<?xml version="1.0" encoding="UTF-8"?>
<chapter id="introduction">
  <title>Introduction to the JBoss Microcontainer</title>

  <para>The JBoss Microcontainer provides an environment to configure and manage POJOs (plain old java objects). It is designed to reproduce the existing JBoss JMX Microkernel but targetted at POJO environments. As such it can be used standalone outside the JBoss Application Server.</para>
  
  <para>At its core, the JBoss Microcontainer is a generic "dependency injection" framework. It's primary function is to instantiate objects, figure out their dependencies (e.g., object A must be instantiated before object B), and then manage the relationship between those objects (e.g., object A is a property of object B). With the JBoss Microcontainer, you can build applications or shared services using simple POJOs. The JBoss Microcontainer is responsible for assembling the POJOs together according to an externally defined XML configuration file. It decouples the components in an application and makes the application easy to unit-test.</para>
  
  <para>The JBoss Microcontainer is a big object factory that manages objects. In this sense, it is similar to existing dependency injection frameworks such as the Spring framework and HiveMind framework. However, JBoss Microcontainer also has several important new features that set it apart from existing frameworks.</para>
  
  <itemizedlist mark="bullet">
    <listitem><para>JBoss Microcontainer supports life cycles for POJO components. It gives you fine-grained control over exactly how the objects are created, instantiated, and destroyed.</para></listitem>
    <listitem><para>JBoss Microcontainer manages dependencies between objects. For instance, you can declare that object A must be instantiated before object B can be created.</para></listitem>
    <listitem><para>JBoss Microcontainer integrates with the JBoss AOP (Aspect Oriented Programming) framework. In the JBoss Microcontainer configuration file, you can easily wire aspects as services to POJOs.</para></listitem>
    <listitem><para>JBoss Microcontainer is embedded in JBoss AS 4.0.3 and above. It is the ideal choice if you need to develop shared services in JBoss AS.</para></listitem>
  </itemizedlist>
  
  <para>Of course, you can also run JBoss Microcontainer outside of the JBoss AS. For instance, you can run it in a Java SE (e.g., Swing) application or in the Tomcat servlet container. So, JBoss Microcontainer primarily targets three types of developers.</para>
  
  <itemizedlist mark="bullet">
    <listitem><para>Framework developers can use JBoss Microcontainer to assemble custom server frameworks. For instance, the JBoss embeddable EJB3 framework is based on the Microcontainer.</para></listitem>
    <listitem><para>JBoss application developers can develop POJO services that nicely integrate into the server and can be shared across applications.</para></listitem>
    <listitem><para>Application developers can write lightweight applications that makes use of services from a variety of sources (e.g., transaction service from JBoss, persistence service from Hibernate, and HTTP service from Tomcat).</para></listitem>
  </itemizedlist>
  
  <para>A typical JBoss Microcontainer application or service include a set of POJOs that complete business tasks, as well as an XML configuration file called <varname>META-INF/jboss-beans.xml</varname> on the class path. The <varname>jboss-beans.cml</varname> file tells the JBoss Microcontianer how to assemble those POJOs together. For deployment, you can JAR the POJO classes, as well as the <varname>META-INF/jboss-beans.xml</varname> file together in a <varname>.beans</varname> archive file (see <xref linkend="packaging"/>).</para>

  <para>This document takes you through some example deployments into
  JBoss-4.0.3+ explaining how to configure POJOs and link them together
  through injection. Later it shows how to do the same thing outside the
  application server.</para>
  
</chapter>