What is a "lightweight" container?

Source: Internet
Author: User
Source: http://spring.jactiongroup.net/viewtopic.php? T = 825

View lightweight containers

Lightweight containers are increasingly becoming one of the key words in the Java World. So what is a "lightweight" container?
When you browse recent articles or blogs about J2EE, you have intentionally or unintentionally mentioned "lightweigh Inter ",
The most common words are "IoC", "dependencies inject", and "AOP.

What is "Container "?

There is nothing special about it, and it is common in our world. A container is a group of managers that provide a series of services, as long as you meet the service requirements (specifications) of the container)
Containers allow you to use management services within the scope. As early as the Web is popular, http container provides us with the ability to parse Html,
Let's publish our html code to the internet through the http protocol. With the promotion of web applications and the development of dynamic languages, http containers are gradually
You can use the specified interface to explain the special parts in special files, such as php and asp. Let's uncover the container lid and see what is in it (service ).

1. lifecycle management

-To manage running components (or program fragments), at least some method can be used to create them and destroy them if they are useless.

2. query and locate

-Determine the component or resource to be called through a certain policy (usually using the file name), which is the main task of the manager.

3. Configurator

-Provides static configuration policies. Allows you to control the details of a service. For example, where is the resource?

4. dependency parsing

-If there is a relationship between components, or you need to communicate with each other. At least make sure they are "active. This requires analyzing the dependency between them and dynamically managing them.

5. Communication support at different protocol layers

-Program fragments can not be used to complete all calculations by themselves. They also need to communicate with different systems (platforms), such as JDBC and data storage databases, and RMI distribution components.

6. extended support

-Extended service items are not only required by containers, but also required by any software. For example, add a security policy.

What is "lightweight "?

Since it is "light", it is more "heavy. A typical example of "heavy" is EJB, which provides a series of "Heavyweight" enterprise-level services and allows you to develop good components.
Integrates enterprise-level services provided by EJB containers, such as JTA. Now that we have a service container "yes, why do we still need" lightweight? This is a good question.
Although the comprehensive EJB container provides us with a seemingly complete service policy, EJB is not Lei Feng, and it also brings us many negative effects. People with EJB experience
Deep feelings:
1. Complicated deployment and slow operation
2. Many internal services and slow startup
3. Many rules and small space
4. Difficult pre-test (debugging)
...

The EJB container service is often "buy one get three. I only need JTA, but I really don't need JMS.
Therefore, in this world of "all useless to me is rubbish", we need "selectable" service containers so that those services that are useless to us do not stand in the way.
Selectivity is one of the goals of lightweight containers.

Where is "lightweight?

Since the container service can be DIY, it does look "light" a lot. However, it is not that simple.
Before starting, let's review several keywords.

1. Encapsulation

Java itself takes care of the acceptance of non-java programmers and works with the "running anywhere" advertised in the market.
Add the non-object-oriented feature syntax. "Is encapsulation damaged? ", Known as the most controversial issue in Java over the past decade.

2. Component-based development

The term is highly technical in the circle of software. However, in the field of hardware, which hardware is not component? Your computer is a variety of components,
They work by integrating interfaces (slots. Even the digital TV set-top box is a standard component.

3. Running Anywhere

This word entered our world with a cup of black coffee. Although it has now become "Debug Anywhere", it has always been our goal.

Lightweight containers are solutions targeted at these issues.

In the face of encapsulation, component granularity has always been the biggest issue of SA. According to the EJB model, the EJB component allows us to encapsulate business components into coarse-grained business components.
Lightweight containers can define more fine-grained components, and even this component has only one object. Decoupling mode represented by Dependency Injection (DI,
This prevents components from relying on the APIs of the container (runtime environment. DI acts as the container pipeline and acts as the intermediary, so that the user (component) and the provider are unrelated.
This is determined by the specific requirements of the business for designing business components at what granularity, and any framework will not help you.
The technical support provided by lightweight containers is definitely targeted for you.

In the face of components, the real components are like the U-disk in your hand. You can enjoy the functions by inserting them on the USB.
Lightweight containers use reverse Control (IoC) to take the initiative to manage the inserted components. As long as the component is compliant with the standard, it can be
Lightweight container management.

In the face of Running anywhere, a lightweight volume allows a group to exist in the form of pojo. you only need java.exe to run it.
In this way, the component is an independent function integration class, and the test behavior can be achieved without a container.

The above three points bring us not only the benefits, but we will also benefit from reuse, productivity, testing (quality), portability and other aspects. Here we will not be too long-winded.

Status Quo of lightweight containers

Currently, lightweight containers have been widely recognized in the open source Field, and as the basis of the next-generation J2EE architecture, they have incomparable advantages.
Currently, most of the existing lightweight container frameworks come from the open source community, which lowers the threshold for us to understand this technology.

PicoContainer
Http://www.picocontainer.org/

Aveon Apache Software License
HomePage http://avalon.apache.org/

NanoContainer
Http://www.nanocontainer.org/

Peapod
Http://www.peapod.org/

Carbon
Http://carbon.sourceforge.net/

Excalibur
Http://excalibur.apache.org/index.html

Gravity
Http://gravity.dev.java.net

The above Pico has become the leader of type3 (IoC) and spring IoC containers. The IoC container has a profound impact on the traditional container (as EJB.
In the face of the innovative ideas brought by technology, we must always prepare to keep our learning curve at a fixed point so that we can be unbeaten.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.