Writing the session bean class Writing the session
Saturday, January 19th, 2008Writing the session bean class Writing the session bean class To create a session bean class, 1 Create a class that implements the javax.ejb.SessionBean interface. 2 Implement one or more ejbCreate() methods. If you are creating a stateless session bean, the class implements just one parameterless ejbCreate() method. If you ve already created the remote home or local home interface for the bean, the bean must have an ejbCreate() method with the same signature for each create() method in the remote home/local home interface. 3 Define and implement the business methods you want your bean to have. If you ve already created the remote or local interface for the bean, the methods must be defined exactly as they are in the remote/local interface. JBuilder s EJB tools can start these tasks for you, including creating the home and remote interfaces. They create a class that extends the SessionBean interface and write empty implementations of the SessionBean methods. You fill in the implementations if your bean requires them. The next section explains what these methods are and how they are used. Implementing the SessionBean interface The SessionBean interface defines the methods all session beans must implement. It extends the EnterpriseBean interface. package javax.ejb; public interface SessionBean extends EnterpriseBean { void setSessionContext(SessionContext sessionContext) throws EJBException, RemoteException; void ejbRemove() throws EJBException, RemoteException; void ejbActivate() throws EJBException, RemoteException; void ejbPassivate() throws EJBException, RemoteException; } The methods of the SessionBean interface are closely associated with the life cycle of a session bean. This table explains their purpose: Method Description setSessionContext() Sets a session context. The bean s container calls this method to associate a session bean instance with its context. The session context interface provides methods to access the runtime properties of the context in which a session runs. Usually a session bean retains its context in a data field. ejbRemove() Notifies a session object that it is about to be removed. The container calls this method whenever it removes a stateful session bean as a result of the client calling a remove() method of the remote/local or remote home/local home interface. ejbActivate() Notifies a stateful session object that has been activated. ejbPassivate() Notifies a stateful session object that it is about to be deactivated by the container. The ejbActivate() and ejbPassivate() methods allow a stateful session bean to manage resources. 150 Developing Applications with Enterprise JavaBeans
We are here to provide web hosting at an affordable rate for the online Christian community. The term “Christian” is used by various groups with diverse beliefs to describe themselves. Some people, including many born-again Christians, use a fairly specific definition of “Christian”. They believe that in order to be a Christian, one must follow Jesus, and that the proof of this is found in agreeing to and following the doctrines set forth in the Bible. Others who refer to themselves as Christians require only that one believes that Jesus is the Son of God, that he died, and that he was resurrected from the dead, to claim the term Christian.Check Christian Web Hosting section.