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.
Learn how to use JBOSS, from beginner basics to advanced techniques, with online video tutorials taught by industry experts. Enroll in the Free JBOSS Training Demo!
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 is an object 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 supports conversational services with tightly coupled clients. A stateful session bean accomplishes a task for a particular client. It maintains a state for the duration of a client session. After session completion, the state is not retained.
Message-driven beans (MDB): MDB is a kind of Enterprise Beans that are able to asynchronously process messages sent by any JMS producer.
[Related Article: JBoss Interview Questions for Experienced]
EJB components, which don’t keep conversational 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 use of a Singleton to hold some cached data.
As a content writer and storyteller, Raunaak Mitra regards himself to be a prodigy in writing. He firmly believes that language is borderless, and anyone can write as long as they have a strong narrative capability and the ability to emote feelings into words. Authors like F. Scott Fitzgerald and R. K. Narayan have influenced him to keep the writing as simple as possible for anyone to understand. Other than being well-versed about technological trends like AI, Machine Learning, AR, VR, Gaming, Microprocessors, Cloud Computing, Industry 4.0, literally any technological advancement (old or new), he also shares a knack to curate fiction on sci-fi, satire, and thriller genres.