EJBContext --> provides an instance with access to the container-provided runtime context for all types of EJBs (Session, Entity and MDB). Parent of SessionContext, EntityContext, MessageDrivenContext interfaces. Has methods for getting the EJB Home, client security(getCallerIdentity, getCallerPrincipal, isCallerInRole), transaction (get/setRollbackOnly). These methods are available for all types of EJBs (but at different points in the lifecycle).
SessionContext --> access to the runtime session context that the container provides for the Session EJB (both StateLESS, StateFUL). Has additional methods like getEJBObject and getEJBLocalObject.
EntityContext --> provides an instance with access to the container-provided runtime context of an entity EJB. Has additional methods like getEJBLocalObject, getEJBObject, getPrimaryKey.
------------------------------ Contexts used in JNDI area ------------------------------ InitialContext --> If you want to do a JNDI lookup of an EJB or an object, you need to create an InitialContext with appropriate values (usually for remote clients a Hashtable with the server name/IP and the Vendor's initial context factory).
JNDIContext --> There is no such class or interface J2EE 1.3 and J2SDK 1.3 or 1.4. The InitialContext is usually referred/used in the context(no pun intended) of JNDI.
Hope this helps.
SCJP1.4 SCBCD 1.3
posted 15 years ago
I think that I've heard and read the InitialContext reffered to as the JNDIContext. Now that I look at my books, JNDIContext seems to usually be the reference variable name for the InitialContext.
Thanks for helping clear this up. For some unknown reason, the contexts have been a "sticky" topic for me.
So, it sounds like there are only two types of contexts.
One for the EJBs themselves that provide them with an "in" to the container environment. Session, entity, and message driven beans each have their own subclass of EJBContext for this.
The other is for accessing JNDI. The only class here is InitialContext.