[jbosscache-commits] JBoss Cache SVN: r7474 - in core/branches/flat/src: main/java/org/jboss/cache and 25 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jan 14 12:00:41 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-01-14 12:00:40 -0500 (Wed, 14 Jan 2009)
New Revision: 7474

Added:
   core/branches/flat/src/main/java/org/jboss/starobrno/config/SharedConfiguration.java
   core/branches/flat/src/main/java/org/jboss/starobrno/executors/
   core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultExecutorFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultScheduledExecutorFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/executors/ExecutorFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/executors/ScheduledExecutorFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/DefaultCacheFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/HierarchicalComponentRegistry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scope.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/ScopeDetector.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scopes.java
   core/branches/flat/src/test/java/org/jboss/starobrno/factories/
   core/branches/flat/src/test/java/org/jboss/starobrno/factories/scopes/
   core/branches/flat/src/test/java/org/jboss/starobrno/factories/scopes/ScopeDetectorTest.java
   core/branches/flat/src/test/java/org/jboss/starobrno/manager/
   core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerComponentRegistryTest.java
   core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerTest.java
   core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerXmlConfigurationTest.java
   core/branches/flat/src/test/resources/configs/named-cache-test.xml
Removed:
   core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
Modified:
   core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml
   core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java
   core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java
   core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
   core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
   core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java
   core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java
   core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
   core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java
   core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/ReflectionUtil.java
   core/branches/flat/src/main/resources/schema/starobrno-config-1.0.xsd
   core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java
   core/branches/flat/src/test/java/org/jboss/starobrno/atomic/APITest.java
   core/branches/flat/src/test/java/org/jboss/starobrno/profiling/MemConsumptionTest.java
Log:
Scopes + executor factories

Modified: core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml
===================================================================
--- core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml	2009-01-14 17:00:40 UTC (rev 7474)
@@ -1,112 +1,112 @@
 <chapter id="deployment">
-   <title>Deploying JBoss Cache</title>
-   <section id="deployment.standalone">
-      <title>Standalone Use / Programatic Deployment</title>
-      <para>
-         When used in a standalone Java program, all that needs to be done is to instantiate the cache using the
-         <literal>CacheFactory</literal>
-         and a
-         <literal>Configuration</literal>
-         instance or an XML file, as discussed
-         in the
-         <link linkend="api.create_start">User API</link>
-         and
-         <link linkend="configuration.creation">Configuration</link>
-         chapters.
-      </para>
+    <title>Deploying JBoss Cache</title>
+    <section id="deployment.standalone">
+        <title>Standalone Use / Programatic Deployment</title>
+        <para>
+            When used in a standalone Java program, all that needs to be done is to instantiate the cache using the
+            <literal>CacheFactory</literal>
+            and a
+            <literal>Configuration</literal>
+            instance or an XML file, as discussed
+            in the
+            <link linkend="api.create_start">User API</link>
+            and
+            <link linkend="configuration.creation">Configuration</link>
+            chapters.
+        </para>
 
-      <para>
-         The same techniques can be used when an application running in an application
-         server wishes to programatically deploy a cache rather than relying on an application server's
-         deployment features. An example of this would be
-         a webapp deploying a cache via a
-         <literal>javax.servlet.ServletContextListener</literal>
-         .
-      </para>
+        <para>
+            The same techniques can be used when an application running in an application
+            server wishes to programatically deploy a cache rather than relying on an application server's
+            deployment features. An example of this would be
+            a webapp deploying a cache via a
+            <literal>javax.servlet.ServletContextListener</literal>
+            .
+        </para>
 
-      <para>
-         If, after deploying your cache you wish to expose a management interface
-         to it in JMX, see the
-         <link linkend="jmx.registration.programatic">section on Programatic Registration in JMX</link>
-         .
-      </para>
-   </section>
+        <para>
+            If, after deploying your cache you wish to expose a management interface
+            to it in JMX, see the
+            <link linkend="jmx.registration.programatic">section on Programatic Registration in JMX</link>
+            .
+        </para>
+    </section>
 
-   <section id="deployment.microkernel">
-      <title>JMX-Based Deployment in JBoss AS (JBoss AS 5.x and 4.x)</title>
-      <para>If JBoss Cache is run in JBoss AS then the cache can be deployed as an
-         MBean simply by copying a standard cache configuration file to the server's
-         <literal>deploy</literal>
-         directory. The standard format of JBoss Cache's
-         standard XML configuration file (as shown in the
-         <link linkend="sample_xml_file">Configuration Reference</link>
-         ) is the same
-         as a JBoss AS MBean deployment descriptor, so the AS's SAR Deployer has
-         no trouble handling it. Also, you don't have to place the configuration
-         file directly in
-         <literal>deploy</literal>
-         ; you can package it along
-         with other services or JEE components in a SAR or EAR.
-      </para>
+    <section id="deployment.microkernel">
+        <title>JMX-Based Deployment in JBoss AS (JBoss AS 5.x and 4.x)</title>
+        <para>If JBoss Cache is run in JBoss AS then the cache can be deployed as an
+            MBean simply by copying a standard cache configuration file to the server's
+            <literal>deploy</literal>
+            directory. The standard format of JBoss Cache's
+            standard XML configuration file (as shown in the
+            <link linkend="sample_xml_file">Configuration Reference</link>
+            ) is the same
+            as a JBoss AS MBean deployment descriptor, so the AS's SAR Deployer has
+            no trouble handling it. Also, you don't have to place the configuration
+            file directly in
+            <literal>deploy</literal>
+            ; you can package it along
+            with other services or JEE components in a SAR or EAR.
+        </para>
 
-      <para>
-         In AS 5, if you're using a server config based on the standard
-         <literal>all</literal>
-         config, then that's all you need to do; all required
-         jars will be on the classpath. Otherwise, you will need to ensure
-         <literal>jbosscache.jar</literal>
-         and
-         <literal>jgroups-all.jar</literal>
-         are on the classpath. You may need to add other jars if you're using
-         things like
-         <literal>JdbmCacheLoader</literal>
-         . The simplest way to do
-         this is to copy the jars from the JBoss Cache distribution's
-         <literal>lib</literal>
-         directory to the server config's
-         <literal>lib</literal>
-         directory. You could also package the jars with the configuration file
-         in Service Archive (.sar) file or an EAR.
-      </para>
+        <para>
+            In AS 5, if you're using a server config based on the standard
+            <literal>all</literal>
+            config, then that's all you need to do; all required
+            jars will be on the classpath. Otherwise, you will need to ensure
+            <literal>jbosscache.jar</literal>
+            and
+            <literal>jgroups-all.jar</literal>
+            are on the classpath. You may need to add other jars if you're using
+            things like
+            <literal>JdbmCacheLoader</literal>
+            . The simplest way to do
+            this is to copy the jars from the JBoss Cache distribution's
+            <literal>lib</literal>
+            directory to the server config's
+            <literal>lib</literal>
+            directory. You could also package the jars with the configuration file
+            in Service Archive (.sar) file or an EAR.
+        </para>
 
