The Enterprise Java Bean (EJB) container is a fundamental part of the Java Enterprise architecture. In a nutshell, the EJB container provides the environment used to host and manage the EJB components deployed in the container. The container is responsible for providing a standard set of services, including caching, concurrency, persistence, security, transaction management, and locking services.
The container also provides distributed access and lookup functions for hosted components, and it intercepts all method invocations on hosted components to enforce declarative security and transaction contexts.
As depicted in this image, with JBoss AS 7, you will be able to deploy a rich set of EJB components:
Stateless session beans (SLSB): SLSB are objects whose instances have no conversational state. This means that all bean instances are equivalent when they are not servicing a client.
Stateful session beans (SFSB): SFSB support conversational services with tightly coupled clients. A stateful session bean accomplishes a task for a particular client. It maintains state for the duration of a client session. After session completion, state is not retained.
Message-driven beans (MDB): MDB are a kind of Enterprise Beans that are able to asynchronously process messages sent by any JMS producer.
EJB components, which don’t keep conversional states (SLSB, MDB), can be optionally configured to emit timed notifications. See the section named Configuring the timer service for more information about it.
Besides the standard EJB components, the application server also supports the new EJB 3.1 variants introduced by Java EE 6, which are:
Singleton EJB: This is essentially similar to a stateless session bean, however, it uses a single instance to serve the client requests. Thus, you are guaranteed to use the same instance across invocations. Singletons can use a richer life-cycle set of events and a stricter locking policy to control concurrent access to the instance. In the next chapter, which is about Web applications, we will illustrate a Java EE 6 application that makes use of a Singleton to hold some cached data.
No-interface EJB: This is just another view of the standard session bean except that local clients do not require a separate interface, that is, all public methods of the bean class are automatically exposed to the caller.
Asynchronous EJB: These are able to process client requests asynchronously just like MDBs, except that they expose a typed interface and follow a more complex approach for processing client requests, which is composed of:
In the next chapter, which is about Web applications, we will illustrate a Java EE 6 application, which makes uses of a Singleton to hold some cached data.
Get Updates on Tech posts, Interview & Certification questions and training schedules