开发者

Definition of a Java Container

开发者 https://www.devze.com 2023-03-29 17:11 出处:网络
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.

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 enterpri开发者_C百科se java container?


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.


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.


Java EE Containers

Normally, thin-client multitiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex low-level details. The component-based and platform-independent Java EE architecture makes Java EE applications easy to write because business logic is organized into reusable components. In addition, the Java EE server provides underlying services in the form of a container for every component type. Because you do not have to develop these services yourself, you are free to concentrate on solving the business problem at hand.

http://download.oracle.com/javaee/5/tutorial/doc/bnabo.html


The key notion behind a container is inversion of control, where application components inside the container can be loosely coupled with other application components as well as lower-level resources they depend upon. For Java these resources are usually things like database connections, network connections, JNDI, etc.

Different tiers of containers support different specifications for instance a web/servlet container like tomcat does not support some application level specifications like EJB3, therefore tomcat cannot wire together ejb's for injection into your application.


"Containers are the interface between a component and the low-level platform-specific functionality that supports the component. Before a web component, enterprise bean, or application client component can be executed, it must be assembled into a Java EE module and deployed into its container." here is my source : http://docs.oracle.com/javaee/1.4/tutorial/doc/Overview3.html


A container is execution environment that brings dynamism. It creates HTTP response, converts HTTP request to an object and creates and manages servlet life cycle.

Java EE is the collection of the specification that are used to solve enterprise problems like security, scalability, robustness, availability etc.

A container that manages every specification of Java EE is known as Java enterprise container. Eg. glassfish, JBoss etc. (BTW Tomcat is not EE container it is web container)


It is responsible for maintaining the individual components on the server side, which include Java servlets, Java server pages and Java server faces.


Container- in the context of Java development, refers to a part of the server that is responsible for managing the lifecycle of Web applications. The Web applications specify the required lifecycle management with the help of a contract presented in XML format. The Web container cannot be accessed directly by a client. Rather, the server manages the Web container, which in turn manages the Web application code.

Ref- https://www.techopedia.com/definition/4252/container-java

0

精彩评论

暂无评论...
验证码 换一张
取 消