EJB session beans
What are the session beans? Explain the types of session beans.Session Bean: The client’s business logic is implemented by a session bean of EJB. For example a session bean can calculate interest on deposits for a banking application. Session beans are used as reusable components in EJB architecture that encapsulate the business logic and can be used by other clients. These clients can optimize the use of EJB container. The name is derived as they are live as long as a client’s session using them.
There are two types of session beans: 1. Stateless session beans 2. Stateful session beans.
1. Stateless session bean :
The stateless session bean does not hold a conversational state of the client. When a client invokes a method of this bean, the bean’s instance variables may contain a state, but only for the invocation period. When the method execution is completed, the state will be lost.
2. Stateful session bean :
Stateful session bean is associated with a single client. The EJB container always uses the same stateful session bean instance to service a given client. The stateful session bean retains the data retrieved by the client from the database.What are the steps involved in developing a stateless session bean?1. Defining Home Interface 2. Defining Remote Interface 3. Developing the EJB class 4. Authoring deployment descriptors 5. Package the application 6. Deploy the application in the EJB container 7. Test the applicationDescribe the lifecycle of stateless session beans.The life cycle of the stateless session bean starts when the client first obtains the reference of the session bean. Before invoking the annotated @PreConstruct method, the container performs the dependency injection. After this process, the bean allows the client to invoke its methods.
At the end of the life cycle of the session bean the container calls the annotated @PreConstruct method, followed by the garbage collection of the bean.What are the steps involved in developing a stateful session beans?The following are the steps involved in developing the Stateful Session Bean: 1. Defining Home Interface 2. Defining Remote Interface 3. Developing the EJB class 4. Authoring deployment descriptors 5. Package the application 6. Deploy the application in the EJB container 7. Test the applicationDescribe the lifecycle of stateful session beans.First the client gets the reference of a stateful session bean. Then the stateful session bean starts its life cycle. The container performs dependency injection before invoking the annotated method @PostConstruct. Then the bean is ready. The bean may be deactivated while in the ready state by the container.
The bean moves from memory to secondary memory in the passivate mechanism. Then the annotated method @PostPassivate is invoked by the container before passivating the bean. The container invokes the annotated @PostActivate method, if a client invokes a business method on the passivated bean.
The client invokes the annotated @Remove method just before ending the life cycle of this bean. Following this action, the container invokes the annotated @PreDestroy method. This results in making the bean ready for garbage collection.Explain the steps involved in deploying a session bean.1. Installing an Enterprise JavaBeans Server. 2. Specifying the Enterprise JavaBeans Remote Interface. 3. Specifying the Home Interface. 4. Authoring the Enterprise Java Bean Class. 5. Creation of the ejb-jar File. 6. Deployment of the Session Bean in Enterprise JavaBeans container. 7. Authoring the Enterprise Java Bean Client. 8. Running the Client.
|
EJB Entity beansEJB Entity beans - What are Entity beans? Explain the need of entity beans, Explain the types of Entity beans. Explain their uses, Explain the steps involve in developing Entity beans, What are the steps involve in deployment of CMP and BMP entity beans, Explain the lifecycle of entity beans.
EJB 2.0 Entity ModelEJB 2.0 Entity Model - Explain the advantages of EJB 2.0 container-managed persistence over bean-managed persistence, Explain the types and role of abstract methods in EJB 2.0 persistence, Explain the structure of EJB query language (EJB QL)
EJB Asynchronous communicationEJB Asynchronous communication - What is a message-driven bean?, Explain the need for asynchronous communication, What is the JMS messaging?, Explain the JavaMail API. Explain how it is used to compose and dispatch a mail.