EJB stands for Enterprise Java Beans which is a Java enterprise technology that enables developers to create business logic and object on the application servers. EJB is part of the J2EE technologies and is implemented and adopted by most of the Java vendors such as IBM, Oracle, and Apache.
There are three types of EJBs
An entity bean is a java server object that represents a record in the database. It enables the developer to deal with persistence as java objects rather than dealing with the JDBC connections and result sets. In EJB3 Entity beans are represented by the persistence API which uses ORM (Object Relation Mapping) to create Java objects that map to tables and database entities. This means that Java beans are going to be created to represent the data tables in the database and the mapping is going to be performed using an XML file called persistence.xml to map every field in the object to the appropriate field in the table.
Session beans enable the developer to create business logic that will reside on the server for access and reuse from applications residing either on the same server or other servers.
There are two kinds of session beans
Stateless Session Beans
This kind of sesson beans does not hold information regarding the state of conversation with the client application. A example of stateless session bean can be the send mail bean or the weather telling bean where no information regarding the conversation is being stored or relevant o the bean.
Statefull Session Bean
Unlike stateless session beans stateful session beans hold information regarding the conversation with the client. An example of stateful session bean is the shopping cart bean where the client will add a new item to the bean each time it calls the bean method.
Message Driven Beans
Message driven bans enable your application to receive messages and work in an asynchronous pattern. An example of message driven bean is the shop that sends a message to the warehouse to complete and order. When the warehouse receives the message the warehouse will perform the appropriate action.
In my next post I’ll show you how to create an entity bean using Eclipse EE and JBoss Application Server
The Java Code Admin