While at one time an extremely complex set of tools, mastered by only a small percentage of Developers and Programmers, the Enterprise Java Beans (EJB) architecture for the server side modular building of applications has evolved over the years to be more coder friendly and become easier to use. It is one of the Application Programming Interface (API) server based architecture options available in the Java platform.
Continuing with the Java predilection for Coffee references, EJB consists of 3 main types of “Beans”. These are”
1) Session Beans that can be Stateless or Statefull
2) Entity Beans
3) Message Driven Beans
Web Support Tech: EJB
Stateless Session Beans:
Stateless Beans are distributed objects not meant to maintain their state (persistence), and are coded for single occurrence events like a user sending a Customer Service email to your company using a form on the Contact Us page of your website. Since the information stored in these beans is temporary in nature, it is lost when a session ends or when a system or server crashes. This does not reduce their importance it only is a statement as to their application and they are therefore less resource intensive. There are many instances when information/data does not require long-term storage, and stateless beans are use extensively.
Statefull Beans while still not permanent hold information or data for short time when it is to be used during a sequence of steps in a process. These beans are used to maintain the data during the client session as would be required in a Shopping Cart application wherein the information carries forward from one screen to the next throughout the process. The data stored in Statefull Beans are generally removed at the end of a session but could be persisted for individual clients, and, if not set up to do so, will not survive system or server crashes.
Entity Beans are no longer being incorporated into Applications as their usefulness has been replaced by a Java Persistence API. However there are many older applications that have them built in. As a result new systems are all backward compatible. Web Support Tech programmers are familiar with these EJB Entity Beans and know how to utilize their database data storage abilities. Entity Beans, unlike Stateless beans and Statefull Beans, survive even if the server crashes because they recollect the data for the database when the server comes backup.
Message Driven Beans:
A Message Driven Bean is a Bean instance that can listen to messages from the Java Message Service (JMS). Unlike other types of beans, a MDB does not have a client view and clients cannot look-up an MDB instance. An MDB just listens for any incoming message on a JMS queue (or topic) and then processes it automatically.
Message Driven Beans are primarily designed to handle asynchronous JMS messages. That is, they handle operations that do not require or trigger an immediate response to the user. For example, a visitor to your website clicking on a add me to your newsletter box may trigger a call to a Message Driven Bean to add the user to a list in the company’s database. This call is considered asynchronous because the user does not anticipate an immediate response.
With many web-oriented applications requiring a high level of scalability and maintainability, EJB provides a robust environment for developing this kind of complex web applications. One of the key reasons for the widespread use of EJB is that it allows Application Designers, Developers and Programmers to design and deploy business functionality independently from the presentation layer. To be able to program and code EJB once and then run it on any server platform gives it an advantage over some other modular programming methodologies.