Previous | Home | Next |
EJB is stands for enterprise java bean. It is a specification provided by Sun Microsystems to develop secured, robust and scalable distributed applications. When run EJB application, you need an application server (EJB Container) such as Jboss, Glassfish, Weblogic, Websphere etc. It performs the following tasks as follows:
- Life cycle management,
- Security,
- Transaction management,
- Object pooling.
EJB application is deployed on the server, so it is called server side component also. EJB is a COM (Component Object Model) provided by Microsoft. But, it is different from Java Bean, RMI and Web Services.
There are following advantages of EJB as given below:
- EJB container provides System level services to enterprise java beans.
- EJB developer just focus on business logic and on solving business problems.
- To access EJB free security is provided.
- Declarative transactions are provided.
- EJBs are cached & pooled. Containers manage the EJB life cycles.
- Remote access capabilities are present & are clustered for sake of scalability.
- OO concepts are supported for example inheritance.
- Usage of attributes or annotation based programming is possible.
- Free usage & access of complex resources.
- EJB is a standard API due to which applications build on EJB can run on any complaint Java EE web application server.
There are several disadvantages of EJB as given below:
- Requires application server.
- Requires only java client. For other language client, you need to go for webservice.
- Complex to understand and develop ejb applications.
- Complicated and large specification.
- Increased time of development.
- Complexities are added in comparison with straight Java classes.
- Potential to create a more essential, costly & complex solution.
- Continual revisions of the specifications.
- Lots of resources are used & have also lots of artifacts.
There are three types of enterprise bean in java as given below:
-
Session Beans- A session bean encapsulates business logic that can be invoked programmatically by a client over local, remote, or web service client views. A session bean is not persistent, means its data is not saved to a database. EJB Session Beans has three types as below:
- Stateful Session Bean: In stateful session bean, the state of an object consists of the values of its instance variables. In a stateful session bean, the instance variables represent the state of a unique client / bean session.
- Stateless Session Bean: In EJB stateless session bean conversational state is not maintained with client. When a client invokes the methods of a stateless bean, the bean’s instance variables may contain a state specific to that client but only for the duration of the invocation.
- Single tone Session Bean: A singleton session bean is instantiated once per application and exists for the whole lifecycle of the java application. A single enterprise bean instance is shared across all the applications clients and it is concurrently accessed by clients.
-
Message Driven Bean (MDB)- Message Driven Beans ( MDBs ) also known as Message Beans. Message Driven Beans are business objects whose execution is triggered by messages instead of by method calls.
- Entity Bean- It encapsulates the state that can be persisted in the database. It is deprecated. Now, it is replaced with JPA (Java Persistent API).
Previous | Home | Next |