- Tech know how online

lightweight container (LWC)

Generally speaking, containers as a special form of frameworks realize runtime environments in which objects are managed. In addition, basic services are made available to these objects. A central feature of lightweight containers is the application of the Dependency Injection

methodology - a special form of the Inversion of Control principle. Inversionof Control (IoC) is one of the most important concepts of frameworks for the development of maintainable and testable code

thatis also low-coupled


Lightweight containers assist in configuring applications. Instead of going through different configuration files, all configurations can be done dynamically at runtime centrally in one place. A well-known example of a lightweight container is the Spring framework, where the domain-oriented classes are implemented as so-called POJOs - an acronym

for simple Java classes. Other examples of lightweight containers are theopen source frameworks Avalon, Keel, Pico, or HiveMind, all of which offer functionalities that can be used as an alternative to Enterprise JavaBeans

(EJBs). Theterm container in the context of lightweight containers often refers to a meta-framework


This provides generic mechanisms for locating and loading an object based on a symbolic name

, as well as managing the lifecycles of objects. By including additional frameworks - which is why a lightweight container is also referred to as a meta-framework - additional services such as persistence services can be provided. Lightweight containers can thus offer similar functionality to application servers - the objective, however, is to remove the binding to application servers themselves

Characteristics of Lightweight Containers

Lightweight containers (LWC) can be characterized in terms of their properties as follows


  • An LWC should manage the code of an application or its objects, but not create any additional dependencies. For example, it should be possible to execute legacy code without further adaptations.
  • An LWC can be started very quickly.
  • No complex deployment process needs to be started in order to place objects in the LWC.
  • An LWC should fundamentally require minimal resources and have minimal dependency on interfaces. This then allows the code to run in a variety of environments such as J2SE, J2ME or J2EE
  • An LWC should fundamentally minimize the effort required to deploy managed objects so that it can be used for objects regardless of their granularity. Granularity is used to define the degree of aggregation.
This inevitably leads to the reasons why, for example, EJB containers are not classified as lightweight containers


  • Code written for the EJB model basically does not run outside the EJB container. Thus, the code is always dependent on the container.
  • EJB containers are relatively slow to start up.
Different types of IoC

Different types of IoC

A central aspect

in the decision for a lightweight container is the requirement for the greatest possible independence of the application code from the container. Here it is worth remembering the great dependency of the code before the introduction of EJB 3.0. However, since objects cannot work in isolation from each other, appropriate mechanisms for interobject communication are required. Without creating additional dependencies on the container, the principle of Inversion of Control (IoC) is often used for interobject association, and Dependency Injection is used there as its special manifestation.For an explanation of the principle in detail, please refer to the corresponding main article; in this context

, thefigure illustrates

thedifferent types of Inversion of Control.

The following advantages speak in favor of using a lightweight container


  • It is not a monolithic container.
  • The reusability of the code is given.
  • Better object orientation.
  • Greater productivity due to which code can be written more easily in any development environment.
  • Better testability of components.
Thefollowing lightweight container implementations are known and available as open source:

Avalon Framework

Was one of the first containers based on the inversion of control principle in 1999. Is also called an invasive framework because the code has to be adapted to accommodate the Avalon-specific interfaces. The Avalon framework was further developed under the name ExcaliburSpring Framework. Is a comprehensive implementation of a lightweight container. Among other things, it also offers the inclusion of a framework for aspect-oriented programming

. Furthermore, the integration of various persistence technologies, a transparent transaction management and much more is offeredKeel Framework

. Is a meta-framework and integrates the functionality of several frameworks. Similar goals are pursued as by Spring, without Keel being able to establish itself on the market as wellPico Container

. Realizes a container, which however does not offer any further features like Spring. Likewise, no frameworks from external sources can be integratedHiveMind is also an IoC container.

Here, too, the integration of aspect-oriented programming is possible. It also does not have the powerful range of functions as the Spring Framework.

Informationen zum Artikel
Englisch: lightweight container - LWC
Updated at: 28.10.2013
#Words: 236
Translations: DE