Certification
SCBCD
SCBCD Study Notes : Chapter 3 : Session Bean Component Contract (Part 1)
SCBCD Study Notes : Chapter 3 : Session Bean Component Contract (Part 1) - Page 2
SCBCD Study Notes : Chapter 3 : Session Bean Component Contract (Part 1) - Page 3SCBCD Study Notes : Chapter 3 : Session Bean Component Contract (Part 1)
Please find the Study Notes and resources which covers the 1st Part of Chapter 3 : Session Bean Component Contract, as part of the Sun Certified Business Component Developer exam CX-310-090.
Chapter 3 : Session Bean Component Contract (Part 1)
Identify correct and incorrect statements or examples about session beans, including conversational state, the SessionBean interface, and create methods.
Session bean is specified at deployment as having one of the following state management modes:
The conversational state of a STATEFUL session object is defined as the session bean instance’s field values.
In advanced cases, a session object’s conversational state may contain open resources, such as open sockets and open database cursors. A container cannot retain such open resources when a session bean instance is passivated. A developer of such a session bean must close and open the resources in the ejbPassivate and ejbActivate notifications.
All session beans must implement the SessionBean interface.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public interface SessionBean extends EnterpriseBean { ;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;void ejbActivate() throws EJBException, RemoteException; ;;;;;;;;;;;;;;
;;;;;;;void ejbPassivate() throws EJBException, RemoteException; ;;;;;;;;;;;;;
;;;;;;;void ejbRemove() throws EJBException, RemoteException; ;;;;;;;;;;;;;;;;
;;;;;;;void setSessionContext(SessionContext ctx) throws EJBException, ;;;;;;;
;;;;;;;RemoteException; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public interface EnterpriseBean extends Serializable { ;;;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
A client creates a session bean instance using one of the create ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .....;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; or for LOCAL view: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ..... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; The container creates an instance of a session bean in three steps: Each session bean class must have at LEAST one ejbCreate< METHOD > Invoking create() method by client on home interface of STATELESS session bean will NOT invoke ejbCreate() method on bean object. It only creates new EJB(Local)Object. ejbCreate() on STATELESS session bean is invoked by EJB container when it decides to put object in method-ready pool. For STATELESS session beans container handles creating of instances. Invoking remove() method by client on home interface of STATELESS session bean will NOT invoke ejbRemove() method on bean object. It does nothing. ejbRemove() on STATELESS session bean is invoked by EJB container when it decides to remove object from method-ready pool. For STATELESS session beans container handles removing of instances. Invoking create< METHOD > Invoking remove() method by client on home interface of STATEFUL session bean will invoke ejbRemove() method on bean object. The home interface of a STATELESS session bean must have one (and ONLY one) create() method that takes NO arguments. The create() method of the remote home interface must return the session bean’s remote interface. The create method of the local home interface must return the session bean’s local interface. STATELESS session bean CAN have instance variables, but there is no guarantee, that these variables will be accessed by the same client. However, the instance variables of the instance can contain the state across client-invoked method calls. Examples of such states include an open database connection and an object reference to an EJB object. A STATELESS session bean MUST NOT implement the javax.ejb.SessionSynchronization interface.
Next Page: SCBCD Study Notes : Chapter 3 : Session Bean Component Contract (Part 1) - Page 2
public interface CartHome extends javax.ejb.EJBHome {;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;CartRemote create(String customerName, String account);;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;throws RemoteException, BadAccountException,;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;CreateException;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;CartRemote createLargeCart(String customerName, String account);;;;;;;;
;;;;;;;;;;;;;;throws RemoteException, BadAccountException,;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;CreateException;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CartRemote cart = cartHome.create(“John”, “7506”);;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public interface CartHome extends javax.ejb.EJBLocalHome {;;;;;;;;;;;;;;;;;;;;
;;;;;;;CartLocal create(String customerName, String account);;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;throws BadAccountException, CreateException;;;;;;;;;;;;;;;;;;;;;
;;;;;;;CartLocal createLargeCart(String customerName, String account);;;;;;;;;
;;;;;;;;;;;;;;throws BadAccountException, CreateException;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CartLocal cart = cartHome.create(“John”, “7506”); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.
.