First page Back Continue Last page Graphics

Setting Context...


Notes:

The set*Context( ) method is called when the bean is created; it is the first EJB method called. This method lets the container pass the context object to the bean. The bean should save the reference context to an instance variable for later use. This method is also the place to connect to external resources that the bean instance will use.
Note that in the case of entity beans, setEntityContext( ) is called when the bean instance (not the entity it represents) is created.
(Again note the similarity to Java servlets. The javax.servlet.Servlet interface has an init( ) method that receives a ServletContext object; the servlet is supposed to store its reference in an instance variable for future use.)