0 Replies Latest reply on Jun 3, 2014 11:35 AM by bob1978

    Design Pattern for Generic EJB Invocation

    bob1978

      I'm currently trying to architect a new JEE6 application to invoke EJB's and EJB methods in a generic way. Heres what im thinking...

      Client applications interact with a remote stateless EJB (e.g. FinancialServiceExecutor) passing a Service Request DTO with the following properties for example:

      • Service Key (e.g. Ordering, Invoicing)
      • TaskId (Delete, Add, Update etc.)
      • Task Attributes Map of String, Object (Parameters to be passed to each service)

      This EJB will contain the following two method:

      • executeService(ServiceRequestDTO) throws FinancialServiceException;
      • executeAsynchService(ServiceRequestDTO, CorrelationId) throws FinancialServiceException (using EJB 3.1 @Asynchronous, JMS message will be sent back to caller using the correlation id to notify the caller if the service request was sucessful or not)

      For each of these execute methods the Service Key is used to locate the correct EJB (e.g. OrderingEJB, Invoicing EJB etc. these maybe remote or local), this i can do using the key as driver for the JNDI lookup.

      I'm struggling with how to invoke the EJB methods in a generic fashion.... i dont want to hard code methods names on client side and use reflection to perform the invocation on the EJB proxy.... is there a nice clean way to do this in JEE/CDI maybe?

      Any Ideas?