Share on Google+Share on Google+

Given a list of methods for a stateful or stateless session bean class, define which of the following operations can be performed from each of those methods: SessionContext interface metho

Advertisement
This page discusses - Given a list of methods for a stateful or stateless session bean class, define which of the following operations can be performed from each of those methods: SessionContext interface metho

Given a list of methods for a stateful or stateless session bean class, define which of the following operations can be performed from each of those methods: SessionContext interface methods, UserTransaction methods, Java Naming and Directory Interface API (JNDI API) access to java:comp/env environment naming context, resource manager access, and other enterprise bean access.

Stateful Session Bean

Table 4.1. Operations allowed in the methods of a stateful session bean

Bean methodBean method can perform the following operations
Container-managed transaction demarcationBean-managed transaction demarcation
constructor--
setSessionContext

SessionContext methods: getEJBHome, getEJBLocalHome.

JNDI access to java:comp/env

SessionContext methods: getEJBHome, getEJBLocalHome.

JNDI access to java:comp/env

ejbCreate

ejbRemove

ejbActivate

ejbPassivate

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject.

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject, getUserTransaction.

UserTransaction methods

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

Business method from component interface

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, getRollbackOnly, isCallerInRole, setRollbackOnly, getEJBObject, getEJBLocalObject.

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject, getUserTransaction.

UserTransaction methods

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

afterBegin

beforeCompletion

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, getRollbackOnly, isCallerInRole, setRollbackOnly, getEJBObject, getEJBLocalObject.

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

N/A

(a bean with bean-managed transaction (BMT) demarcation cannot implement the SessionSynchronization interface)

afterCompletion

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject.

JNDI access to java:comp/env

Stateless Session Bean

Table 4.2. Operations allowed in the methods of a stateless session bean

Bean methodBean method can perform the following operations
Container-managed transaction demarcationBean-managed transaction demarcation
constructor--
setSessionContext

SessionContext methods: getEJBHome, getEJBLocalHome.

JNDI access to java:comp/env

SessionContext methods: getEJBHome, getEJBLocalHome.

JNDI access to java:comp/env

ejbCreate

ejbRemove

SessionContext methods: getEJBHome, getEJBLocalHome, getEJBObject, getEJBLocalObject.

JNDI access to java:comp/env

SessionContext methods: getEJBHome, getEJBLocalHome, getEJBObject, getEJBLocalObject, getUserTransaction.

JNDI access to java:comp/env

Business method from component interface

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, getRollbackOnly, isCallerInRole, setRollbackOnly, getEJBObject, getEJBLocalObject.

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject, getUserTransaction.

UserTransaction methods

JNDI access to java:comp/env

Resource manager access

Enterprise bean access

Advertisements

Advertisement

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Comments:0