Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Enterprise Java Beans:

Tags: bean

EJB stands for Enterprise Java Bean and is the widely-adopted server side component architecture for J2EE. it enables rapid development of mission-critical application that are versatile, reusable and portable across middle-ware while protecting IT investment and preventing vendor lock-in.

EJB technology is the core of J2EE. It enables developers to write reusable and portable server-side business logic for the J2EE platform.

EJB is a specification for J2EE server, not a product; Java beans may be a graphical component in IDE.

Key Features of the EJB technology:

1. EJB components are server-side components written entirely in the Java programming language

2. EJB components contain business logic only - no system-level programming & services, such as transactions, security, life-cycle, threading, persistence, etc. are automatically managed for the EJB component by the EJB server.

3. EJB architecture is inherently transactional, distributed, portable multi-tier, scalable and secure.

4. EJB components are fully portable across any EJB server and any OS.

5. EJB architecture is wire-protocol neutral--any protocol can be utilized like IIOP, JRMP, HTTP, DCOM, etc.

Benefits of the EJB technology:

o Rapid application development

o Broad industry adoption

o Application portability

o Protection of IT investment

There are three kinds of enterprise beans:

Session Bean: Session Bean is used to represent a work-flow on behalf of a client. There are two types: Stateless and Stateful. Stateless bean is the simplest bean. It doesn't maintain any conversational state with clients between method invocations. Stateful bean maintains state between invocations.

Entity Bean: Entity Bean is a Java class which implements an Enterprise Bean interface and provides the implementation of the business methods. There are two types: Container Managed Persistence (CMP) and Bean-Managed Persistence (BMP).

Message-driven beans: A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS. A message-driven bean enables asynchronous clients to access the business logic in the EJB tier.

Persistence in EJB is taken care of in two ways Container managed persistence (CMP) or bean managed persistence (BMP), depending on how you implement your beans:

1. For CMP, the EJB container which your beans run under takes care of the persistence of the fields you have declared to be persisted with the database - this declaration is in the deployment descriptor. So, anytime you modify a field in a CMP bean, as soon as the method you have executed is finished, the new data is persisted to the database by the container.

2. For BMP, the EJB bean developer is responsible for defining the persistence routines in the proper places in the bean, for instance, the ejbCreate (), ejbStore (), ejbRemove () methods would be developed by the bean developer to make calls to the database. The container is responsible, in BMP, to call the appropriate method on the bean. So, if the bean is being looked up, when the create () method is called on the Home interface, then the container is responsible for calling the ejbCreate () method in the bean, which should have functionality inside for going to the database and looking up the data.

EJBContext

EJBContext is an interface that is implemented by the container, and it is also a part of the bean-container contract. Entity beans use a subclass of EJBContext called EntityContext. Session beans use a subclass called Session Context. These EJBContext objects provide the bean class with information about its container, the client using the bean and the bean itself. They also provide other functions.



This post first appeared on Web Applications Development | Custom Web Applicat, please read the originial post: here

Share the post

Enterprise Java Beans:

×

Subscribe to Web Applications Development | Custom Web Applicat

Get updates delivered right to your inbox!

Thank you for your subscription

×