Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of a Java Container

I've read\heard many times about java containers such as a servlet container, however, I can't seem to find a good definition of what a container is in the enterprise java world.

Does anyone know of a good definition of an enterprise java container?

like image 836
javamonkey79 Avatar asked Aug 22 '11 17:08

javamonkey79


People also ask

What are the 3 main types of containers in Java?

There are three container types - frames, dialogs and applets - but applets are no longer used and most browsers no longer support them.

What acts as a container in Java?

Container is an abstract class that serves as a general purpose holder of other Component objects. The Container class holds the methods for grouping the components together, laying out the components inside it, and dealing with events occurring within it.

What is container and component in Java?

Java For TestersA component represents an object with graphical representation. The class Container is the superclass for the containers of AWT. The container object can contain other AWT components.


2 Answers

The common containers in Java EE are servlet container and the EJB container, and I see these as examples of IoC(Inversion of Control) containers. The crucial aspects are :

  1. Your code does not have any main() or "wait here for a request logic" - the container starts up and configures itself and then eventually initialises your code and delivers requests
  2. Your code may be one of many similar classes (servlets in a servlet container, EJBs in an EJB container) whose instances have life-cycles to be controlled by the container.
  3. Requests are delivered to your servlet or EJB via some protocol defined by the container, using resources (eg. HTTP ports) controlled by the container, and possibly with considerable infrastructure cleverness (look at the HTTP request queues, EJB load balancing etc.)
  4. There's considerable added value from functions such as transaction control and security management - as the container is calling your code it is well-placed to implement this unintrusively.
  5. The main container functionality is very much IOC, the container calls your code at appropriate times, however the container will also provide useful APIs that your code can call (eg. to get Servlet or EJB Contexts.
like image 114
djna Avatar answered Sep 28 '22 05:09

djna


Referring more generally to the Container pattern (of which an enterprise Java container could be considered a specialization), the book Server Component Patterns by M.Volter, et al. offers the following:

[A CONTAINER provides] an execution environment that is responsible for adding the technical concerns to the COMPONENTS...Conceptually, it wraps the COMPONENTS, thus giving clients the illusion of of tightly-integrated functional and technical concerns.

Examples of such technical concerns include security, transaction management, logging, etc.

like image 44
Brandon E Taylor Avatar answered Sep 28 '22 03:09

Brandon E Taylor