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 method | Bean method can perform the following operations | |
---|---|---|
Container-managed transaction demarcation | Bean-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. 0 JNDI access to java:comp/env Resource manager access Enterprise bean access 1 | N/A (a bean with bean-managed transaction (BMT) demarcation cannot implement the SessionSynchronization interface) |
afterCompletion 2 | 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 3
Bean method | Bean method can perform the following operations | |
---|---|---|
Container-managed transaction demarcation | Bean-managed transaction demarcation | |
constructor | - | - |
setSessionContext | SessionContext methods: getEJBHome, getEJBLocalHome. JNDI access to java:comp/env | SessionContext methods: getEJBHome, getEJBLocalHome. 4 JNDI access to java:comp/env |
ejbCreate ejbRemove 5 | SessionContext methods: getEJBHome, getEJBLocalHome, getEJBObject, getEJBLocalObject. JNDI access to java:comp/env | SessionContext methods: getEJBHome, getEJBLocalHome, getEJBObject, getEJBLocalObject, getUserTransaction. 6 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 7 Resource manager access Enterprise bean access | SessionContext methods: getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject, getUserTransaction. 8 UserTransaction methods JNDI access to java:comp/env Resource manager access 9 Enterprise bean access |