• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Contexts, contexts, everywhere

 
Lisa French
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone please post a brief definition of each of the context terms and what they are used for? There seem to be so many of them.

SessionContext
EntityContext
EJBContext (ancestor of above two?)
JNDIContext
InitialContext

any others?
 
Krishnan Kannan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You missed the MessageDrivenContext in your list.

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.

Kannan
 
Lisa French
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Do I have it now?
 
Paul Codillo
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lisa French:
The other is for accessing JNDI. The only class here is InitialContext.
Do I have it now?

During the setSessionContext() [session beans], setMessageDrivenContext() [MDB], setEntityContext(), you can access your JNDI environment through the InitialContext reference.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic