Chapter 4. Examples
Prev |  | Next

## Chapter 4. Examples

The examples folder shows some of the simpler uses of the MicroContainer. Each example is in a subfolder with the following structure:

    readme.txt - a short description of the example including the expected output
    build.xml - the ant build script
    src/resources/META-INF/jboss-beans.xml - the MicroContainer configuration for the example
    src/main - the java source for the example

To run each example, simply:

    > cd examples/<directory>
    > ant

To run against the JBoss application server:

    > <edit> build.properties {change to point at your jboss instance}
    > cd examples/<directory>
    > ant deploy
    followed by
    > ant undeploy
    to remove the deployment

- simple: a simple example to make sure you have everything working

- constructor: simple constructor configuration

- factory: construction using factories

- properties: property configuration

- injection: referencing other beans

- collections: creating collections

- lifecycle: the create/start/stop/destroy lifecycle

- locator: implementing the locator pattern with the Microcontainer

The JBoss Microcontainer uses any logging mechanism supported by org.jboss.logging. e.g. if you want to use log4j, add log4j.jar and a directory containing either a log4j.properties or log4j.xml to the classpath. The default distribution uses the "null" logging implementation, which is why the examples all use System.out.println().

This just skims the surface of the MicroContainer, showing the most common usecases. Other more complicated examples can be found in the tests (available from cvs).

Prev | Up | Next
Chapter 3. Packaging | Home | Chapter 5. Basic Configuration