EJB design: Plugable EJB archtecture

  1. Plugable EJB archtecture (1 messages)

    Hi all, I'm working for a company that uses Bea Weblogic 9.2 with Beehive annotations and controls for a web application. The use case is the following:
    • A user selects a file for upload and a message type from a combo box.
    • The file is uploaded and needs to be handled by a specific EJB that will save the message in one or more tables in the database.
    Some developers want to define an interface that has the following method: public Result handle(byte[] msg, String msgType) Different message types require of course different implementations because the database tables where they are store in differ. Therefore a mapping between the msgType and the JNDI name of (local) session bean home interface is need. So you end up with a Service Locator implementation that also delegates the call to the right EJB. To be more generic, they want to use a database table for the mapping between the message type and the JNDI name of the EJB. This way they want to plugin new message handlers by deploying an EAR with EJBs implementing the above interface. Does anyone know another way to do the mapping from the above message type to a conrete EJB instance? I like the callback methods in Spring but we can't use Spring for the moment. Kind regards, Mark

    Threaded Messages (1)

  2. Strategy Pattern?[ Go to top ]

    Could you use the Strategy design pattern to solve this? The strategy pattern is useful for situations where it is necessary to dynamically swap the implementation used in an application at run time through polymorphisms. So instead of.. public Result handle(byte[] msg, String msgType) you could use... public Result handle(byte[] msg, MessageStrategy messageStrategyImpl) In your example each concrete MesseageStrategy would have its own set of implementation code to point to different EJB implementations.