I have a stateful session bean with the following annotations:
@Stateful
@Name("fooBar")
public class FooBarAction implements FooBar {
I noticed there are 2 ways to get my FooBar instance:
Seam lookup:
Component.getInstance(FooBarAction.class);
JNDI lookup:
(new InitialContext()).lookup("MYAPP/FooBarAction/local");
When I use the JNDI lookup, each time I execute the lookup, I notice a new instance of FooBar is created. The default constructor gets called, and setter methods are used to bring back the state (attributes) of my SFSB.
When I use the Seam lookup, no default constructor is called and no setter methods are called. I just have the instance. The same instance as the previous lookup.
So what's the difference? And what is the best way to use?