<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
      "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<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 targeted at POJO environments. As such it can be
      used standalone outside the JBoss Application Server.
   </para>

   <para>As we mention JBoss Application Server, while rewriting its Microkernel to a POJO environment, there were other
      aspects that also needed to be considered while changing the core functionality. New modules or subprojects were
      introduced to the Microcontainer project to tightly integrate those aspects with the new POJO approach and to
      eventually solve some of the basic problems that arose over the years with the changes application server went
      through.
      We will discuss these modules and subproject later on.
   </para>

   <para>At its core, the JBoss Microcontainer is a generic "dependency injection" framework. Its 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 sets 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 used as a replacement for the JMX-based Microkernel in JBoss AS 5.x and above.
            All
            the existing features of MBeans are thightly integrated into new Microcontainer based ServiceController.
         </para>
      </listitem>
      <listitem>
         <para>JBoss Microcontainer is embedded in JBoss AS 4.x. 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.xml</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 simple .jar archive file (see
      <xref linkend="packaging"/>
      ).
   </para>

   <para>This document takes you through some example deployments into
      JBoss Microcontainer 2.0 explaining how to configure POJOs and link them together
      through injection.
      We will also explain how to use other Microcontainer modules inside JBoss AS 5.x, especially the re-written
      deployers and classloader modules.  Later, we will discuss how to do the same thing outside the application server.
   </para>

</chapter>
