EJB (Enterprise JavaBeans) is not a new concept, but many people will Ching when they hear or see the noun. EJB components are built into the Java EE specification, tying the application's presentation layer to the back-end information system (such as a database or the main frame computer). The EJB architecture uses both the functionality of the EJB object and the environment in which they are run.
Why come out an EJB
Conceptually, the EJB object encapsulates the business object and its concepts, allowing the developer to focus on the details of the solution. From a design standpoint, EJBS should be combined in a lightweight and interactive way. This can make a single EJB, whether or not it is a business application, possible to use an EJB representative for either self-development or a 3rd party vendor development that can be used in a variety of applications. For example, CRM (Customer Relationship Management) tool and an electronic user. These already adaptable objects are configured to be very simple because of the deployment descriptor, the XML file that describes the EJB. The deployment descriptor allows EJB properties and behavior to be modified without recompiling.
The premises of the EJB
EJB objects reside within the EJB container, which is an environment that provides a variety of services to developers. The container may be responsible for handling security, transaction, and instance management based on the specific configuration. Because programmers do not have to do these tasks personally, the development time is greatly saved.
There is a significant difference between the two concepts, the Java server and the EJB container, which may be part of the Java server, but not necessarily. EJB clients typically take the form of a Java servlet or JSP in the context of an EE server component. However, due to the cancellation of dependency on the Java EE Web layer, standard EJB container services can accept requests from multiple types of client programs, applications written in Java, or in various other languages. Communication with the EJB container is a prerequisite for customer action.
The contents of the EJB
The EJB object is divided into the following three categories:
Session Beans
Entity Beans
Message driven beans
Depending on the bean behavior that you want, some attributes determine the type of bean you are using.
Session Beans
The role of Session beans is built on the basis of conversation. After the customer requests and receives the Bean functionality, the session with a specific bean terminates and no record of the session occurs. The session bean type can also be further subdivided into stateless or stateful mode.
Stateless sessions beans do not know the customer or the context in which the request is involved, making it an ideal tool for a single request/response application. This is true, for example, when a user searches for all bug-tracking systems that expose bugs. The client application contacts a stateless session bean and passes the search parameters to it. The bean then accesses the database, selects entries that match the search criteria, and returns the records back to the client program. After the communication is complete, the bean does not retain the interaction information. As a result, multiple clients can access stateless session beans at the same time without affecting each other.
Instead, stateful sessions beans the request to a particular customer, creating a one-to-one relationship between the customer and the bean. A shopping cart bean is one example. The user implements the standard e-commerce task, adds the commodity to the shopping cart, enters the address information and then orders. The shopping cart Bean maintains state, so it knows that all of these variables are associated with a particular customer.
Entity Beans
An entity (Entity) beans represents a business object or data that persists after a session terminates. They usually exist as a single record in the database, and of course, they may be stored in the form of other media, such as files. An object represents a user, with a name, contact, language selection, and so on, which represent the purpose of the entity bean. As one of the most essential connotations of persistence, the unique identification or primary key of the entity Bean plays a role in identifying and retrieving the correct object information. Entity beans requires a primary key to encapsulate the unique identifier of the object as a "helper class".