Enterprise Java Bean What is EJB? Enterprise Java Bean is a kind of technology which adds distribued function to a javabean and also let developers realise it easily. The current EJB version is 1.1. It is a core part of Java 2. An EJB consists of three parts, two interfaces and one bean implementation class. The EJB container will do most trivial things for the developers, such as created, or deleted a bean. A client needs to get a reference from the home interface, then it can create an instance of the EJB by the remote interface. After the EJB is created, the client can use the business methods on the EJB. Sun wants to separate the middleware into business logic and business data layers. So, we got session beans and entity beans. Session beans represent business processes or agents that perform a service, while entity beans represent data in a database. Session beans may use other beans on behalf of the client application to perform a task or access the database directly. The entity bean is used to represent data in the database. It provides an object-oriented interface to data that would normally be accessed by the JDBC or some other back-end API. More than that, entity beans provide a component model that allows bean developers to focus their attention on the business logic of the bean, while the container takes care of managing persistence, transactions, and access control. There are two types of entity bean: Container-Managed Persistence (CMP), and Bean-Managed Persistence (BMP). With CMP, the container manages the persistence of the entity bean, which absolutely no database access code is written in the bean class. With BMP, the entity bean contains database access code (usually JDBC) and is responsible for reading and writing its own state to the database. EJB Web Sites Books
EJB Tutorial:
|