yryrp
yryrp

Reputation: 37

Can I call from one ejb3 session bean method to other method in same session bean ?

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 ?

Upvotes: 0

Views: 162

Answers (1)

Brett Kail
Brett Kail

Reputation: 33956

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.

Upvotes: 1

Related Questions