-      <para>
-         It is possible to deploy a JBoss Cache 2.0 instance in JBoss AS 4.x
-         (at least in 4.2.0.GA; other AS releases are completely untested).
-         However, the significant API changes between the JBoss Cache 2.x and 1.x releases
-         mean none of the standard AS 4.x clustering services (e.g.
-         http session replication) that rely on JBoss Cache will work with
-         JBoss Cache 2.x. Also, be aware that usage of JBoss Cache 2.x in AS 4.x is not
-         something the JBoss Cache developers are making any significant effort to test,
-         so be sure to test your application well (which of course you're doing anyway.)
-      </para>
+        <para>
+            It is possible to deploy a JBoss Cache 2.0 instance in JBoss AS 4.x
+            (at least in 4.2.0.GA; other AS releases are completely untested).
+            However, the significant API changes between the JBoss Cache 2.x and 1.x releases
+            mean none of the standard AS 4.x clustering services (e.g.
+            http session replication) that rely on JBoss Cache will work with
+            JBoss Cache 2.x. Also, be aware that usage of JBoss Cache 2.x in AS 4.x is not
+            something the JBoss Cache developers are making any significant effort to test,
+            so be sure to test your application well (which of course you're doing anyway.)
+        </para>
 
-      <para>
-         Note in the
-         <link linkend="sample_xml_file">example</link>
-         the value of the
-         <literal>mbean</literal>
-         element's
-         <literal>code</literal>
-         attribute:
-         <literal>org.jboss.cache.jmx.CacheJmxWrapper</literal>
-         . This is the
-         class JBoss Cache uses to handle JMX integration; the
-         <literal>Cache</literal>
-         itself does not expose an MBean
-         interface. See the
-         <link linkend="jmx.mbeans">JBoss Cache MBeans section</link>
-         for more on the
-         <literal>CacheJmxWrapper</literal>
-         .
-      </para>
+        <para>
+            Note in the
+            <link linkend="sample_xml_file">example</link>
+            the value of the
+            <literal>mbean</literal>
+            element's
+            <literal>code</literal>
+            attribute:
+            <literal>org.jboss.cache.jmx.CacheJmxWrapper</literal>
+            . This is the
+            class JBoss Cache uses to handle JMX integration; the
+            <literal>Cache</literal>
+            itself does not expose an MBean
+            interface. See the
+            <link linkend="jmx.mbeans">JBoss Cache MBeans section</link>
+            for more on the
+            <literal>CacheJmxWrapper</literal>
+            .
+        </para>
 
-      <para>
-         Once your cache is deployed, in order to use it with an in-VM client
-         such as a servlet, a JMX proxy can be used to get a reference to
-         the cache:
-      </para>
+        <para>
+            Once your cache is deployed, in order to use it with an in-VM client
+            such as a servlet, a JMX proxy can be used to get a reference to
+            the cache:
+        </para>
 
-      <programlisting role="JAVA"><![CDATA[
+        <programlisting role="JAVA"><![CDATA[
    MBeanServer server = MBeanServerLocator.locateJBoss();
    ObjectName on = new ObjectName("jboss.cache:service=Cache");
    CacheJmxWrapperMBean cacheWrapper =
@@ -116,82 +116,82 @@
    Node root = cache.getRoot(); // etc etc
    ]]></programlisting>
 
-      <para>The MBeanServerLocator class is a helper to find the (only) JBoss
-         MBean server inside the current JVM. The
-         <literal>javax.management.MBeanServerInvocationHandler</literal>
-         class'
-         <literal>newProxyInstance</literal>
-         method creates a
-         dynamic proxy implementing the given interface and uses JMX to
-         dynamically dispatch methods invoked against the generated interface
-         to the MBean. The name used to look up the MBean is the same as defined
-         in the cache's configuration file.
-      </para>
+        <para>The MBeanServerLocator class is a helper to find the (only) JBoss
+            MBean server inside the current JVM. The
+            <literal>javax.management.MBeanServerInvocationHandler</literal>
+            class'
+            <literal>newProxyInstance</literal>
+            method creates a
+            dynamic proxy implementing the given interface and uses JMX to
+            dynamically dispatch methods invoked against the generated interface
+            to the MBean. The name used to look up the MBean is the same as defined
+            in the cache's configuration file.
+        </para>
 
-      <para>
-         Once the proxy to the
-         <literal>CacheJmxWrapper</literal>
-         is obtained,
-         the
-         <literal>getCache()</literal>
-         will return a reference to the
-         <literal>Cache</literal>
-         itself.
-      </para>
+        <para>
+            Once the proxy to the
+            <literal>CacheJmxWrapper</literal>
+            is obtained,
+            the
+            <literal>getCache()</literal>
+            will return a reference to the
+            <literal>Cache</literal>
+            itself.
+        </para>
 
-   </section>
+    </section>
 
-   <section id="deployment.microcontainer">
-      <title>Via JBoss Microcontainer (JBoss AS 5.x)</title>
+    <section id="deployment.microcontainer">
+        <title>Via JBoss Microcontainer (JBoss AS 5.x)</title>
 
-      <para>
-         Beginning with AS 5, JBoss AS also supports deployment of POJO services via
-         deployment of a file whose name ends with
-         <literal>-beans.xml</literal>
-         .
-         A POJO service is one whose implementation is via a "Plain Old Java Object",
-         meaning a simple java bean that isn't required to implement any special
-         interfaces or extend any particular superclass. A
-         <literal>Cache</literal>
-         is a POJO service, and all the components in a
-         <literal>Configuration</literal>
-         are also POJOS, so deploying a cache in this way is a natural step.
-      </para>
-      <para>
-         Deployment of the cache is done using the JBoss Microcontainer that forms the
-         core of JBoss AS. JBoss Microcontainer is a sophisticated IOC framework
-         (similar to Spring). A
-         <literal>-beans.xml</literal>
-         file is basically
-         a descriptor that tells the IOC framework how to assemble the various
-         beans that make up a POJO service.
-      </para>
-      <para>
-         For each configurable option exposed by the
-         <literal>Configuration</literal>
-         components, a getter/setter must be defined in the configuration class.
-         This is required so that JBoss Microcontainer can, in typical IOC way,
-         call these methods when the corresponding properties have been
-         configured.
-      </para>
-      <para>
-         The rules for how to deploy the file, how to package it, how to
-         ensure the required jars are on the classpath, etc. are the same
-         as for a
-         <link linkend="deployment.microkernel">JMX-based deployment</link>
-         .
-      </para>
-      <para>
-         Following is an example
-         <literal>-beans.xml</literal>
-         file. If you
-         look in the
-         <literal>server/all/deploy</literal>
-         directory of an AS 5
-         installation, you can find several more examples.
-      </para>
+        <para>
+            Beginning with AS 5, JBoss AS also supports deployment of POJO services via
+            deployment of a file whose name ends with
+            <literal>-beans.xml</literal>
+            .
+            A POJO service is one whose implementation is via a "Plain Old Java Object",
+            meaning a simple java bean that isn't required to implement any special
+            interfaces or extend any particular superclass. A
+            <literal>Cache</literal>
+            is a POJO service, and all the components in a
+            <literal>Configuration</literal>
+            are also POJOS, so deploying a cache in this way is a natural step.
+        </para>
+        <para>
+            Deployment of the cache is done using the JBoss Microcontainer that forms the
+            core of JBoss AS. JBoss Microcontainer is a sophisticated IOC framework
+            (similar to Spring). A
+            <literal>-beans.xml</literal>
+            file is basically
+            a descriptor that tells the IOC framework how to assemble the various
+            beans that make up a POJO service.
+        </para>
+        <para>
+            For each configurable option exposed by the
+            <literal>Configuration</literal>
+            components, a getter/setter must be defined in the configuration class.
+            This is required so that JBoss Microcontainer can, in typical IOC way,
+            call these methods when the corresponding properties have been
+            configured.
+        </para>
+        <para>
+            The rules for how to deploy the file, how to package it, how to
+            ensure the required jars are on the classpath, etc. are the same
+            as for a
+            <link linkend="deployment.microkernel">JMX-based deployment</link>
+            .
+        </para>
+        <para>
+            Following is an example
+            <literal>-beans.xml</literal>
+            file. If you
+            look in the
+            <literal>server/all/deploy</literal>
+            directory of an AS 5
+            installation, you can find several more examples.
+        </para>
 
-      <programlisting role="XML"><![CDATA[
+        <programlisting role="XML"><![CDATA[<![CDATA[<![CDATA[
 <?xml version="1.0" encoding="UTF-8"?>
 
       <deployment xmlns="urn:jboss:bean-deployer:2.0">
@@ -280,8 +280,8 @@
          </bean>
 
          <!-- Factory to build the Cache. -->
-         <bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">
-            <constructor factoryClass="org.jboss.cache.DefaultCacheFactory"
+         <bean name="DefaultCacheFactory" class="org.jboss.starobrno.factories.DefaultCacheFactory">
+            <conorg.jboss.starobrno.factories.DefaultCacheFactoryche.DefaultCacheFactory"
                          factoryMethod="getInstance"/>
          </bean>
 
@@ -297,158 +297,160 @@
          </bean>
 
       </deployment>
-      ]]></programlisting>
+      ]]>]]>]]>
+        </programlisting>
 
-      <para>
-         See the JBoss Microcontainer documentation
-         <footnote>
-            <para>http://labs.jboss.com/jbossmc/docs</para>
-         </footnote>
-         for details on the above syntax. Basically, each
-         <literal>bean</literal>
-         element represents an object; most going to create a
-         <literal>Configuration</literal>
-         and its
-         <link linkend="configuration.elements">constituent parts</link>
-         .
-      </para>
-      <para>
-         An interesting thing to note in the above example is the use of the
-         <literal>RuntimeConfig</literal>
-         object. External resources like
-         a
-         <literal>TransactionManager</literal>
-         and a JGroups
-         <literal>ChannelFactory</literal>
-         that are visible to the
-         microcontainer are dependency injected into the
-         <literal>RuntimeConfig</literal>
-         .
-         The assumption here is that in some other deployment descriptor in the AS,
-         the referenced beans have been described.
-      </para>
-   </section>
-
-   <section>
-      <title>Binding to JNDI in JBoss AS</title>
-      <para>
-         With the 1.x JBoss Cache releases, a proxy to the cache could be bound
-         into JBoss AS's JNDI tree using the AS's
-         <literal>JRMPProxyFactory</literal>
-         service. With JBoss Cache 2.x, this no longer works. An alternative
-         way of doing a similar thing with a POJO (i.e. non-JMX-based) service
-         like a
-         <literal>Cache</literal>
-         is under development by the JBoss AS
-         team
-         <footnote>
-            <para>http://jira.jboss.com/jira/browse/JBAS-4456</para>
-         </footnote>
-         . That feature is not available as of the time of this writing,
-         although it will be completed before AS 5.0.0.GA is released.
-         We will add a wiki page describing how to use it once it becomes available.
-      </para>
-   </section>
-
-   <section>
-      <title>Runtime Management Information</title>
-      <para>JBoss Cache includes JMX MBeans to expose cache functionality and provide statistics that can be
-         used to analyze cache operations. JBoss Cache can also broadcast cache events as MBean notifications for
-         handling
-         via JMX monitoring tools.
-      </para>
-
-      <section id="jmx.mbeans">
-         <title>JBoss Cache MBeans</title>
-         <para>
-            JBoss Cache provides an MBean that can be registered with your environments JMX server to allow access
-            to the cache instance via JMX. This MBean is the
-            <literal>org.jboss.cache.jmx.CacheJmxWrapper</literal>
+        <para>
+            See the JBoss Microcontainer documentation
+            <footnote>
+                <para>http://labs.jboss.com/jbossmc/docs</para>
+            </footnote>
+            for details on the above syntax. Basically, each
+            <literal>bean</literal>
+            element represents an object; most going to create a
+            <literal>Configuration</literal>
+            and its
+            <link linkend="configuration.elements">constituent parts</link>
             .
-            It is a StandardMBean, so it's MBean interface is
-            <literal>org.jboss.cache.jmx.CacheJmxWrapperMBean</literal>
+        </para>
+        <para>
+            An interesting thing to note in the above example is the use of the
+            <literal>RuntimeConfig</literal>
+            object. External resources like
+            a
+            <literal>TransactionManager</literal>
+            and a JGroups
+            <literal>ChannelFactory</literal>
+            that are visible to the
+            microcontainer are dependency injected into the
+            <literal>RuntimeConfig</literal>
             .
-            This MBean can be used to:
-            <itemizedlist>
-               <listitem>Get a reference to the underlying
-                  <literal>Cache</literal>
-                  .
-               </listitem>
-               <listitem>Invoke create/start/stop/destroy lifecycle operations on
-                  the underlying
-                  <literal>Cache</literal>
-                  .
-               </listitem>
-               <listitem>Inspect various details about the cache's current state (number of nodes, lock information,
-                  etc.)
-               </listitem>
-               <listitem>See numerous details about the cache's configuration, and
-                  change those configuration items that can be changed when the
-                  cache has already been started.
-               </listitem>
-            </itemizedlist>
-            See the
-            <literal>CacheJmxWrapperMBean</literal>
-            javadoc for more details.
-         </para>
-         <para>
-            It is important to note a significant architectural difference between JBoss Cache 1.x and 2.x. In 1.x,
-            the old
-            <literal>TreeCache</literal>
-            class was itself an MBean, and essentially exposed the cache's entire
-            API via JMX. In 2.x, JMX has been returned to it's fundamental role as a management layer. The
+            The assumption here is that in some other deployment descriptor in the AS,
+            the referenced beans have been described.
+        </para>
+    </section>
+
+    <section>
+        <title>Binding to JNDI in JBoss AS</title>
+        <para>
+            With the 1.x JBoss Cache releases, a proxy to the cache could be bound
+            into JBoss AS's JNDI tree using the AS's
+            <literal>JRMPProxyFactory</literal>
+            service. With JBoss Cache 2.x, this no longer works. An alternative
+            way of doing a similar thing with a POJO (i.e. non-JMX-based) service
+            like a
             <literal>Cache</literal>
-            object itself is completely unaware of JMX; instead JMX functionality is added
-            through a wrapper class designed for that purpose. Furthermore, the interface exposed through JMX
-            has been limited to management functions; the general
-            <literal>Cache</literal>
-            API is no longer exposed
-            through JMX. For example, it is no longer possible to invoke a cache
-            <literal>put</literal>
-            or
-            <literal>get</literal>
-            via the JMX interface.
-         </para>
-         <para>
-            If a
-            <literal>CacheJmxWrapper</literal>
-            is registered, JBoss Cache also provides MBeans
-            for each interceptor configured in the cache's interceptor stack. These
-            MBeans are used to capture and expose statistics related to cache operations. They are hierarchically
-            associated with the
-            <literal>CacheJmxWrapper</literal>
-            MBean and have service names that reflect this relationship. For
-            example, a replication interceptor MBean for the
-            <literal>jboss.cache:service=TomcatClusteringCache</literal>
-            instance will be
-            accessible through the service named
-            <literal>jboss.cache:service=TomcatClusteringCache,cache-interceptor=ReplicationInterceptor</literal>
-            .
-         </para>
-      </section>
+            is under development by the JBoss AS
+            team
+            <footnote>
+                <para>http://jira.jboss.com/jira/browse/JBAS-4456</para>
+            </footnote>
+            . That feature is not available as of the time of this writing,
+            although it will be completed before AS 5.0.0.GA is released.
+            We will add a wiki page describing how to use it once it becomes available.
+        </para>
+    </section>
 
-      <section id="jmx.registration">
-         <title>Registering the CacheJmxWrapper with the MBeanServer</title>
+    <section>
+        <title>Runtime Management Information</title>
+        <para>JBoss Cache includes JMX MBeans to expose cache functionality and provide statistics that can be
+            used to analyze cache operations. JBoss Cache can also broadcast cache events as MBean notifications for
+            handling
+            via JMX monitoring tools.
+        </para>
 
-         <para>
-            The best way to ensure the
-            <literal>CacheJmxWrapper</literal>
-            is registered
-            in JMX depends on how you are deploying your cache:
-         </para>
+        <section id="jmx.mbeans">
+            <title>JBoss Cache MBeans</title>
+            <para>
+                JBoss Cache provides an MBean that can be registered with your environments JMX server to allow access
+                to the cache instance via JMX. This MBean is the
+                <literal>org.jboss.cache.jmx.CacheJmxWrapper</literal>
+                .
+                It is a StandardMBean, so it's MBean interface is
+                <literal>org.jboss.cache.jmx.CacheJmxWrapperMBean</literal>
+                .
+                This MBean can be used to:
+                <itemizedlist>
+                    <listitem>Get a reference to the underlying
+                        <literal>Cache</literal>
+                        .
+                    </listitem>
+                    <listitem>Invoke create/start/stop/destroy lifecycle operations on
+                        the underlying
+                        <literal>Cache</literal>
+                        .
+                    </listitem>
+                    <listitem>Inspect various details about the cache's current state (number of nodes, lock
+                        information,
+                        etc.)
+                    </listitem>
+                    <listitem>See numerous details about the cache's configuration, and
+                        change those configuration items that can be changed when the
+                        cache has already been started.
+                    </listitem>
+                </itemizedlist>
+                See the
+                <literal>CacheJmxWrapperMBean</literal>
+                javadoc for more details.
+            </para>
+            <para>
+                It is important to note a significant architectural difference between JBoss Cache 1.x and 2.x. In 1.x,
+                the old
+                <literal>TreeCache</literal>
+                class was itself an MBean, and essentially exposed the cache's entire
+                API via JMX. In 2.x, JMX has been returned to it's fundamental role as a management layer. The
+                <literal>Cache</literal>
+                object itself is completely unaware of JMX; instead JMX functionality is added
+                through a wrapper class designed for that purpose. Furthermore, the interface exposed through JMX
+                has been limited to management functions; the general
+                <literal>Cache</literal>
+                API is no longer exposed
+                through JMX. For example, it is no longer possible to invoke a cache
+                <literal>put</literal>
+                or
+                <literal>get</literal>
+                via the JMX interface.
+            </para>
+            <para>
+                If a
+                <literal>CacheJmxWrapper</literal>
+                is registered, JBoss Cache also provides MBeans
+                for each interceptor configured in the cache's interceptor stack. These
+                MBeans are used to capture and expose statistics related to cache operations. They are hierarchically
+                associated with the
+                <literal>CacheJmxWrapper</literal>
+                MBean and have service names that reflect this relationship. For
+                example, a replication interceptor MBean for the
+                <literal>jboss.cache:service=TomcatClusteringCache</literal>
+                instance will be
+                accessible through the service named
+                <literal>jboss.cache:service=TomcatClusteringCache,cache-interceptor=ReplicationInterceptor</literal>
+                .
+            </para>
+        </section>
 
-         <section id="jmx.registration.programatic">
-            <title>Programatic Registration</title>
+        <section id="jmx.registration">
+            <title>Registering the CacheJmxWrapper with the MBeanServer</title>
 
             <para>
-               Simplest way to do this is to create your
-               <literal>Cache</literal>
-               and pass it to the
-               <literal>CacheJmxWrapper</literal>
-               constructor.
+                The best way to ensure the
+                <literal>CacheJmxWrapper</literal>
+                is registered
+                in JMX depends on how you are deploying your cache:
             </para>
 
-            <programlisting role="JAVA"><![CDATA[
+            <section id="jmx.registration.programatic">
+                <title>Programatic Registration</title>
+
+                <para>
+                    Simplest way to do this is to create your
+                    <literal>Cache</literal>
+                    and pass it to the
+                    <literal>CacheJmxWrapper</literal>
+                    constructor.
+                </para>
+
+                <programlisting role="JAVA"><![CDATA[
    CacheFactory factory = new DefaultCacheFactory();
    // Build but don't start the cache
    // (although it would work OK if we started it)
@@ -474,19 +476,19 @@
    wrapper.destroy();
             ]]></programlisting>
 
-            <para>
-               Alternatively, build a
-               <literal>Configuration</literal>
-               object
-               and pass it to the
-               <literal>CacheJmxWrapper</literal>
-               . The wrapper
-               will construct the
-               <literal>Cache</literal>
-               :
-            </para>
+                <para>
+                    Alternatively, build a
+                    <literal>Configuration</literal>
+                    object
+                    and pass it to the
+                    <literal>CacheJmxWrapper</literal>
+                    . The wrapper
+                    will construct the
+                    <literal>Cache</literal>
+                    :
+                </para>
 
-            <programlisting role="JAVA"><![CDATA[
+                <programlisting role="JAVA"><![CDATA[
    Configuration config = buildConfiguration(); // whatever it does
 
    CacheJmxWrapperMBean wrapper = new CacheJmxWrapper(config);
@@ -508,43 +510,44 @@
    wrapper.stop();
    wrapper.destroy();
             ]]></programlisting>
-         </section>
+            </section>
 
-         <section>
-            <title>JMX-Based Deployment in JBoss AS (JBoss AS 4.x and 5.x)</title>
+            <section>
+                <title>JMX-Based Deployment in JBoss AS (JBoss AS 4.x and 5.x)</title>
 
-            <para>
-               When you
-               <link linkend="deployment.microkernel">deploy your cache in JBoss AS using a -service.xml file</link>
-               ,
-               a
-               <literal>CacheJmxWrapper</literal>
-               is automatically registered. There is no need
-               to do anything further. The
-               <literal>CacheJmxWrapper</literal>
-               is accessible from an MBean server
-               through the service name specified in the cache configuration file's
-               <literal>mbean</literal>
-               element.
-            </para>
-         </section>
+                <para>
+                    When you
+                    <link linkend="deployment.microkernel">deploy your cache in JBoss AS using a -service.xml file
+                    </link>
+                    ,
+                    a
+                    <literal>CacheJmxWrapper</literal>
+                    is automatically registered. There is no need
+                    to do anything further. The
+                    <literal>CacheJmxWrapper</literal>
+                    is accessible from an MBean server
+                    through the service name specified in the cache configuration file's
+                    <literal>mbean</literal>
+                    element.
+                </para>
+            </section>
 
-         <section>
-            <title>Via JBoss Microcontainer (JBoss AS 5.x)</title>
+            <section>
+                <title>Via JBoss Microcontainer (JBoss AS 5.x)</title>
 
-            <para>
-               <literal>CacheJmxWrapper</literal>
-               is a POJO, so the microcontainer
-               has no problem creating one. The trick is
-               getting it to register your bean in JMX. This can be done by
-               specifying the
-               <literal>org.jboss.aop.microcontainer.aspects.jmx.JMX</literal>
-               annotation on the
-               <literal>CacheJmxWrapper</literal>
-               bean:
-            </para>
+                <para>
+                    <literal>CacheJmxWrapper</literal>
+                    is a POJO, so the microcontainer
+                    has no problem creating one. The trick is
+                    getting it to register your bean in JMX. This can be done by
+                    specifying the
+                    <literal>org.jboss.aop.microcontainer.aspects.jmx.JMX</literal>
+                    annotation on the
+                    <literal>CacheJmxWrapper</literal>
+                    bean:
+                </para>
 
-            <programlisting role="XML"><![CDATA[
+                <programlisting role="XML"><![CDATA[<![CDATA[<![CDATA[
 <?xml version="1.0" encoding="UTF-8"?>
 
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
@@ -552,63 +555,64 @@
    <!-- First we create a Configuration object for the cache -->
    <bean name="ExampleCacheConfig"
    		 class="org.jboss.cache.config.Configuration">
-      
+
       ... build up the Configuration
-      
+
    </bean>
-   
+
    <!-- Factory to build the Cache. -->
-   <bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">      
-      <constructor factoryClass="org.jboss.cache.DefaultCacheFactory" 
+   <bean name="DefaultCacheFactoryorg.jboss.starobrno.factories.DefaultCacheFactoryheFactory">
+      <constructor factoryClass="org.jboss.starobrno.factories.DefaultCacheFactory"
                    factoryMethod="getInstance"/>
    </bean>
-   
+
    <!-- The cache itself -->
    <bean name="ExampleCache" class="org.jboss.cache.CacheImpl">
-      
+
       <constructor factoryMethod="createnewInstance">
           <factory bean="DefaultCacheFactory"/>
           <parameter><inject bean="ExampleCacheConfig"/></parameter>
           <parameter>false</false>
       </constructor>
-          
+
    </bean>
-   
+
    <!-- JMX Management -->
    <bean name="ExampleCacheJmxWrapper" class="org.jboss.cache.jmx.CacheJmxWrapper">
-      
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=ExampleTreeCache", 
-                         exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class, 
+
+      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=ExampleTreeCache",
+                         exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class,
                          registerDirectly=true)</annotation>
-      
+
       <constructor>
           <parameter><inject bean="ExampleCache"/></parameter>
       </constructor>
-          
+
    </bean>
 
-</deployment>      
-]]></programlisting>
+</deployment>
+]]>]]>]]>
+                </programlisting>
 
-            <para>
-               As discussed in the
-               <link linkend="jmx.registration.programatic">Programatic Registration</link>
-               section,
-               <literal>CacheJmxWrapper</literal>
-               can do the work of building,
-               creating and starting the
-               <literal>Cache</literal>
-               if it is provided
-               with a
-               <literal>Configuration</literal>
-               . With the microcontainer,
-               this is the preferred approach, as it saves the boilerplate XML
-               needed to create the
-               <literal>CacheFactory</literal>
-               :
-            </para>
+                <para>
+                    As discussed in the
+                    <link linkend="jmx.registration.programatic">Programatic Registration</link>
+                    section,
+                    <literal>CacheJmxWrapper</literal>
+                    can do the work of building,
+                    creating and starting the
+                    <literal>Cache</literal>
+                    if it is provided
+                    with a
+                    <literal>Configuration</literal>
+                    . With the microcontainer,
+                    this is the preferred approach, as it saves the boilerplate XML
+                    needed to create the
+                    <literal>CacheFactory</literal>
+                    :
+                </para>
 
-            <programlisting role="XML"><![CDATA[
+                <programlisting role="XML"><![CDATA[
 <?xml version="1.0" encoding="UTF-8"?>
 
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
@@ -635,133 +639,135 @@
 
 </deployment>      
 ]]></programlisting>
-         </section>
+            </section>
 
-      </section>
+        </section>
 
-      <section id="jmx.statistics">
-         <title>JBoss Cache Statistics</title>
-         <para>
-            JBoss Cache captures statistics in its interceptors and exposes the statistics through interceptor
-            MBeans. Gathering of statistics is enabled by default; this can be disabled for a specific cache
-            instance through the
-            <literal>ExposeManagementStatistics</literal>
-            configuration attribute. Note that
-            the majority of the statistics are provided by the
-            <literal>CacheMgmtInterceptor</literal>
-            ,
-            so this MBean is the most significant in this regard. If you want to disable all statistics for performance
-            reasons, you set
-            <literal>ExposeManagementStatistics</literal>
-            to
-            <literal>false</literal>
-            as this will
-            prevent the
-            <literal>CacheMgmtInterceptor</literal>
-            from being included in the cache's interceptor stack
-            when the cache is started.
-         </para>
-         <para>
-            If a
-            <literal>CacheJmxWrapper</literal>
-            is registered with JMX, the wrapper also ensures that
-            an MBean is registered in JMX for each interceptor that exposes statistics
-            <footnote>
-               <para>
-                  Note that if the
-                  <literal>CacheJmxWrapper</literal>
-                  is not registered in JMX, the
-                  interceptor MBeans will not be registered either. The JBoss Cache 1.4 releases
-                  included code that would try to "discover" an
-                  <literal>MBeanServer</literal>
-                  and
-                  automatically register the interceptor MBeans with it. For JBoss Cache 2.x we decided
-                  that this sort of "discovery" of the JMX environment was beyond the proper scope of
-                  a caching library, so we removed this functionality.
-               </para>
-            </footnote>
-            .
-            Management tools can then access those MBeans to examine the statistics. See the section in the
-            <link linkend="jmx_reference.statistics">JMX Reference chapter</link>
-            pertaining to the
-            statistics that are made available via JMX.
-         </para>
-         <para>
-            The name under which the interceptor MBeans will be registered is derived by taking the
-            <literal>ObjectName</literal>
-            under which the
-            <literal>CacheJmxWrapper</literal>
-            is
-            registered and adding a
-            <literal>cache-interceptor</literal>
-            attribute key whose value
-            is the non-qualified name of the interceptor class. So, for example, if the
-            <literal>CacheJmxWrapper</literal>
-            were registered under
-            <literal>jboss.cache:service=TreeCache</literal>
-            , the name of the
-            <literal>CacheMgmtInterceptor</literal>
-            MBean would be
-            <literal>jboss.cache:service=TreeCache,cache-interceptor=CacheMgmtInterceptor</literal>
-            .
-         </para>
-         <para>
-            Each interceptor's MBean exposes a
-            <literal>StatisticsEnabled</literal>
-            attribute that can be used to disable maintenance of statistics for
-            that interceptor. In addition, each interceptor MBean provides the following common operations and
-            attributes.
-            <itemizedlist>
-               <listitem>
-                  <literal>dumpStatistics</literal>
-                  - returns a
-                  <literal>Map</literal>
-                  containing the interceptor's attributes and values.
-               </listitem>
-               <listitem>
-                  <literal>resetStatistics</literal>
-                  - resets all statistics maintained by the interceptor.
-               </listitem>
-               <listitem>
-                  <literal>setStatisticsEnabled(boolean)</literal>
-                  - allows statistics to be disabled for a specific interceptor.
-               </listitem>
-            </itemizedlist>
-         </para>
-         <para>
-         </para>
-      </section>
+        <section id="jmx.statistics">
+            <title>JBoss Cache Statistics</title>
+            <para>
+                JBoss Cache captures statistics in its interceptors and exposes the statistics through interceptor
+                MBeans. Gathering of statistics is enabled by default; this can be disabled for a specific cache
+                instance through the
+                <literal>ExposeManagementStatistics</literal>
+                configuration attribute. Note that
+                the majority of the statistics are provided by the
+                <literal>CacheMgmtInterceptor</literal>
+                ,
+                so this MBean is the most significant in this regard. If you want to disable all statistics for
+                performance
+                reasons, you set
+                <literal>ExposeManagementStatistics</literal>
+                to
+                <literal>false</literal>
+                as this will
+                prevent the
+                <literal>CacheMgmtInterceptor</literal>
+                from being included in the cache's interceptor stack
+                when the cache is started.
+            </para>
+            <para>
+                If a
+                <literal>CacheJmxWrapper</literal>
+                is registered with JMX, the wrapper also ensures that
+                an MBean is registered in JMX for each interceptor that exposes statistics
+                <footnote>
+                    <para>
+                        Note that if the
+                        <literal>CacheJmxWrapper</literal>
+                        is not registered in JMX, the
+                        interceptor MBeans will not be registered either. The JBoss Cache 1.4 releases
+                        included code that would try to "discover" an
+                        <literal>MBeanServer</literal>
+                        and
+                        automatically register the interceptor MBeans with it. For JBoss Cache 2.x we decided
+                        that this sort of "discovery" of the JMX environment was beyond the proper scope of
+                        a caching library, so we removed this functionality.
+                    </para>
+                </footnote>
+                .
+                Management tools can then access those MBeans to examine the statistics. See the section in the
+                <link linkend="jmx_reference.statistics">JMX Reference chapter</link>
+                pertaining to the
+                statistics that are made available via JMX.
+            </para>
+            <para>
+                The name under which the interceptor MBeans will be registered is derived by taking the
+                <literal>ObjectName</literal>
+                under which the
+                <literal>CacheJmxWrapper</literal>
+                is
+                registered and adding a
+                <literal>cache-interceptor</literal>
+                attribute key whose value
+                is the non-qualified name of the interceptor class. So, for example, if the
+                <literal>CacheJmxWrapper</literal>
+                were registered under
+                <literal>jboss.cache:service=TreeCache</literal>
+                , the name of the
+                <literal>CacheMgmtInterceptor</literal>
+                MBean would be
+                <literal>jboss.cache:service=TreeCache,cache-interceptor=CacheMgmtInterceptor</literal>
+                .
+            </para>
+            <para>
+                Each interceptor's MBean exposes a
+                <literal>StatisticsEnabled</literal>
+                attribute that can be used to disable maintenance of statistics for
+                that interceptor. In addition, each interceptor MBean provides the following common operations and
+                attributes.
+                <itemizedlist>
+                    <listitem>
+                        <literal>dumpStatistics</literal>
+                        - returns a
+                        <literal>Map</literal>
+                        containing the interceptor's attributes and values.
+                    </listitem>
+                    <listitem>
+                        <literal>resetStatistics</literal>
+                        - resets all statistics maintained by the interceptor.
+                    </listitem>
+                    <listitem>
+                        <literal>setStatisticsEnabled(boolean)</literal>
+                        - allows statistics to be disabled for a specific interceptor.
+                    </listitem>
+                </itemizedlist>
+            </para>
+            <para>
+            </para>
+        </section>
 
-      <section>
-         <title>Receiving JMX Notifications</title>
-         <para>
-            JBoss Cache users can register a listener to receive cache events described earlier in the
-            <link linkend="api.listener">User API</link>
-            chapter. Users can alternatively utilize the cache's management information infrastructure to receive these
-            events
-            via JMX notifications. Cache events are accessible as notifications by registering a
-            <literal>NotificationListener</literal>
-            for the
-            <literal>CacheJmxWrapper</literal>
-            .
-         </para>
+        <section>
+            <title>Receiving JMX Notifications</title>
+            <para>
+                JBoss Cache users can register a listener to receive cache events described earlier in the
+                <link linkend="api.listener">User API</link>
+                chapter. Users can alternatively utilize the cache's management information infrastructure to receive
+                these
+                events
+                via JMX notifications. Cache events are accessible as notifications by registering a
+                <literal>NotificationListener</literal>
+                for the
+                <literal>CacheJmxWrapper</literal>
+                .
+            </para>
 
-         <para>
-            See the section in the
-            <link linkend="jmx_reference.notifications">JMX Reference chapter</link>
-            pertaining
-            to JMX notifications for a list of notifications that can be received through the
-            <literal>CacheJmxWrapper</literal>
-            .
-         </para>
+            <para>
+                See the section in the
+                <link linkend="jmx_reference.notifications">JMX Reference chapter</link>
+                pertaining
+                to JMX notifications for a list of notifications that can be received through the
+                <literal>CacheJmxWrapper</literal>
+                .
+            </para>
 
 
-         <para>
-            The following is an example of how to programmatically receive cache notifications when running in a
-            JBoss AS environment. In this example, the client uses a filter to specify which events are of interest.
-         </para>
+            <para>
+                The following is an example of how to programmatically receive cache notifications when running in a
+                JBoss AS environment. In this example, the client uses a filter to specify which events are of interest.
+            </para>
 
-         <programlisting role="JAVA"><![CDATA[
+            <programlisting role="JAVA"><![CDATA[
    MyListener listener = new MyListener();
    NotificationFilterSupport filter = null;
 
@@ -789,8 +795,8 @@
    server.removeNotificationListener(mgmt_name, listener, filter, null);
          ]]></programlisting>
 
-         <para>The following is the simple notification listener implementation used in the previous example.</para>
-         <programlisting role="JAVA"><![CDATA[
+            <para>The following is the simple notification listener implementation used in the previous example.</para>
+            <programlisting role="JAVA"><![CDATA[
    private class MyListener implements NotificationListener, Serializable
    {
       public void handleNotification(Notification notification, Object handback)
@@ -825,71 +831,73 @@
    }
          ]]></programlisting>
 
-         <para>Note that the JBoss Cache management implementation only listens to cache events after a client registers
-            to receive MBean notifications. As soon as no clients are registered for notifications, the MBean will
-            remove
-            itself as a cache listener.
-         </para>
+            <para>Note that the JBoss Cache management implementation only listens to cache events after a client
+                registers
+                to receive MBean notifications. As soon as no clients are registered for notifications, the MBean will
+                remove
+                itself as a cache listener.
+            </para>
 
-      </section>
+        </section>
 
-      <section>
-         <title>Accessing Cache MBeans in a Standalone Environment</title>
-         <para>
-            JBoss Cache MBeans are easily accessed when running cache instances in an application server that
-            provides an MBean server interface such as JBoss JMX Console. Refer to your server documentation
-            for instructions on how to access MBeans running in a server's MBean container.
-         </para>
-         <para>
-            In addition, though, JBoss Cache MBeans are also accessible when running in a non-server environment if the
-            JVM is JDK 5.0 or later. When running a standalone cache in a JDK 5.0 environment, you can access the
-            cache's MBeans as follows.
-         </para>
-         <para>
-            <orderedlist>
-               <listitem>
-                  Set the system property
-                  <literal>-Dcom.sun.management.jmxremote</literal>
-                  when starting the JVM
-                  where the cache will run.
-               </listitem>
-               <listitem>
-                  Once the JVM is running, start the JDK 5.0
-                  <literal>jconsole</literal>
-                  utility, located in your JDK's
-                  <literal>/bin</literal>
-                  directory.
-               </listitem>
-               <listitem>When the utility loads, you will be able to select your running JVM and connect to it. The
-                  JBoss Cache
-                  MBeans will be available on the MBeans panel.
-               </listitem>
-            </orderedlist>
-         </para>
-         <para>Note that the
-            <literal>jconsole</literal>
-            utility will automatically register as a listener for cache notifications when
-            connected to a JVM running JBoss Cache instances.
-         </para>
+        <section>
+            <title>Accessing Cache MBeans in a Standalone Environment</title>
+            <para>
+                JBoss Cache MBeans are easily accessed when running cache instances in an application server that
+                provides an MBean server interface such as JBoss JMX Console. Refer to your server documentation
+                for instructions on how to access MBeans running in a server's MBean container.
+            </para>
+            <para>
+                In addition, though, JBoss Cache MBeans are also accessible when running in a non-server environment if
+                the
+                JVM is JDK 5.0 or later. When running a standalone cache in a JDK 5.0 environment, you can access the
+                cache's MBeans as follows.
+            </para>
+            <para>
+                <orderedlist>
+                    <listitem>
+                        Set the system property
+                        <literal>-Dcom.sun.management.jmxremote</literal>
+                        when starting the JVM
+                        where the cache will run.
+                    </listitem>
+                    <listitem>
+                        Once the JVM is running, start the JDK 5.0
+                        <literal>jconsole</literal>
+                        utility, located in your JDK's
+                        <literal>/bin</literal>
+                        directory.
+                    </listitem>
+                    <listitem>When the utility loads, you will be able to select your running JVM and connect to it. The
+                        JBoss Cache
+                        MBeans will be available on the MBeans panel.
+                    </listitem>
+                </orderedlist>
+            </para>
+            <para>Note that the
+                <literal>jconsole</literal>
+                utility will automatically register as a listener for cache notifications when
+                connected to a JVM running JBoss Cache instances.
+            </para>
 
-         <para>The following figure shows cache interceptor MBeans in
-            <literal>jconsole</literal>
-            . Cache statistics are displayed
-            for the
-            <literal>CacheMgmtInterceptor</literal>
-            :
-         </para>
+            <para>The following figure shows cache interceptor MBeans in
+                <literal>jconsole</literal>
+                . Cache statistics are displayed
+                for the
+                <literal>CacheMgmtInterceptor</literal>
+                :
+            </para>
 
-         <figure>
-            <title>CacheMgmtInterceptor MBean in jconsole</title>
+            <figure>
+                <title>CacheMgmtInterceptor MBean in jconsole</title>
 
-            <mediaobject>
-               <imageobject>
-                  <imagedata fileref="CacheMgmtInterceptor.png"/>
-               </imageobject>
-            </mediaobject>
-         </figure>
+                <mediaobject>
+                    <imageobject>
+                        <imagedata fileref="CacheMgmtInterceptor.png"/>
+                    </imageobject>
+                </mediaobject>
+            </figure>
 
-      </section>
-   </section>
+        </section>
+    </section>
 </chapter>

Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -47,7 +47,7 @@
  *
  * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
  * @see Cache_Legacy
- * @see org.jboss.cache.DefaultCacheFactory
+ * @see org.jboss.starobrno.factories.DefaultCacheFactory
  * @since 2.0.0
  */
 @ThreadSafe

Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -135,7 +135,7 @@
    /**
     * Extension point for subclasses, where we actually use a
     * {@link CacheFactory} to create a cache. This default implementation
-    * uses {@link DefaultCacheFactory}.
+    * uses {@link org.jboss.starobrno.factories.DefaultCacheFactory}.
     *
     * @param config the Configuration for the cache
     * @return the Cache

Deleted: core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -1,181 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache;
-
-import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.jmx.PlatformMBeanServerRegistration;
-import org.jboss.starobrno.Cache;
-import org.jboss.starobrno.CacheDelegate;
-import org.jboss.starobrno.CacheSPI;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.parsing.XmlConfigurationParserJBC3;
-import org.jboss.starobrno.factories.ComponentFactory;
-import org.jboss.starobrno.factories.ComponentRegistry;
-
-import java.io.InputStream;
-
-/**
- * Default implementation of the {@link org.jboss.cache.CacheFactory} interface.
- * <p/>
- * This is a special instance of a {@link ComponentFactory} which contains bootstrap information for the
- * {@link org.jboss.cache.factories.ComponentRegistry}.
- * <p/>
- *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @see org.jboss.cache.factories.ComponentFactory
- */
-public class DefaultCacheFactory<K, V> extends ComponentFactory implements CacheFactory<K, V>
-{
-   private ClassLoader defaultClassLoader;
-
-
-   /**
-    * This is here for backward compatibility only.  Use <tt>new DefaultCacheFactory()</tt> instead.
-    *
-    * @deprecated
-    */
-   @SuppressWarnings("unchecked")
-   @Deprecated
-   @Compat
-   public static DefaultCacheFactory getInstance()
-   {
-      return new DefaultCacheFactory();
-   }
-
-   public org.jboss.starobrno.Cache<K, V> createCache() throws ConfigurationException
-   {
-      return createCache(true);
-   }
-
-   public org.jboss.starobrno.Cache<K, V> createCache(boolean start) throws ConfigurationException
-   {
-      return createCache(new Configuration(), start);
-   }
-
-   public org.jboss.starobrno.Cache<K, V> createCache(String configFileName) throws ConfigurationException
-   {
-      return createCache(configFileName, true);
-   }
-
-   public org.jboss.starobrno.Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
-   {
-      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
-      Configuration c;
-      c = parser.parseFile(configFileName);
-      return createCache(c, start);
-   }
-
-   /**
-    * This implementation clones the configuration passed in before using it.
-    *
-    * @param configuration to use
-    * @return a cache
-    * @throws ConfigurationException if there are problems with the cfg
-    */
-   public org.jboss.starobrno.Cache<K, V> createCache(Configuration configuration) throws ConfigurationException
-   {
-      return createCache(configuration, true);
-   }
-
-   /**
-    * This implementation clones the configuration passed in before using it.
-    *
-    * @param configuration to use
-    * @param start         whether to start the cache
-    * @return a cache
-    * @throws ConfigurationException if there are problems with the cfg
-    */
-   public org.jboss.starobrno.Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
-   {
-      try
-      {
-         CacheSPI<K, V> cache = createAndWire(configuration);
-         if (start) cache.start();
-         return cache;
-      }
-      catch (ConfigurationException ce)
-      {
-         throw ce;
-      }
-      catch (RuntimeException re)
-      {
-         throw re;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   protected org.jboss.starobrno.CacheSPI<K, V> createAndWire(Configuration configuration) throws Exception
-   {
-      CacheSPI<K, V> spi = new CacheDelegate<K, V>();
-      bootstrap(spi, configuration);
-      return spi;
-   }
-
-   /**
-    * Bootstraps this factory with a Configuration and a ComponentRegistry.
-    */
-   private void bootstrap(CacheSPI spi, Configuration configuration)
-   {
-      // injection bootstrap stuff
-      componentRegistry = new ComponentRegistry(configuration, spi);
-      componentRegistry.registerDefaultClassLoader(defaultClassLoader);
-      this.configuration = configuration;
-
-      componentRegistry.registerComponent(spi, CacheSPI.class);
-      componentRegistry.registerComponent(new PlatformMBeanServerRegistration(), PlatformMBeanServerRegistration.class);
-   }
-
-   /**
-    * Allows users to specify a default class loader to use for both the construction and running of the cache.
-    *
-    * @param loader class loader to use as a default.
-    */
-   public void setDefaultClassLoader(ClassLoader loader)
-   {
-      this.defaultClassLoader = loader;
-   }
-
-   public Cache<K, V> createCache(InputStream is) throws ConfigurationException
-   {
-      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
-      Configuration c = null;
-      c = parser.parseStream(is);
-      return createCache(c);
-   }
-
-   public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
-   {
-      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
-      Configuration c = parser.parseStream(is);
-      return createCache(c, start);
-   }
-
-   @Override
-   protected <T> T construct(Class<T> componentType)
-   {
-      throw new UnsupportedOperationException("Should never be invoked - this is a bootstrap factory.");
-   }
-}

Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -23,11 +23,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheFactory;
 import org.jboss.cache.CacheSPI_Legacy;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.Cache_Legacy;
-import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.util.CachePrinter;
 import org.jboss.starobrno.CacheException;
 import org.jboss.starobrno.config.BuddyReplicationConfig;
@@ -46,16 +44,7 @@
 import org.jgroups.jmx.JChannelFactoryMBean;
 import org.w3c.dom.Element;
 
-import javax.management.AttributeChangeNotification;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
+import javax.management.*;
 import javax.transaction.TransactionManager;
 import java.util.ArrayList;
 import java.util.List;
@@ -935,7 +924,7 @@
    protected void constructCache() throws ConfigurationException
    {
       log.debug("Constructing Cache");
-      CacheFactory<K, V> cf = new DefaultCacheFactory<K, V>();
+      //CacheFactory<K, V> cf = new DefaultCacheFactory<K, V>();
       throw new UnsupportedOperationException("Fix me to use a flat cache!!");
 //      setCache(cf.createCache(config, false));
 //      if (multiplexerService != null)

Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -23,14 +23,32 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI_Legacy;
+import org.jboss.cache.Cache_Legacy;
+import org.jboss.cache.Modification;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
 import org.jboss.cache.jmx.CacheJmxWrapperMBean;
 import org.jboss.starobrno.CacheException;
 import org.jboss.starobrno.tree.Fqn;
 
-import java.io.*;
-import java.net.*;
-import java.util.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * TCP-IP based CacheServer, setCache TcpDelegatingCacheLoader with host and port of this server
@@ -123,7 +141,8 @@
          }
          else if (config != null)
          {
-            cache = (CacheSPI_Legacy) new DefaultCacheFactory<Object, Object>().createCache(this.config);
+//            cache = (CacheSPI_Legacy) new DefaultCacheFactory<Object, Object>().createCache(this.config, null);
+            throw new RuntimeException("FIX ME");
          }
       }
 

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -34,7 +34,12 @@
 import org.jboss.starobrno.commands.CommandsFactory;
 import org.jboss.starobrno.commands.read.GetKeyValueCommand;
 import org.jboss.starobrno.commands.read.SizeCommand;
-import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.write.ClearCommand;
+import org.jboss.starobrno.commands.write.EvictCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.PutMapCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.commands.write.ReplaceCommand;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.container.DataContainer;
@@ -84,6 +89,10 @@
    private LockManager lockManager;
    private static final Log log = LogFactory.getLog(CacheDelegate.class);
 
+   public CacheDelegate(String name)
+   {
+      this.name = name;
+   }
 
    @Inject
    private void injectDependencies(EvictionManager evictionManager,

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -1,16 +1,17 @@
 package org.jboss.starobrno;
 
+import net.jcip.annotations.ThreadSafe;
 import org.jboss.starobrno.eviction.EvictionCacheManager;
 import org.jboss.starobrno.factories.annotations.NonVolatile;
-import net.jcip.annotations.ThreadSafe;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 
-import java.util.concurrent.ThreadFactory;
-
 /**
  * @author Mircea.Markus at jboss.com
  */
 @ThreadSafe
 @NonVolatile
+ at Scope(Scopes.CACHE_ONLY)
 public interface EvictionManager
 {
    /**
@@ -30,7 +31,8 @@
     * If the given cache doesn't have eviction enabled this is an no-op.
     * If this is the only cache that has eviction enabled, then the eviction thread will be stopped.
     * After calling this method the given cache will be unregistered from eviction events.
-    * @param chacheName
+    *
+    * @param cacheName
     */
    public void cacheStopped(String cacheName);
 

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -23,11 +23,19 @@
 
 import org.jboss.starobrno.commands.read.GetKeyValueCommand;
 import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.remote.ReplicateCommand;
 import org.jboss.starobrno.commands.tx.CommitCommand;
 import org.jboss.starobrno.commands.tx.PrepareCommand;
 import org.jboss.starobrno.commands.tx.RollbackCommand;
-import org.jboss.starobrno.commands.write.*;
-import org.jboss.starobrno.commands.remote.ReplicateCommand;
+import org.jboss.starobrno.commands.write.ClearCommand;
+import org.jboss.starobrno.commands.write.EvictCommand;
+import org.jboss.starobrno.commands.write.InvalidateCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.PutMapCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 import org.jboss.starobrno.transaction.GlobalTransaction;
 import org.jgroups.Address;
 
@@ -37,6 +45,7 @@
 /**
  * @author Mircea.Markus at jboss.com
  */
+ at Scope(Scopes.CACHE_ONLY)
 public interface CommandsFactory
 {
    PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value);

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -33,7 +33,11 @@
 import org.w3c.dom.Element;
 
 import java.net.URL;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 
 /**
  * Encapsulates the configuration of a Cache.

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -28,8 +28,15 @@
 import org.jboss.starobrno.factories.ComponentRegistry;
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
 
 /**
  * Base superclass of Cache configuration classes that expose some properties
@@ -39,6 +46,7 @@
  * @version $Revision$
  * @see #testImmutability(String)
  */
+ at Scope(Scopes.CACHE_ONLY)
 public abstract class ConfigurationComponent implements CloneableConfigurationComponent
 {
    private static final long serialVersionUID = 4879873994727821938L;

Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/SharedConfiguration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/SharedConfiguration.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/SharedConfiguration.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,42 @@
+package org.jboss.starobrno.config;
+
+/**
+ * // TODO: Manik: Document this!
+ *
+ * @author Manik Surtani
+ */
+public class SharedConfiguration extends ConfigurationComponent
+{
+   /*
+   <asyncListenerExecutor factory="org.jboss.starobrno.executors.DefaultExecutorFactory">
+            <property name="maxThreads">5</property>
+            <property name="threadNamePrefix">AsyncListenerThread</property>
+        </asyncListenerExecutor>
+
+        <asyncSerializationExecutor factory="org.jboss.starobrno.executors.DefaultExecutorFactory">
+            <property name="maxThreads">25</property>
+            <property name="threadNamePrefix">AsyncSerializationThread</property>
+        </asyncSerializationExecutor>
+
+        <evictionScheduledExecutor factory="org.jboss.starobrno.executors.DefaultScheduledExecutorFactory">
+            <property name="threadNamePrefix">EvictionThread</property>
+        </evictionScheduledExecutor>
+
+        <replicationQueueScheduledExecutor factory="org.jboss.starobrno.executors.DefaultScheduledExecutorFactory">
+            <property name="threadNamePrefix">ReplicationQueueThread</property>
+        </replicationQueueScheduledExecutor>
+
+        <jgroupsConfig configFile="udp.xml"/>
+
+        <serialization marshallerClass="org.jboss.starobrno.marshall.CacheMarshallerStarobrno" version="1.0"
+                       objectInputStreamPoolSize="100" objectOutputStreamPoolSize="100"/>
+    */
+   String asyncListenerExecutorFactoryClass;
+   String asyncSerializationExecutorFactoryClass;
+   String evictionScheduledExecutorFactoryClass;
+   String replicationQueueScheduledExecutorFactoryClass;
+   String marshallerClass;
+   String marshallVersion;
+   int objectInputStreamPoolSize;
+   int objectOutputStreamPoolSize;
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -21,6 +21,9 @@
  */
 package org.jboss.starobrno.container;
 
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
+
 import java.util.Set;
 
 /**
@@ -29,6 +32,7 @@
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  * @since 3.0
  */
+ at Scope(Scopes.CACHE_ONLY)
 public interface DataContainer<K, V>
 {
    V get(K k);

Added: core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultExecutorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultExecutorFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultExecutorFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,32 @@
+package org.jboss.starobrno.executors;
+
+import org.jboss.starobrno.util.TypedProperties;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Default executor factory that creates executors using the JDK Executors service.
+ *
+ * @author Manik Surtani
+ */
+public class DefaultExecutorFactory implements ExecutorFactory
+{
+   public ExecutorService getExecutor(Properties p)
+   {
+      TypedProperties tp = new TypedProperties(p);
+      int maxThreads = tp.getIntProperty("maxThreads", 1);
+      final String threadNamePrefix = tp.getProperty("threadNamePrefix", "Thread");
+      final AtomicInteger counter = new AtomicInteger(0);
+      return Executors.newFixedThreadPool(maxThreads, new ThreadFactory()
+      {
+         public Thread newThread(Runnable r)
+         {
+            return new Thread(threadNamePrefix + "-" + counter.getAndIncrement());
+         }
+      });
+   }
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultScheduledExecutorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultScheduledExecutorFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/executors/DefaultScheduledExecutorFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,31 @@
+package org.jboss.starobrno.executors;
+
+import org.jboss.starobrno.util.TypedProperties;
+
+import java.util.Properties;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Creates scheduled executors using the JDK Executors service
+ *
+ * @author Manik Surtani
+ */
+public class DefaultScheduledExecutorFactory implements ScheduledExecutorFactory
+{
+   public ScheduledExecutorService getScheduledExecutor(Properties p)
+   {
+      TypedProperties tp = new TypedProperties(p);
+      final String threadNamePrefix = tp.getProperty("threadNamePrefix", "ScheduledThread");
+      final AtomicInteger counter = new AtomicInteger(0);
+      return Executors.newSingleThreadScheduledExecutor(new ThreadFactory()
+      {
+         public Thread newThread(Runnable r)
+         {
+            return new Thread(threadNamePrefix + "-" + counter.getAndIncrement());
+         }
+      });
+   }
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/executors/ExecutorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/executors/ExecutorFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/executors/ExecutorFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,14 @@
+package org.jboss.starobrno.executors;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Used to configure and create executors
+ *
+ * @author Manik Surtani
+ */
+public interface ExecutorFactory
+{
+   ExecutorService getExecutor(Properties p);
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/executors/ScheduledExecutorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/executors/ScheduledExecutorFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/executors/ScheduledExecutorFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,14 @@
+package org.jboss.starobrno.executors;
+
+import java.util.Properties;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * Used to configure and create scheduled executors
+ *
+ * @author Manik Surtani
+ */
+public interface ScheduledExecutorFactory
+{
+   ScheduledExecutorService getScheduledExecutor(Properties p);
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -26,11 +26,13 @@
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 
 /**
  * Factory that creates components used internally within JBoss Cache, and also wires dependencies into the components.
  * <p/>
- * The {@link org.jboss.cache.DefaultCacheFactory} is a special subclass of this, which bootstraps the construction of
+ * The {@link DefaultCacheFactory} is a special subclass of this, which bootstraps the construction of
  * other components.  When this class is loaded, it maintains a static list of known default factories for known
  * components, which it then delegates to, when actually performing the construction.
  * <p/>
@@ -40,6 +42,7 @@
  * @see ComponentRegistry
  * @since 2.1.0
  */
+ at Scope(Scopes.CACHE_ONLY)
 public abstract class ComponentFactory
 {
    protected final Log log = LogFactory.getLog(getClass());

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -30,14 +30,27 @@
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.RuntimeConfig;
-import org.jboss.starobrno.factories.annotations.*;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 import org.jboss.starobrno.lifecycle.Lifecycle;
 import org.jboss.starobrno.util.BeanUtils;
 import org.jboss.starobrno.util.ReflectionUtil;
 
 import javax.management.MBeanServerFactory;
 import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * A registry where components which have been created are stored.  Components are stored as singletons, registered under
@@ -68,12 +81,13 @@
  * @since 2.1.0
  */
 @NonVolatile
+ at Scope(Scopes.CACHE_ONLY)
 public class ComponentRegistry implements Lifecycle
 {
    /**
     * Contains class definitions of component factories that can be used to construct certain components
     */
-   Map<Class, Class<? extends ComponentFactory>> defaultFactories = null;
+   private Map<Class, Class<? extends ComponentFactory>> defaultFactories = null;
 
    private static final Log log = LogFactory.getLog(ComponentRegistry.class);
    private static final boolean trace = log.isTraceEnabled();
@@ -328,8 +342,8 @@
     */
    protected ComponentFactory getFactory(Class componentClass)
    {
-      if (defaultFactories == null) scanDefaultFactories();
-      Class<? extends ComponentFactory> cfClass = defaultFactories.get(componentClass);
+      Map<Class, Class<? extends ComponentFactory>> defaultFactoryMap = getDefaultFactoryMap();
+      Class<? extends ComponentFactory> cfClass = defaultFactoryMap.get(componentClass);
       if (cfClass == null)
          throw new ConfigurationException("No registered default factory for component " + componentClass + " found!");
       // a component factory is a component too!  See if one has been created and exists in the registry
@@ -351,6 +365,12 @@
       return cf;
    }
 
+   protected Map<Class, Class<? extends ComponentFactory>> getDefaultFactoryMap()
+   {
+      if (defaultFactories == null) scanDefaultFactories();
+      return defaultFactories;
+   }
+
    /**
     * Scans the class path for classes annotated with {@link org.jboss.cache.factories.annotations.DefaultFactoryFor}, and
     * analyses which components can be created by such factories.

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/DefaultCacheFactory.java (from rev 7331, core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/DefaultCacheFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/DefaultCacheFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories;
+
+import org.jboss.cache.jmx.PlatformMBeanServerRegistration;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.CacheDelegate;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.manager.CacheManager;
+
+/**
+ * Default implementation of the {@link org.jboss.cache.CacheFactory} interface.
+ * <p/>
+ * This is a special instance of a {@link ComponentFactory} which contains bootstrap information for the
+ * {@link org.jboss.cache.factories.ComponentRegistry}.
+ * <p/>
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ * @see org.jboss.cache.factories.ComponentFactory
+ */
+public class DefaultCacheFactory<K, V> extends ComponentFactory// implements CacheFactory<K, V>
+{
+   private ClassLoader defaultClassLoader;
+
+   /**
+    * This implementation clones the configuration passed in before using it.
+    *
+    * @param configuration to use
+    * @param start         whether to start the cache
+    * @return a cache
+    * @throws ConfigurationException if there are problems with the cfg
+    */
+   public Cache<K, V> createCache(Configuration configuration, ComponentRegistry parentComponentRegistry, String cacheName) throws ConfigurationException
+   {
+      try
+      {
+         CacheSPI<K, V> cache = createAndWire(configuration, parentComponentRegistry, cacheName);
+         cache.start();
+         return cache;
+      }
+      catch (ConfigurationException ce)
+      {
+         throw ce;
+      }
+      catch (RuntimeException re)
+      {
+         throw re;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public Cache<K, V> createDefaultCache(Configuration configuration) throws ConfigurationException
+   {
+      return createCache(configuration, null, CacheManager.DEFAULT_CACHE_NAME);
+   }
+
+   protected CacheSPI<K, V> createAndWire(Configuration configuration, ComponentRegistry parentComponentRegistry, String cacheName) throws Exception
+   {
+      CacheSPI<K, V> spi = new CacheDelegate<K, V>(cacheName);
+      bootstrap(spi, configuration, parentComponentRegistry);
+      return spi;
+   }
+
+   /**
+    * Bootstraps this factory with a Configuration and a ComponentRegistry.
+    */
+   private void bootstrap(CacheSPI spi, Configuration configuration, ComponentRegistry parentComponentRegistry)
+   {
+      // injection bootstrap stuff
+      componentRegistry = parentComponentRegistry == null ? new ComponentRegistry(configuration, spi) : new HierarchicalComponentRegistry(configuration, spi, parentComponentRegistry);
+      componentRegistry.registerDefaultClassLoader(defaultClassLoader);
+      this.configuration = configuration;
+
+      componentRegistry.registerComponent(spi, CacheSPI.class);
+      componentRegistry.registerComponent(new PlatformMBeanServerRegistration(), PlatformMBeanServerRegistration.class);
+   }
+
+   /**
+    * Allows users to specify a default class loader to use for both the construction and running of the cache.
+    *
+    * @param loader class loader to use as a default.
+    */
+   public void setDefaultClassLoader(ClassLoader loader)
+   {
+      this.defaultClassLoader = loader;
+   }
+
+   @Override
+   protected <T> T construct(Class<T> componentType)
+   {
+      throw new UnsupportedOperationException("Should never be invoked - this is a bootstrap factory.");
+   }
+
+//   public Cache<K, V> createCache() throws ConfigurationException
+//   {
+//      throw new UnsupportedOperationException("Should never be invoked - this is a bootstrap factory.");
+//   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/factories/DefaultCacheFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/HierarchicalComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/HierarchicalComponentRegistry.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/HierarchicalComponentRegistry.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,68 @@
+package org.jboss.starobrno.factories;
+
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.scopes.ScopeDetector;
+import org.jboss.starobrno.factories.scopes.Scopes;
+
+import java.util.Map;
+
+/**
+ * // TODO: Manik: Document this!
+ *
+ * @author Manik Surtani
+ */
+public class HierarchicalComponentRegistry extends ComponentRegistry
+{
+   ComponentRegistry parent;
+
+   /**
+    * Creates an instance of the component registry.  The configuration passed in is automatically registered.
+    *
+    * @param configuration configuration with which this is created
+    * @param cache         cache
+    * @param parent        parent Component Registry to delegate to
+    */
+   public HierarchicalComponentRegistry(Configuration configuration, CacheSPI cache, ComponentRegistry parent)
+   {
+      super(configuration, cache);
+      this.parent = parent;
+   }
+
+   @Override
+   public <T> T getComponent(Class<T> componentType)
+   {
+      // first try in the local registry
+      Scopes componentScope = ScopeDetector.detectScope(componentType);
+      switch (componentScope)
+      {
+         case CACHE_MANAGER_ONLY:
+            return parent.getComponent(componentType);
+         case CACHE_ONLY:
+            return super.getComponent(componentType);
+         case EITHER:
+            T t = super.getComponent(componentType);
+            if (t == null)
+            {
+               // delegate to parent
+               t = parent.getComponent(componentType);
+            }
+            return t;
+         default:
+            throw new IllegalArgumentException("Unknown component scope " + componentScope);
+      }
+   }
+
+   @Override
+   protected Map<Class, Class<? extends ComponentFactory>> getDefaultFactoryMap()
+   {
+      // delegate to parent.  No sense maintaining multiple copies of this map.
+      return parent.getDefaultFactoryMap();
+   }
+
+   @Override
+   protected ComponentFactory getFactory(Class componentClass)
+   {
+      return super.getFactory(componentClass);
+   }
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scope.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scope.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scope.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,16 @@
+package org.jboss.starobrno.factories.scopes;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Defines the scope of a component in a cache system.  If not specified, components default to the {@link Scopes#EITHER} scope.
+ *
+ * @author Manik Surtani
+ * @see Scopes
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Scope
+{
+   Scopes value();
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/ScopeDetector.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/ScopeDetector.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/ScopeDetector.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,20 @@
+package org.jboss.starobrno.factories.scopes;
+
+import org.jboss.starobrno.util.ReflectionUtil;
+
+/**
+ * Retrieves the declated scope of a component
+ *
+ * @author Manik Surtani
+ */
+public class ScopeDetector
+{
+   public static Scopes detectScope(Class clazz)
+   {
+      Scope s = ReflectionUtil.getAnnotation(clazz, Scope.class);
+      if (s == null)
+         return Scopes.getDefaultScope();
+      else
+         return s.value();
+   }
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scopes.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scopes.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/scopes/Scopes.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,34 @@
+package org.jboss.starobrno.factories.scopes;
+
+/**
+ * The different scopes that can be declared for a component in the cache system.  If components are not bounded to a
+ * specific scope explicity, then it defaults to the {@link #CACHE_ONLY} scope.
+ *
+ * @author Manik Surtani
+ * @see Scope
+ */
+public enum Scopes
+{
+   /**
+    * Components bounded to this scope can only be created by a {@link org.jboss.starobrno.manager.CacheManager} and exist in the
+    * {@link org.jboss.starobrno.manager.CacheManager}'s {@link org.jboss.starobrno.factories.ComponentRegistry}.
+    */
+   CACHE_MANAGER_ONLY,
+
+   /**
+    * Components bounded to this scope can only be created by a {@link org.jboss.starobrno.Cache} and exist in the
+    * {@link org.jboss.starobrno.Cache}'s {@link org.jboss.starobrno.factories.ComponentRegistry}.
+    */
+   CACHE_ONLY,
+
+   /**
+    * Components bounded to this scope could be created by either the CacheManager or the Cache, depending on where it is
+    * first configured and encountered.
+    */
+   EITHER;
+
+   public static Scopes getDefaultScope()
+   {
+      return CACHE_ONLY;
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -28,6 +28,8 @@
 import org.jboss.starobrno.context.InvocationContext;
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 import org.jboss.starobrno.interceptors.base.CommandInterceptor;
 import org.jboss.starobrno.invocation.InvocationContextContainer;
 
@@ -44,6 +46,7 @@
  *        todo - if you add the same interceptor instance twice, things get really dirty.
  *        -- this should be treated as an missuse and an exception should be thrown
  */
+ at Scope(Scopes.CACHE_ONLY)
 public class InterceptorChain
 {
    /**
@@ -379,4 +382,15 @@
       }
       return false;
    }
+
+   public boolean containsInterceptorType(Class<? extends CommandInterceptor> interceptorType)
+   {
+      CommandInterceptor it = firstInChain;
+      while (it != null)
+      {
+         if (it.getClass().equals(interceptorType)) return true;
+         it = it.getNext();
+      }
+      return false;
+   }
 }
\ No newline at end of file

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -28,6 +28,8 @@
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.context.InvocationContext;
 import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 
 /**
  * This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
@@ -52,6 +54,7 @@
  * @see org.jboss.cache.interceptors.InterceptorChain
  * @since 2.2
  */
+ at Scope(Scopes.CACHE_ONLY)
 public class CommandInterceptor extends AbstractVisitor
 {
    private CommandInterceptor next;

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -21,10 +21,12 @@
  */
 package org.jboss.starobrno.invocation;
 
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.NonVolatile;
-import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.context.ContextFactory;
-import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 
 
 /**
@@ -34,6 +36,7 @@
  * @since 2.1.0
  */
 @NonVolatile
+ at Scope(Scopes.CACHE_ONLY)
 public class InvocationContextContainer extends ThreadLocal<InvocationContext>
 {
    ContextFactory contextFactory;

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -25,6 +25,8 @@
 import org.jboss.cache.loader.AbstractCacheLoader;
 import org.jboss.starobrno.CacheSPI;
 import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 import org.jboss.starobrno.marshall.EntryData;
 
 import java.io.ObjectInputStream;
@@ -60,6 +62,7 @@
  * @since 2.0.0
  */
 @ThreadSafe
+ at Scope(Scopes.CACHE_ONLY)
 public interface CacheLoader<K, V>
 {
    /**

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -21,16 +21,19 @@
  */
 package org.jboss.starobrno.manager;
 
-import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.CacheSPI;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
 import org.jboss.starobrno.config.parsing.XmlConfigurationParserImpl;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.factories.DefaultCacheFactory;
 import org.jboss.starobrno.lifecycle.Lifecycle;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -81,7 +84,9 @@
    protected Configuration configuration;
    private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>();
    private final ConcurrentMap<String, Configuration> configurationOverrides = new ConcurrentHashMap<String, Configuration>();
+   private ComponentRegistry sharedComponentRegistry;
 
+
    /**
     * Constructs and starts a default instance of the CacheManager, using configuration defaults.
     */
@@ -228,26 +233,21 @@
     */
    public Cache getCache()
    {
-      try
-      {
-         return getCache(DEFAULT_CACHE_NAME);
-      }
-      catch (NamedCacheNotFoundException e)
-      {
-         throw new RuntimeException("Default cache not found; this should NEVER happen!", e);
-      }
+      return getCache(DEFAULT_CACHE_NAME);
    }
 
    /**
-    * Retrieves a named cache from the system.  The named cache must have been defined previously using the {@link #defineCache(String, org.jboss.starobrno.config.Configuration)}
-    * method or have been declared in the configuration file used by this <tt>CacheManager</tt>
-    * instance, otherwise this method will throw a {@link org.jboss.starobrno.manager.NamedCacheNotFoundException}.
+    * Retrieves a named cache from the system.  If the cache has been previously created with the same name, the running
+    * cache instance is returned.  Otherwise, this method attempts to create the cache first.
+    * <p/>
+    * When creating a new cache, this method will use the configuration passed in to the CacheManager on construction,
+    * as a template, and then optionally apply any overrides previously defined for the named cache using the
+    * {@link #defineCache(String, org.jboss.starobrno.config.Configuration)} method, or declared in the configuration file.
     *
     * @param cacheName name of cache to retrieve
     * @return a cache instance identified by cacheName
-    * @throws NamedCacheNotFoundException if the named cache does not exist, or is not defined declaratively.
     */
-   public Cache getCache(String cacheName) throws NamedCacheNotFoundException
+   public Cache getCache(String cacheName)
    {
       if (cacheName == null)
          throw new NullPointerException("Null arguments not allowed");
@@ -255,9 +255,6 @@
       if (caches.containsKey(cacheName))
          return caches.get(cacheName);
 
-      if (!cacheName.equals(DEFAULT_CACHE_NAME) && !configurationOverrides.containsKey(cacheName))
-         throw new NamedCacheNotFoundException("No such cache named " + cacheName + " defined or declared with this CacheManager!");
-
       return createCache(cacheName);
    }
 
@@ -267,10 +264,10 @@
       if (!cacheName.equals(DEFAULT_CACHE_NAME))
       {
          Configuration overrides = configurationOverrides.get(cacheName);
-         c.applyOverrides(overrides);
+         if (overrides != null) c.applyOverrides(overrides);
       }
 
-      Cache cache = new DefaultCacheFactory().createCache(c, false);
+      Cache cache = new DefaultCacheFactory().createCache(c, sharedComponentRegistry, cacheName);
       Cache other = caches.putIfAbsent(cacheName, cache);
       if (other == null)
       {
@@ -285,11 +282,27 @@
 
    public void start()
    {
-      // todo
+      // get a hold of the "default" cache to start this?
+      CacheSPI defaultCache = (CacheSPI) getCache();
+      sharedComponentRegistry = defaultCache.getComponentRegistry();
    }
 
    public void stop()
    {
-      for (Cache cache : caches.values()) cache.stop();
+      // make sure we stop the default cache LAST!
+      Cache defaultCache = null;
+      for (Map.Entry<String, Cache> entry : caches.entrySet())
+      {
+         if (entry.getKey().equals(DEFAULT_CACHE_NAME))
+         {
+            defaultCache = entry.getValue();
+         }
+         else
+         {
+            entry.getValue().stop();
+         }
+      }
+
+      if (defaultCache != null) defaultCache.stop();
    }
 }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -29,7 +29,13 @@
 import org.jboss.starobrno.CacheSPI;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.factories.annotations.*;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 import org.jboss.starobrno.notifications.annotation.*;
 import org.jboss.starobrno.notifications.event.*;
 import static org.jboss.starobrno.notifications.event.Event.Type.*;
@@ -42,7 +48,12 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ThreadFactory;
@@ -54,6 +65,7 @@
  * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
  */
 @NonVolatile
+ at Scope(Scopes.CACHE_ONLY)
 public class NotifierImpl implements Notifier
 {
    private static final Log log = LogFactory.getLog(NotifierImpl.class);

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -22,6 +22,8 @@
 package org.jboss.starobrno.remoting;
 
 import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.factories.scopes.Scope;
+import org.jboss.starobrno.factories.scopes.Scopes;
 import org.jgroups.Address;
 import org.jgroups.Channel;
 import org.jgroups.blocks.RspFilter;
@@ -43,6 +45,7 @@
  * @author Manik Surtani
  * @since 2.1.0
  */
+ at Scope(Scopes.CACHE_MANAGER_ONLY)
 public interface RPCManager
 {
    /**

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/ReflectionUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/ReflectionUtil.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/ReflectionUtil.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -170,4 +170,38 @@
          throw new CacheException("Cannot access field " + f, iae);
       }
    }
+
+   /**
+    * Inspects the class passed in for the class level annotation specified.  If the annotation is not available, this
+    * method recursively inspects superclasses and interfaces until it finds the required annotation.
+    * <p/>
+    * Returns null if the annotation cannot be found.
+    *
+    * @param clazz class to inspect
+    * @param ann   annotation to search for.  Must be a class-level annotation.
+    * @return the annotation instance, or null
+    */
+   @SuppressWarnings("unchecked")
+   public static <T extends Annotation> T getAnnotation(Class clazz, Class<T> ann)
+   {
+      // first check class
+      T a = (T) clazz.getAnnotation(ann);
+      if (a != null) return a;
+
+      // check interfaces
+      if (!clazz.isInterface())
+      {
+         Class[] interfaces = clazz.getInterfaces();
+         for (Class inter : interfaces)
+         {
+            a = getAnnotation(inter, ann);
+            if (a != null) return a;
+         }
+      }
+
+      // check superclasses
+      Class superclass = clazz.getSuperclass();
+      if (superclass == null) return null; // no where else to look
+      return getAnnotation(superclass, ann);
+   }
 }

Modified: core/branches/flat/src/main/resources/schema/starobrno-config-1.0.xsd
===================================================================
--- core/branches/flat/src/main/resources/schema/starobrno-config-1.0.xsd	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/main/resources/schema/starobrno-config-1.0.xsd	2009-01-14 17:00:40 UTC (rev 7474)
@@ -3,10 +3,46 @@
            xmlns:tns="urn:jboss:starobrno-core:config:1.0" targetNamespace="urn:jboss:starobrno-core:config:1.0"
            xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
 
-    <xs:element name="jbosscache" type="tns:cacheConfigurationType"/>
+    <xs:element name="jbosscache" type="tns:cacheManagerConfigurationType"/>
 
-    <xs:complexType name="cacheConfigurationType">
+    <xs:complexType name="cacheManagerConfigurationType">
+        <xs:sequence>
+            <xs:element name="global" type="tns:globalCacheConfigurationType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="default" type="tns:defaultCacheConfigurationType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="namedCache" type="tns:namedCacheConfigurationType" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="globalCacheConfigurationType">
         <xs:all>
+            <xs:element name="serialization" type="tns:sharedSerializationType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="jgroupsConfig" type="tns:jgroupsConfigType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="asyncListenerExecutor" type="tns:executorConfigurationType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="asyncSerializationExecutor" type="tns:executorConfigurationType" minOccurs="0"
+                        maxOccurs="1"/>
+            <xs:element name="evictionScheduledExecutor" type="tns:executorConfigurationType" minOccurs="0"
+                        maxOccurs="1"/>
+            <xs:element name="replicationQueueScheduledExecutor" type="tns:executorConfigurationType" minOccurs="0"
+                        maxOccurs="1"/>
+        </xs:all>
+    </xs:complexType>
+
+    <xs:complexType name="sharedSerializationType">
+        <xs:attribute name="objectInputStreamPoolSize" type="tns:positiveInteger"/>
+        <xs:attribute name="objectOutputStreamPoolSize" type="tns:positiveInteger"/>
+        <xs:attribute name="version" type="xs:string"/>
+        <xs:attribute name="marshallerClass" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:complexType name="executorConfigurationType">
+        <xs:sequence>
+            <xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="tns:propertyType"/>
+        </xs:sequence>
+        <xs:attribute name="factory" type="xs:string"/>
+    </xs:complexType>
+
+    <xs:complexType name="defaultCacheConfigurationType">
+        <xs:all>
             <xs:element name="locking" type="tns:lockingType" minOccurs="0" maxOccurs="1"/>
             <xs:element name="transaction" type="tns:transactionType" minOccurs="0" maxOccurs="1"/>
             <xs:element name="startup" type="tns:startupType" minOccurs="0" maxOccurs="1"/>
@@ -22,6 +58,24 @@
         </xs:all>
     </xs:complexType>
 
+    <xs:complexType name="namedCacheConfigurationType">
+        <xs:all>
+            <xs:element name="locking" type="tns:lockingType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="transaction" type="tns:transactionType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="startup" type="tns:startupType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="shutdown" type="tns:shutdownType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="serialization" type="tns:serializationType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="jmxStatistics" type="tns:jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="listeners" type="tns:listenersType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="invocationBatching" type="tns:invocationBatchingType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="eviction" type="tns:evictionType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="loaders" type="tns:loadersType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="customInterceptors" type="tns:customInterceptorsType" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="clustering" type="tns:clusteringType" minOccurs="0" maxOccurs="1"/>
+        </xs:all>
+        <xs:attribute name="name" type="xs:string"/>
+    </xs:complexType>
+
     <xs:complexType name="clusteringType">
         <xs:all>
             <xs:element name="sync" type="tns:syncType" minOccurs="0" maxOccurs="1"/>
@@ -51,7 +105,6 @@
                     <xs:attribute name="communicationTimeout" type="xs:integer"/>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="jgroupsConfig" type="tns:jgroupsConfigType" minOccurs="0" maxOccurs="1"/>
         </xs:all>
         <xs:attribute name="mode">
             <xs:simpleType>
@@ -108,12 +161,7 @@
     </xs:complexType>
 
     <xs:complexType name="serializationType">
-        <xs:attribute name="objectInputStreamPoolSize" type="tns:positiveInteger"/>
-        <xs:attribute name="objectOutputStreamPoolSize" type="tns:positiveInteger"/>
-        <xs:attribute name="version" type="xs:string"/>
-        <xs:attribute name="marshallerClass" type="xs:string"/>
         <xs:attribute name="useLazyDeserialization" type="tns:booleanType"/>
-        <xs:attribute name="useRegionBasedMarshalling" type="tns:booleanType"/>
     </xs:complexType>
 
     <xs:simpleType name="booleanType">

Modified: core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -9,10 +9,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.parsing.XmlConfigurationParserJBC3;
+import org.jboss.starobrno.manager.CacheManager;
 import org.jboss.starobrno.util.TestingUtil;
 import org.jgroups.conf.XmlConfigurator;
 
@@ -149,7 +149,9 @@
             log.info("Unknown cache mode!");
       }
 
-      Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
+//      Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
+      CacheManager cm = new CacheManager(configuration);
+      Cache<K, V> cache = cm.getCache();
 
       List<Cache> caches = threadCaches.get();
       caches.add(cache);

Modified: core/branches/flat/src/test/java/org/jboss/starobrno/atomic/APITest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/atomic/APITest.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/atomic/APITest.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -21,9 +21,9 @@
  */
 package org.jboss.starobrno.atomic;
 
-import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.Configuration.CacheMode;
+import org.jboss.starobrno.manager.CacheManager;
 import org.jboss.starobrno.transaction.DummyTransactionManager;
 import org.jboss.starobrno.transaction.DummyTransactionManagerLookup;
 import org.jboss.starobrno.util.TestingUtil;
@@ -52,7 +52,7 @@
    {
       Configuration c = new Configuration();
       c.setInvocationBatchingEnabled(true);
-      AtomicMapCache cache = (AtomicMapCache) new DefaultCacheFactory().createCache(c);
+      AtomicMapCache cache = (AtomicMapCache) new CacheManager(c).getCache();
       try
       {
          AtomicMap map = cache.getAtomicMap("map");
@@ -82,7 +82,7 @@
       Configuration c = new Configuration();
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       c.setInvocationBatchingEnabled(true);
-      AtomicMapCache cache = (AtomicMapCache) new DefaultCacheFactory().createCache(c);
+      AtomicMapCache cache = (AtomicMapCache) new CacheManager(c).getCache();
       try
       {
          AtomicMap map = cache.getAtomicMap("map");
@@ -123,7 +123,7 @@
       Configuration c = new Configuration();
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       c.setInvocationBatchingEnabled(true);
-      AtomicMapCache cache = (AtomicMapCache) new DefaultCacheFactory().createCache(c);
+      AtomicMapCache cache = (AtomicMapCache) new CacheManager(c).getCache();
       try
       {
          AtomicMap map = cache.getAtomicMap("map");
@@ -161,7 +161,7 @@
       Configuration c = new Configuration();
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       c.setInvocationBatchingEnabled(true);
-      AtomicMapCache cache = (AtomicMapCache) new DefaultCacheFactory().createCache(c);
+      AtomicMapCache cache = (AtomicMapCache) new CacheManager(c).getCache();
       try
       {
          AtomicMap map = cache.getAtomicMap("map");
@@ -194,8 +194,8 @@
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       c.setCacheMode(CacheMode.REPL_SYNC);
       c.setInvocationBatchingEnabled(true);
-      AtomicMapCache cache1 = (AtomicMapCache) new DefaultCacheFactory().createCache(c.clone());
-      AtomicMapCache cache2 = (AtomicMapCache) new DefaultCacheFactory().createCache(c.clone());
+      AtomicMapCache cache1 = (AtomicMapCache) new CacheManager(c).getCache();
+      AtomicMapCache cache2 = (AtomicMapCache) new CacheManager(c).getCache();
 
       try
       {
@@ -229,8 +229,8 @@
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       c.setCacheMode(CacheMode.REPL_SYNC);
       c.setInvocationBatchingEnabled(true);
-      AtomicMapCache cache1 = (AtomicMapCache) new DefaultCacheFactory().createCache(c.clone());
-      AtomicMapCache cache2 = (AtomicMapCache) new DefaultCacheFactory().createCache(c.clone());
+      AtomicMapCache cache1 = (AtomicMapCache) new CacheManager(c).getCache();
+      AtomicMapCache cache2 = (AtomicMapCache) new CacheManager(c).getCache();
 
       try
       {

Added: core/branches/flat/src/test/java/org/jboss/starobrno/factories/scopes/ScopeDetectorTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/factories/scopes/ScopeDetectorTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/factories/scopes/ScopeDetectorTest.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,101 @@
+package org.jboss.starobrno.factories.scopes;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Manik Surtani
+ */
+ at Test(groups = "unit")
+public class ScopeDetectorTest
+{
+   public void testScopeOnClass()
+   {
+      testScopes(Test1.class, Scopes.CACHE_MANAGER_ONLY);
+
+   }
+
+   public void testScopeOnInterface()
+   {
+      testScopes(Test2.class, Scopes.CACHE_MANAGER_ONLY);
+   }
+
+   public void testScopeOnSuperClass()
+   {
+      testScopes(Test3.class, Scopes.CACHE_MANAGER_ONLY);
+   }
+
+   public void testScopeOnSuperInterface()
+   {
+      testScopes(Test4.class, Scopes.CACHE_MANAGER_ONLY);
+   }
+
+   public void testMultipleScopes()
+   {
+      testScopes(Test5.class, Scopes.EITHER);
+   }
+
+   public void testNoScopes()
+   {
+      testScopes(Test6.class, Scopes.CACHE_ONLY);
+   }
+
+   private void testScopes(Class clazz, Scopes expected)
+   {
+      Scopes detected = ScopeDetector.detectScope(clazz);
+      assert detected == expected : "Expected " + expected + " but was " + detected;
+   }
+
+   public static interface Unscoped
+   {
+
+   }
+
+   @Scope(Scopes.CACHE_MANAGER_ONLY)
+   public static interface Scoped
+   {
+
+   }
+
+   @Scope(Scopes.CACHE_MANAGER_ONLY)
+   public static class SuperScoped
+   {
+
+   }
+
+   public static class SuperUnScoped
+   {
+
+   }
+
+   @Scope(Scopes.CACHE_MANAGER_ONLY)
+   public static class Test1
+   {
+
+   }
+
+   public static class Test2 implements Scoped
+   {
+
+   }
+
+   public static class Test3 extends SuperScoped
+   {
+
+   }
+
+   public static class Test4 extends Test2
+   {
+
+   }
+
+   @Scope(Scopes.EITHER)
+   public static class Test5 implements Scoped
+   {
+
+   }
+
+   public static class Test6 extends SuperUnScoped implements Unscoped
+   {
+
+   }
+}

Added: core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerComponentRegistryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerComponentRegistryTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerComponentRegistryTest.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,102 @@
+package org.jboss.starobrno.manager;
+
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.interceptors.BatchingInterceptor;
+import org.jboss.starobrno.interceptors.InterceptorChain;
+import org.jboss.starobrno.loader.CacheLoaderManager;
+import org.jboss.starobrno.loader.FileCacheLoaderConfig;
+import org.jboss.starobrno.remoting.RPCManager;
+import org.jboss.starobrno.transaction.DummyTransactionManager;
+import org.jboss.starobrno.transaction.DummyTransactionManagerLookup;
+import org.jboss.starobrno.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author Manik Surtani
+ */
+ at Test(groups = "functional", sequential = true)
+public class CacheManagerComponentRegistryTest
+{
+   CacheManager cm;
+
+   @AfterMethod
+   public void tearDown()
+   {
+      if (cm != null) cm.stop();
+   }
+
+   public void testForceSharedComponents() throws CacheNameExistsException, NamedCacheNotFoundException
+   {
+      Configuration defaultCfg = new Configuration();
+      defaultCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+      // cache manager with default configuration
+      cm = new CacheManager(defaultCfg);
+
+      // default cache with no overrides
+      Cache c = cm.getCache();
+
+      Configuration overrides = new Configuration();
+      overrides.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      cm.defineCache("transactional", overrides);
+      Cache transactional = cm.getCache("transactional");
+
+      // assert components.
+      assert TestingUtil.extractComponent(c, TransactionManager.class) == null;
+      assert TestingUtil.extractComponent(transactional, TransactionManager.class) instanceof DummyTransactionManager;
+
+      // assert force-shared components
+      assert TestingUtil.extractComponent(c, RPCManager.class) != null;
+      assert TestingUtil.extractComponent(transactional, RPCManager.class) != null;
+      assert TestingUtil.extractComponent(c, RPCManager.class) == TestingUtil.extractComponent(transactional, RPCManager.class);
+   }
+
+   public void testForceUnsharedComponents() throws CacheNameExistsException, NamedCacheNotFoundException
+   {
+      CacheLoaderConfig clc = new CacheLoaderConfig();
+      FileCacheLoaderConfig fc = new FileCacheLoaderConfig();
+      fc.setLocation("/tmp");
+      clc.addIndividualCacheLoaderConfig(fc);
+
+      Configuration defaultCfg = new Configuration();
+      defaultCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+      defaultCfg.setCacheLoaderConfig(clc);
+      // cache manager with default configuration
+      cm = new CacheManager(defaultCfg);
+
+      // default cache with no overrides
+      Cache c = cm.getCache();
+
+      Configuration overrides = new Configuration();
+      overrides.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      cm.defineCache("transactional", overrides);
+      Cache transactional = cm.getCache("transactional");
+
+      // assert components.
+      assert TestingUtil.extractComponent(c, CacheLoaderManager.class) != null;
+      assert TestingUtil.extractComponent(transactional, CacheLoaderManager.class) != null;
+      assert TestingUtil.extractComponent(c, CacheLoaderManager.class) != TestingUtil.extractComponent(transactional, CacheLoaderManager.class);
+   }
+
+   public void testOverridingComponents() throws CacheNameExistsException, NamedCacheNotFoundException
+   {
+      Configuration defaultCfg = new Configuration();
+      cm = new CacheManager(defaultCfg);
+
+      // default cache with no overrides
+      Cache c = cm.getCache();
+
+      Configuration overrides = new Configuration();
+      overrides.setInvocationBatchingEnabled(true);
+      cm.defineCache("overridden", overrides);
+      Cache overridden = cm.getCache("overridden");
+
+      // assert components.
+      assert !TestingUtil.extractComponent(c, InterceptorChain.class).containsInterceptorType(BatchingInterceptor.class);
+      assert TestingUtil.extractComponent(overridden, InterceptorChain.class).containsInterceptorType(BatchingInterceptor.class);
+   }
+}

Added: core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerTest.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,68 @@
+package org.jboss.starobrno.manager;
+
+import org.jboss.cache.CacheStatus;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.config.Configuration;
+import org.testng.annotations.Test;
+
+/**
+ * @author Manik Surtani
+ */
+ at Test(groups = "functional")
+public class CacheManagerTest
+{
+   public void testDefaultCache() throws CacheNameExistsException
+   {
+      CacheManager cm = new CacheManager();
+
+      assert cm.getCache().getCacheStatus() == CacheStatus.STARTED;
+      assert cm.getCache().getName().equals(CacheManager.DEFAULT_CACHE_NAME);
+
+      try
+      {
+         cm.defineCache(CacheManager.DEFAULT_CACHE_NAME, new Configuration());
+         assert false : "Should fail";
+      }
+      catch (IllegalArgumentException e)
+      {
+         // ok
+         assert true : "Allowed";
+      }
+   }
+
+   public void testClashingNames() throws CacheNameExistsException
+   {
+      CacheManager cm = new CacheManager();
+      Configuration c = new Configuration();
+
+      cm.defineCache("aCache", c);
+      try
+      {
+         cm.defineCache("aCache", c);
+         assert false : "Should fail";
+      }
+      catch (CacheNameExistsException cnee)
+      {
+         // expected
+         assert true : "Expected";
+      }
+   }
+
+   public void testStartAndStop()
+   {
+      CacheManager cm = new CacheManager();
+      Cache c1 = cm.getCache("cache1");
+      Cache c2 = cm.getCache("cache2");
+      Cache c3 = cm.getCache("cache3");
+
+      assert c1.getCacheStatus() == CacheStatus.STARTED;
+      assert c2.getCacheStatus() == CacheStatus.STARTED;
+      assert c3.getCacheStatus() == CacheStatus.STARTED;
+
+      cm.stop();
+
+      assert c1.getCacheStatus() == CacheStatus.STOPPED;
+      assert c2.getCacheStatus() == CacheStatus.STOPPED;
+      assert c3.getCacheStatus() == CacheStatus.STOPPED;
+   }
+}

Added: core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerXmlConfigurationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerXmlConfigurationTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/manager/CacheManagerXmlConfigurationTest.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,157 @@
+package org.jboss.starobrno.manager;
+
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+/**
+ * @author Manik Surtani
+ */
+ at Test(groups = "functional", sequential = true)
+public class CacheManagerXmlConfigurationTest
+{
+   CacheManager cm;
+
+   @AfterMethod
+   public void tearDown()
+   {
+      if (cm != null) cm.stop();
+   }
+
+   public void testNamedCacheXML() throws IOException
+   {
+      String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+            "<jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:jboss:starobrno-core:config:1.0\">\n" +
+            "\n" +
+            "    <default>\n" +
+            "        <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" +
+            "    </default>\n" +
+            "\n" +
+            "    <namedCache name=\"transactional\">\n" +
+            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
+            "    </namedCache>\n" +
+            "\n" +
+            "    <namedCache name=\"syncRepl\">\n" +
+            "        <clustering>\n" +
+            "            <stateRetrieval fetchInMemoryState=\"true\" timeout=\"15000\"/>\n" +
+            "            <jgroupsConfig configFile=\"udp.xml\"/>\n" +
+            "            <sync replTimeout=\"15000\"/>\n" +
+            "        </clustering>\n" +
+            "    </namedCache>\n" +
+            "\n" +
+            "    <namedCache name=\"txSyncRepl\">\n" +
+            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
+            "        <clustering>\n" +
+            "            <stateRetrieval fetchInMemoryState=\"true\" timeout=\"15000\"/>\n" +
+            "            <jgroupsConfig configFile=\"udp.xml\"/>\n" +
+            "            <sync replTimeout=\"15000\"/>\n" +
+            "        </clustering>\n" +
+            "    </namedCache>\n" +
+            "    \n" +
+            "</jbosscache>";
+
+      ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
+      cm = new CacheManager(bais);
+
+      // test default cache
+      Cache c = cm.getCache();
+      assert c.getConfiguration().getConcurrencyLevel() == 100;
+      assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
+      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() == null;
+      assert c.getConfiguration().getRuntimeConfig().getRPCManager() == null;
+
+      // test the "transactional" cache
+      c = cm.getCache("transactional");
+      assert c.getConfiguration().getConcurrencyLevel() == 100;
+      assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
+      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() != null;
+      assert c.getConfiguration().getRuntimeConfig().getRPCManager() == null;
+
+      // test the "replicated" cache
+      c = cm.getCache("syncRepl");
+      assert c.getConfiguration().getConcurrencyLevel() == 100;
+      assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
+      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() == null;
+      assert c.getConfiguration().getRuntimeConfig().getRPCManager() != null;
+
+      // test the "txSyncRepl" cache
+      c = cm.getCache("txSyncRepl");
+      assert c.getConfiguration().getConcurrencyLevel() == 100;
+      assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
+      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() != null;
+      assert c.getConfiguration().getRuntimeConfig().getRPCManager() != null;
+   }
+
+   public void testNamedCacheXMLClashingNames() throws IOException
+   {
+      String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+            "<jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:jboss:starobrno-core:config:1.0\">\n" +
+            "\n" +
+            "    <default>\n" +
+            "        <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" +
+            "    </default>\n" +
+            "\n" +
+            "    <namedCache name=\"c1\">\n" +
+            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
+            "    </namedCache>\n" +
+            "\n" +
+            "    <namedCache name=\"c1\">\n" +
+            "        <clustering>\n" +
+            "            <stateRetrieval fetchInMemoryState=\"true\" timeout=\"15000\"/>\n" +
+            "            <jgroupsConfig configFile=\"udp.xml\"/>\n" +
+            "            <sync replTimeout=\"15000\"/>\n" +
+            "        </clustering>\n" +
+            "    </namedCache>\n" +
+            "    \n" +
+            "</jbosscache>";
+
+      ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
+      try
+      {
+         cm = new CacheManager(bais);
+         assert false : "Should fail";
+      }
+      catch (ConfigurationException expected)
+      {
+
+      }
+   }
+
+   public void testNamedCacheXMLClashingNamesProgrammatic() throws IOException
+   {
+      String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+            "<jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:jboss:starobrno-core:config:1.0\">\n" +
+            "\n" +
+            "    <default>\n" +
+            "        <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" +
+            "    </default>\n" +
+            "\n" +
+            "    <namedCache name=\"c1\">\n" +
+            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
+            "    </namedCache>\n" +
+            "\n" +
+            "</jbosscache>";
+
+      ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
+      cm = new CacheManager(bais);
+
+      assert cm.getCache() != null;
+      assert cm.getCache("c1") != null;
+      try
+      {
+         cm.defineCache("c1", new Configuration());
+         assert false : "Should fail";
+      }
+      catch (CacheNameExistsException expected)
+      {
+
+      }
+   }
+}
+
+

Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/MemConsumptionTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/MemConsumptionTest.java	2009-01-14 16:55:34 UTC (rev 7473)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/MemConsumptionTest.java	2009-01-14 17:00:40 UTC (rev 7474)
@@ -21,9 +21,9 @@
  */
 package org.jboss.starobrno.profiling;
 
-import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.starobrno.Cache;
 import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.manager.CacheManager;
 import org.jboss.starobrno.util.TestingUtil;
 import org.testng.annotations.Test;
 
@@ -55,8 +55,7 @@
       int kBytesCached = (bytesPerCharacter * numEntries * (payloadSize + keySize)) / 1024;
       System.out.println("Bytes to be cached: " + NumberFormat.getIntegerInstance().format(kBytesCached) + " kb");
 
-//      Cache c = new UnitTestCacheFactory().createCache(false); // default LOCAL cache
-      Cache c = new DefaultCacheFactory().createCache();
+      Cache c = new CacheManager().getCache();
       for (int i = 0; i < numEntries; i++)
       {
          switch (payloadType)

Copied: core/branches/flat/src/test/resources/configs/named-cache-test.xml (from rev 7331, core/branches/flat/src/test/resources/configs/replSync.xml)
===================================================================
--- core/branches/flat/src/test/resources/configs/named-cache-test.xml	                        (rev 0)
+++ core/branches/flat/src/test/resources/configs/named-cache-test.xml	2009-01-14 17:00:40 UTC (rev 7474)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:starobrno-core:config:1.0">
+
+    <global>
+
+        <asyncListenerExecutor factory="org.jboss.starobrno.executors.DefaultExecutorFactory">
+            <property name="maxThreads">5</property>
+            <property name="threadNamePrefix">AsyncListenerThread</property>
+        </asyncListenerExecutor>
+
+        <asyncSerializationExecutor factory="org.jboss.starobrno.executors.DefaultExecutorFactory">
+            <property name="maxThreads">25</property>
+            <property name="threadNamePrefix">AsyncSerializationThread</property>
+        </asyncSerializationExecutor>
+
+        <evictionScheduledExecutor factory="org.jboss.starobrno.executors.DefaultScheduledExecutorFactory">
+            <property name="threadNamePrefix">EvictionThread</property>
+        </evictionScheduledExecutor>
+
+        <replicationQueueScheduledExecutor factory="org.jboss.starobrno.executors.DefaultScheduledExecutorFactory">
+            <property name="threadNamePrefix">ReplicationQueueThread</property>
+        </replicationQueueScheduledExecutor>
+
+        <jgroupsConfig configFile="udp.xml"/>
+
+        <serialization marshallerClass="org.jboss.starobrno.marshall.CacheMarshallerStarobrno" version="1.0"
+                       objectInputStreamPoolSize="100" objectOutputStreamPoolSize="100"/>
+
+    </global>
+
+    <default>
+        <locking concurrencyLevel="100" lockAcquisitionTimeout="1000"/>
+    </default>
+
+    <namedCache name="transactional">
+        <transaction transactionManagerLookupClass="org.jboss.starobrno.transaction.GenericTransactionManagerLookup"/>
+    </namedCache>
+
+    <namedCache name="syncRepl">
+
+        <clustering>
+            <stateRetrieval fetchInMemoryState="true" timeout="15000"/>
+            <sync replTimeout="15000"/>
+        </clustering>
+    </namedCache>
+
+    <namedCache name="txSyncRepl">
+        <transaction transactionManagerLookupClass="org.jboss.starobrno.transaction.GenericTransactionManagerLookup"/>
+        <clustering>
+            <stateRetrieval fetchInMemoryState="true" timeout="15000"/>
+            <sync replTimeout="15000"/>
+        </clustering>
+    </namedCache>
+
+</jbosscache>


Property changes on: core/branches/flat/src/test/resources/configs/named-cache-test.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF




More information about the jbosscache-commits mailing list