A container is a logical part of a J2EE Server which contains java components
Before any component can be executed, it must be assembled. The assembly process involves per logical container:
- the configuration of the services
- the override of functionality for the non-configurable services.
The fact that the J2EE architecture provides configurable services means that application components within the same J2EE application can behave differently based on where they are deployed.
For example, an enterprise bean can have security settings that allow it a certain level of access to database data in one production environment and another level of database access in another production environment.
Type of container
On the J2EE Server
An EJB container is a run-time container for beans that are deployed to an application server. The container is automatically created when the application server starts up, and serves as an interface between a bean and run-time services such as:
A container is automatically created when the application server starts up, and serves as an interface between a bean and run-time services such as:
- Life cycle management
- Code generation
- Transaction management
- Locking and concurrency control
- Persistence management
Manages the execution of JSP page and web components for J2EE applications.
On the client
- Application client container: Manages the execution of application client components.
- Applet container: Manages the execution of applets. Consists of a Web browser and Java Plug-in running on the client together.
The assembly process involves the container settings in order to configure services such as:
- security: The component (web, bean) are only accessed by authorized users.
- transaction management: The J2EE transaction model lets you specify relationships among methods that make up a single transaction so that all methods in one transaction are treated as a single unit.
- Java Naming and Directory Interface (JNDI) lookups: JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access naming and directory services.
- and remote connectivity. The J2EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine.
The container also manages non-configurable services such as:
- enterprise bean and servlet life cycles,
- and access to the J2EE platform APIs described in the section J2EE APIs.
Although data persistence is a non-configurable service, the J2EE architecture lets you override container-managed persistence by including the appropriate code in your enterprise bean implementation when you want more control than the default container-managed persistence provides. For example, you might use bean-managed persistence to implement your own finder (search) methods or to create a customized database cache.