4 Replies Latest reply on Oct 23, 2008 5:44 PM by gjeudy

    Reuse stateless services built with Seam

    gjeudy

      Hi,


      I'm using Seam 2.0.1.GA and I would like to know if I can reuse my stateless service layer for remote EJB calls issued by other applications.


      I'm using SMPC so the EntityManager gets injected through @In annotation. I realize that if I access my stateless EJB through traditional JNDI lookup the EntityManager will not get injected.


      Has anyone found a solution where I can still get the EntityManager injected? I guess I would need somehow to pass through Seam context to get hold of my stateless EJB.


      Another alternative I guess is to inject both


      @Stateless
      @Local(MyLocalInterface.class)
      @Remote(MyRemoteInterface.class)
      public class MyStatelessServiceImpl implements MyLocalInterface, MyRemoteInterface {
      
      @In 
      EntityManager em;
      
      @PersistenceContext(unit="MyPU") 
      EntityManager em2;
      
      ...
      }



      and use @In EntityManager if populated otherwise fallback to @PersistenceContext injected one. This workaround appears a little messy though..


      Thanks,
      -Guillaume