[jboss-user] [JBoss Seam] - Using the @Factory annotation and stateless session beans

zzzz8 do-not-reply at jboss.com
Sun Sep 24 22:05:27 EDT 2006


I'm wondering why my method that's marked with the @Factory annotation in my stateless session bean isn't being invoked.  Because I'm still new to EJB and Seam, I'm wondering if I don't understand the concepts well enough yet.  Here's what I have (some sample code - the syntax may not be entirely correct - but my actual code compiles):

My stateless session bean implementation:

@Name("TestStatelessBean")
  | @Stateless
  | public final class TestSLSBBean implements TestSLSBLocal {
  |     @Out(value="testVar")
  |     private String testVar = null;
  | 
  |     @Factory("testVar")
  |     public void init() {
  |         ....
  |     }
  | 
  |     public void testSLSBMethod() {
  |         ....
  |     }
  | }

The business interface for this bean:

@Local
  | public interface TestSLSBLocal {
  |     void init();
  | 
  |     void testSLSBMethod();
  | }

The stateless session bean is invoked from a stateful session bean with the default conversation scope:

@Name("TestStatefulBean")
  | @Stateful
  | public final class TestSFSBBean implements TestSFSBLocal {
  |     @In(value="TestStatelessBean", create = true);
  |     TestSLSBLocal test;
  | 
  |     void testSFSBMethod() {
  |         test.testSLSBMethod();
  |     }
  | }

So when test.testSFSBMethod() is invoked, the init method in TestStatelessBean is somehow never invoked before testSLSBMethod is called (at least it doesn't appear so in my debugger).  I would hate to have to add the init() method call to everyone one of the methods in the TestSLSBBean class.  What am I doing wrong, or do I have to add init() for each method in the TestSLSBBean class?  Thanks!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973774#3973774

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973774



More information about the jboss-user mailing list