5 Responsibilities of the Enterprise JavaBean Container
The Enterprise JavaBeans (EJB) container is responsible for providing a number of services to your EJB programs. The services the EJB container must provide are enumerated by the Enterprise JavaBean Specification. That means that you can deploy your EJB to any specification-compliant container and receive the benefit of all the mandated services. Those services include the following key features:
EJB containers provide support for remote and local communication between your EJB components and client applications. This is accomplished in a manner that’s virtually transparent to you, so you don’t have to worry about how it’s implemented when you’re developing EJB components.
EJB containers provide pool and cache services to EJB components. A pool is a repository of unused EJB components that are supplied to a client on demand. A cache is a storage area for EJB components that are assigned to a client program, but not currently in use. These services minimize the memory requirements for the EJB container while providing high performance service to the client program.
EJB containers must provide security services for EJB programs. When you deploy an application you can configure these services according to guidelines laid out in the specification, but you don’t have to perform any special programming to utilize them.
EJB containers must provide transactional services for EJB programs. Transactions define units of work that must all succeed or all fail as a set. Transactions can contain many EJB programs, including EJB programs residing on remote computers. The transactional characteristics of an EJB container can be configured when your EJB application is deployed, but require little to no special programming from you as the EJB developer.
EJB containers provide transparent integration between your EJB components and external data sources such as databases. As a developer, you don’t have to manage storage and retrieval of data from a database, although you may choose to do so if it fits your needs.
The EJB container provides these and other features according to the rules that you define. This is referred to as declarative programming. Declarative programming is a mechanism that allows you to declare the services you want in an XML formatted document. This XML document is called the deployment descriptor, which is deployed with your EJB application. The server reads the deployment descriptor and automatically implements the services you request according to the rules that you declare. Thus, the complexity of implementing these services is completely hidden while you retain the ability to configure the EJB application to suit your needs.
While the EJB specification defines many of the options that you can modify in the deployment descriptor, it doesn’t prohibit EJB container vendors from creating their own custom deployment descriptors to extend existing configuration options or to add new options. All container vendors provide extensions to the deployment descriptor; they use these extensions to connect the generic EJB deployment descriptor to container-specific services. While these extensions are often essential, they’re not standard and not portable. EJB component developers are not responsible for working with container-specific extensions to the deployment descriptor. The service is generally reserved for someone who has specialized knowledge of administering the EJB container.