Can I call from one ejb3 session bean (statless/statefull) method to other method in same session bean ? does state of members will be save between calls ?
Can I call from one ejb3 session bean method to other method in same session bean ?
207 views Asked by yryrp At
1
Yes, you can. Use
@Resource SessionContext
to inject an instance, and then use the getBusinessObject (or getEJBObject or getEJBLocalObject depending on which view you want); see the javadoc for those methods.For stateless beans, the invocation will be on a new bean instance. Depending on what you're trying to do, it can be even simpler to use
@EJB YourInterface
to directly inject the proxy rather than using SessionContext.For stateful beans, the state of the bean will be "preserved" because you'll be invoking the same underlying bean instance.