Skip to end of metadata
Go to start of metadata

NanoContainer Overview

NanoContainer is a script-enabled layer which builds PicoContainers. Trees of containers and components can be composed using several scripting languages:

Why multiple script language support?

Multiple script languages are supported because we officially stand against a single meta-data language. Of the script languages, XML is the most widely used and mature, but Groovy is most promising because of the its optional builder syntax.

Uses of NanoContainer

NanoContainer is primarily intended to be embedded inside other applications and frameworks. We recommend using NanoContainer when your application consists of many different components that are related to each other but you need composition driven by external scripts.

Embedded Example

Interpreted script languages

NanoContainer currently supports 4 different interpreted languages for container composition. The contract for Groovy, Beanshell, Javascript and Jython scripts is defined as follows:

  • The scripts have to define a "pico" variable of type MutablePicoContainer.
  • The script has access to a variable named "parent", which is a MutablePicoContainer instance or null. It should be used when constructing the "pico" MutablePicoContainer.
  • The script has access to a variable named "assemblyScope" that may be used in order to decide how to compose the container. The value of this variable can be any kind of object.

Groovy

or

Beanshell

Javascript

(org.picocontainer.* and org.picocontainer.defaults.* imported by default)

Jython

(org.picocontainer.* and org.picocontainer.defaults.* imported by default)

XML

The above interpreted language scripts can equally be expressed in XML

The DTD details the full XML syntax.

Further reading

NanoWar

Labels:
  1. Jun 04, 2004

    NanoContainer's constructor takes the Class name as a second argument, so
    the abot should read:

  2. Apr 12, 2008

    I missed XML example ....