Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is a container in J2EE and how does it help?

I'm reading J2EE 1.4 spec right now and there are lot of terms that I do not understand do what. This is from the specs for containers:

Containers provide the runtime support for J2EE application components. Containers provide a federated view of the underlying J2EE APIs to the application components. J2EE application components never interact directly with other J2EE application components. They use the protocols and methods of the container for interacting with each other and with platform services. Interposing a container between the application components and the J2EE services allows the container to transparently inject the services defined by the components’ deployment descriptors, such as declarative transaction management, security checks, resource pooling, and state management.

Since I come from web development world, I'm not able to grasp, what exactly does this do and what is the purpose of a container. What is meant by providing run time support? How does it make a J2EE a better system in terms or scalability, architecture?

like image 460
gizgok Avatar asked Nov 21 '11 11:11

gizgok


People also ask

What is the purpose of container in J2EE?

J2EE containers provide runtime support for J2EE application components. J2EE application components use the protocols and methods of the container to access other application components and services provided by the server.

What is the role of web container in J2EE architecture?

A Web application runs within a Web container of a Web server. The Web container provides the runtime environment through components that provide naming context and life cycle management. Some Web servers may also provide additional services such as security and concurrency control.

What is the use of containers in Java?

Containers are the interface between a component and the low-level, platform-specific functionality that supports the component. Before it can be executed, a web, enterprise bean, or application client component must be assembled into a Java EE module and deployed into its container.

What are the 3 main types of containers in Java?

Three of the most useful container types are JFrame , JPanel , and JApplet . A JFrame is a top-level window on your display. JFrame is derived from JWindow , which is pretty much the same but lacks a border. A JPanel is a generic container element used to group components inside of JFrame s and other JPanel s.


2 Answers

J2EE/Java EE applications aren't self contained. In order to be executed, they need to be deployed in a container. In other words, the container provides an execution environment on top of the JVM.

Also, applications rely on several APIs like JPA, EJB, servlet, JMS, JNDI, etc. The role of the EE compliant container is to provide a standard implementation of all or some of these APIs. This means you can theoretically run your application on top of any container as long as it relies on standard APIs.

From a technical perspective, a container is just another Java SE application with a main() method. EE applications on the other hand are a collection of services/beans/servlets/etc. The container finds these components and runs them, providing API implementations, monitoring, scalability, reliability and so on.

like image 143
Tomasz Nurkiewicz Avatar answered Oct 26 '22 20:10

Tomasz Nurkiewicz


The JEE containers provide a wrapper around your source code.

Typical containers are the classic EJB data bean, and, the message driven bean. To a certain extent servlets and portlets can also be regarded as containers.

What the container provides a large number of services:-

  • invocation -- your code gets loaded and started when required.
  • transactional context -- most container code occurs in an ACID transaction context.
  • configuration -- things like JDBC connections are passed to you by the container.
  • security -- the container will restrict access to your code and data to authorized users.
  • scalability -- since the container is in charge of scheduling it can automatically fire up extra copies if the load gets heavy, or, can be statically configured to run several instances in parallel.
  • Encapsulation. Your program exposes a single interface to the container. However, externally it may expose this interface in a variety of forms (Corba,WSDL,JSM etc.).
  • Common services. such as logging, services exposed by other EJBs. etc.
like image 36
James Anderson Avatar answered Oct 26 '22 19:10

James Anderson