Overview

MilliContainer is an ready-to-use component manager for use within your application. MilliContainer builds on PicoContainer to provide configuration and component deployment. Configuration is provided via Commons Configuration.
See PicoContainer for more information on Dependency Injection, components and PicoContainer itself.
See Commons Configuration for more information on configuration.

Dependencies

If you have the following dependencies in your project already, you are set to go. Otherwise, you must add them to your classpath (they are all included in the MilliContainer package).

News

27 October 2006 - Started the Sourceforge project.

Running the Example

  1. Download MilliContainer and extract it (the archive contains the millicontainer subdirectory).
  2. From the millicontainer directory, run "java millicontainer.example.ExampleApplication -p example_config.xml".
  3. If it works, you should see the following output:
    Oct 26, 2006 3:21:21 PM millicontainer.example.ExampleApplication loadComponentManager
    INFO: loading config from >>example_config.xml<<
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    INFO: loading components...
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    FINE: there are 1 component(s)
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    FINE: component[Configurable Component]=millicontainer.example.ConfigurableComponent
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    FINEST: getting component config: org.apache.commons.configuration.SubnodeConfiguration@b2a2d8
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    FINEST: caf=org.picocontainer.defaults.CachingComponentAdapterFactory@5329c5
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    FINEST: ca=[CachingCA delegate=org.picocontainer.defaults.ConstructorInjectionComponentAdapter[Configurable Component]]
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    FINEST: monitor=org.picocontainer.defaults.DelegatingComponentMonitor@1dfc547
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager loadComponents
    INFO: done loading components
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager start
    INFO: starting...
    Oct 26, 2006 3:21:21 PM millicontainer.example.ConfigurableComponent 
    INFO: init
    Oct 26, 2006 3:21:21 PM millicontainer.ComponentManager getComponent
    FINEST: getting configurable component...
    Oct 26, 2006 3:21:21 PM millicontainer.example.ConfigurableComponent setConfiguration
    FINEST: config=org.apache.commons.configuration.SubnodeConfiguration@b2a2d8
    Oct 26, 2006 3:21:21 PM millicontainer.example.ExampleApplication loadComponentManager
    FINEST: tc=millicontainer.example.ConfigurableComponent@17a8a02
    Oct 26, 2006 3:21:21 PM millicontainer.example.ConfigurableComponent showMessages
    FINE: there are 2 messages
    Oct 26, 2006 3:21:21 PM millicontainer.example.ConfigurableComponent showMessages
    FINE: message[0]=Hello
    Oct 26, 2006 3:21:21 PM millicontainer.example.ConfigurableComponent showMessages
    FINE: message[1]=World

User's Guide

Quick Start

Installation

Download MilliContainer and put millicontainer.jar on your classpath.

Configuration

Create an XML configuration file. The schema is included with MilliContainer. Each component is described within a component element.

Bootstrapping the Component Manager

The first step is load the component configuration file. This can be done with the following snippet:

Configuration config = new XMLConfiguration(path.trim());

Next, set the configuration:

ComponentManager.setConfig(config);

Lastly, start it:

ComponentManager.start();

Components can now be obtained from the component manager:

TestComponent tc = (TestComponent) ComponentManager.getComponent("Test Component");
tc.doSomething("hello world");
See ExampleApplication for code examples.

Components

Almost any class can be used as a component. However, certain qualities make some better components than others.

Constructor Injection

Components should declare all their dependencies via a constructor. This way, the container can inject the proper implementations. See the PicoContainer site and wiki for more information on components.

SourceForge.net Logo