[jbosscache-commits] JBoss Cache SVN: r4834 - in core/trunk/src/main/java/org/jboss/cache: buddyreplication and 12 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Dec 11 12:28:33 EST 2007


Author: manik.surtani at jboss.com
Date: 2007-12-11 12:28:33 -0500 (Tue, 11 Dec 2007)
New Revision: 4834

Added:
   core/trunk/src/main/java/org/jboss/cache/factories/jgroups/
Modified:
   core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java
   core/trunk/src/main/java/org/jboss/cache/FqnComparator.java
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
   core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
   core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java
   core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java
   core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
   core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java
   core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java
   core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
   core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java
   core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java
   core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java
   core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java
   core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
   core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
   core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java
   core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
   core/trunk/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
   core/trunk/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
   core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
   core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
   core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java
   core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
   core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
   core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java
   core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallFactory.java
   core/trunk/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java
   core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
   core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
   core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
   core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
   core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java
   core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java
   core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManager.java
   core/trunk/src/main/java/org/jboss/cache/transaction/DummyContextFactory.java
   core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java
   core/trunk/src/main/java/org/jboss/cache/transaction/JBossTransactionManagerLookup.java
   core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
Log:
Initial check in of injection and aop code

Modified: core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -16,20 +16,20 @@
 
 package org.jboss.cache;
 
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationRegistry;
+import org.jboss.cache.config.XmlParsingConfigurationRegistry;
+import org.jgroups.ChannelFactory;
+
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationRegistry;
-import org.jboss.cache.config.XmlParsingConfigurationRegistry;
-import org.jgroups.ChannelFactory;
-
 /**
  * Basic implementation of {@link CacheManager}.
- * 
+ *
  * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
  * @version $Revision: 1 $
  */
@@ -66,8 +66,8 @@
    }
 
    /**
-    * Create a new CacheRegistryImpl using the provided ChannelFactory and 
-    * using the provided file name to create an 
+    * Create a new CacheRegistryImpl using the provided ChannelFactory and
+    * using the provided file name to create an
     * {@link XmlParsingConfigurationRegistry}.
     */
    public CacheManagerImpl(String configFileName, ChannelFactory factory)
@@ -77,7 +77,7 @@
    }
 
    // ----------------------------------------------------------  CacheRegistry
-   
+
    public ChannelFactory getChannelFactory()
    {
       return channelFactory;
@@ -88,8 +88,8 @@
    {
       synchronized (caches)
       {
-         Set<String> configNames = configRegistry == null ? new HashSet<String>() 
-                                                          : configRegistry.getConfigurationNames();
+         Set<String> configNames = configRegistry == null ? new HashSet<String>()
+               : configRegistry.getConfigurationNames();
          configNames.addAll(getCacheNames());
          return configNames;
       }
@@ -108,11 +108,12 @@
       Cache<Object, Object> cache = null;
       synchronized (caches)
       {
-         cache = (Cache<Object, Object>) caches.get(configName);
+         cache = caches.get(configName);
          if (cache == null && create)
          {
             Configuration config = configRegistry.getConfiguration(configName);
-            if (channelFactory != null && config.getMultiplexerStack() != null) {
+            if (channelFactory != null && config.getMultiplexerStack() != null)
+            {
                config.getRuntimeConfig().setMuxChannelFactory(channelFactory);
             }
             cache = DefaultCacheFactory.getInstance().createCache(config, false);
@@ -142,7 +143,7 @@
    }
 
    // -----------------------------------------------------------------  Public
-   
+
    public ConfigurationRegistry getConfigurationRegistry()
    {
       return configRegistry;
@@ -178,12 +179,12 @@
             throw new IllegalStateException("Must configure a ConfigurationRegistry before calling start()");
          if (channelFactory == null)
             throw new IllegalStateException("Must provide a ChannelFactory before calling start()");
-         
+
          if (!configRegistryInjected)
          {
             ((XmlParsingConfigurationRegistry) configRegistry).start();
          }
-         
+
          started = true;
       }
    }
@@ -203,23 +204,23 @@
             caches.clear();
             checkouts.clear();
          }
-         
+
          if (!configRegistryInjected)
          {
             ((XmlParsingConfigurationRegistry) configRegistry).stop();
          }
-         
+
          started = false;
       }
    }
 
    // ----------------------------------------------------------------  Private
-   
+
    private int incrementCheckout(String configName)
    {
       synchronized (checkouts)
       {
-         Integer count = (Integer) checkouts.get(configName);
+         Integer count = checkouts.get(configName);
          if (count == null)
             count = new Integer(0);
          Integer newVal = new Integer(count.intValue() + 1);
@@ -232,7 +233,7 @@
    {
       synchronized (checkouts)
       {
-         Integer count = (Integer) checkouts.get(configName);
+         Integer count = checkouts.get(configName);
          if (count == null || count.intValue() < 1)
             throw new IllegalStateException("invalid count of " + count + " for " + configName);
 

Modified: core/trunk/src/main/java/org/jboss/cache/FqnComparator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/FqnComparator.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/FqnComparator.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -28,13 +28,6 @@
    public static final FqnComparator INSTANCE = new FqnComparator();
 
    /**
-    * Sorts by name, then depth.
-    */
-   public FqnComparator()
-   {
-   }
-
-   /**
     * Returns -1 if the first comes before; 0 if they are the same; 1 if the
     * second Fqn comes before.  <code>null</code> always comes first.
     */

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -61,7 +61,8 @@
    /**
     * A reference of the CacheImpl instance.
     */
-   private transient CacheImpl<K, V> cache;
+   private transient CacheSPI<K, V> cache;
+   private transient CacheImpl cacheImpl;
 
    /**
     * Map of general data keys to values.
@@ -105,7 +106,7 @@
       {
          throw new IllegalArgumentException("no cache init for " + fqn);
       }
-      this.cache = (CacheImpl<K, V>) cache;
+      this.cache = cache;
       this.fqn = fqn;
       if (!fqn.isRoot() && !child_name.equals(fqn.getLastElement()))
       {
@@ -166,7 +167,8 @@
       childrenLoaded = flag;
    }
 
-   private void assertValid() {
+   private void assertValid()
+   {
       if (!valid)
          throw new NodeNotValidException("Node " + getFqn() + " is not valid.  Perhaps it has been moved or removed.");
    }
@@ -201,9 +203,11 @@
 
    public Map<K, V> getData()
    {
-      assertValid();
-      if (cache == null) return Collections.emptyMap();
-      return cache.getData(getFqn());
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+//      assertValid();
+//      if (cache == null) return Collections.emptyMap();
+//      return cache.getData(getFqn());
    }
 
    public Map<K, V> getDataDirect()
@@ -261,9 +265,9 @@
                children.put(child_name, child);
                if (gtx != null)
                {
-                  MethodCall undo_op = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, gtx,
-                                                                child_fqn, false);
-                  cache.addUndoOperation(gtx, undo_op);
+                  MethodCall undo_op = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal,
+                        gtx, child_fqn, false);
+                  cacheImpl.addUndoOperation(gtx, undo_op);
                   // add the node name to the list maintained for the current tx
                   // (needed for abort/rollback of transaction)
                   // cache.addNode(gtx, child.getFqn());
@@ -383,8 +387,11 @@
 
    public void clearData()
    {
-      assertValid();
-      cache.removeData(getFqn());
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+
+//      assertValid();
+//      cache.removeData(getFqn());
    }
 
    public void clearDataDirect()
@@ -394,8 +401,11 @@
 
    public Node<K, V> getChild(Fqn fqn)
    {
-      assertValid();
-      return cache.get(new Fqn(getFqn(), fqn));
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+//
+//      assertValid();
+//      return cache.get(new Fqn(getFqn(), fqn));
    }
 
    public NodeSPI<K, V> getChildDirect(Fqn fqn)
@@ -419,8 +429,11 @@
 
    public Set<Object> getChildrenNames()
    {
-      assertValid();
-      return cache.getChildrenNames(getFqn());
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+
+//      assertValid();
+//      return cache.getChildrenNames(getFqn());
    }
 
    public Set<Object> getChildrenNamesDirect()
@@ -430,9 +443,12 @@
 
    public Set<K> getKeys()
    {
-      assertValid();
-      Set<K> keys = cache.getKeys(getFqn());
-      return keys == null ? Collections.<K>emptySet() : Collections.<K>unmodifiableSet(keys);
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+
+//      assertValid();
+//      Set<K> keys = cache.getKeys(getFqn());
+//      return keys == null ? Collections.<K>emptySet() : Collections.<K>unmodifiableSet(keys);
    }
 
    public Set<K> getKeysDirect()
@@ -508,8 +524,11 @@
 
    public int dataSize()
    {
-      assertValid();
-      return cache.getKeys(getFqn()).size();
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+//
+//      assertValid();
+//      return cache.getKeys(getFqn()).size();
    }
 
    public boolean removeChild(Object childName)
@@ -555,8 +574,11 @@
 
    public void replaceAll(Map<K, V> data)
    {
-      assertValid();
-      cache.put(fqn, data, true);
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+
+//      assertValid();
+//      cache.put(fqn, data, true);
    }
 
    public void putAllDirect(Map<K, V> data)
@@ -659,7 +681,10 @@
 
    public Node<K, V> getChild(Object childName)
    {
-      return cache.get(new Fqn(getFqn(), childName));
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+//
+//      return cache.get(new Fqn(getFqn(), childName));
    }
 
    public NodeSPI<K, V> getChildDirect(Object childName)
@@ -670,15 +695,18 @@
 
    public Set<Node<K, V>> getChildren()
    {
-      assertValid();
-      if (cache == null) return Collections.emptySet();
-      Set<Node<K, V>> children = new HashSet<Node<K, V>>();
-      for (Object c : cache.getChildrenNames(getFqn()))
-      {
-         Node n = cache.get(new Fqn(getFqn(), c));
-         if (n != null) children.add(n);
-      }
-      return Collections.unmodifiableSet(children);
+      // TODO: Fix this
+      throw new RuntimeException("Should never get here - use NodeInterceptorDelegate!");
+
+//      assertValid();
+//      if (cache == null) return Collections.emptySet();
+//      Set<Node<K, V>> children = new HashSet<Node<K, V>>();
+//      for (Object c : cache.getChildrenNames(getFqn()))
+//      {
+//         Node n = cache.get(new Fqn(getFqn(), c));
+//         if (n != null) children.add(n);
+//      }
+//      return Collections.unmodifiableSet(children);
    }
 
    public Set<NodeSPI<K, V>> getChildrenDirect()
@@ -770,7 +798,7 @@
       if (log.isTraceEnabled()) log.trace("Marking node " + getFqn() + " as " + (valid ? "" : "in") + "valid");
       if (recursive)
       {
-         for (Node child: children().values())
+         for (Node child : children().values())
          {
             ((UnversionedNode) child).setValid(valid, recursive);
          }

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -9,11 +9,15 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
+import org.jboss.cache.RPCManager;
 import org.jboss.cache.Region;
+import org.jboss.cache.RegionManager;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.lock.TimeoutException;
 import org.jboss.cache.marshall.MethodCall;
 import org.jboss.cache.marshall.MethodCallFactory;
@@ -32,16 +36,7 @@
 import org.jgroups.util.Util;
 
 import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
+import java.util.*;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CountDownLatch;
@@ -60,7 +55,7 @@
    /**
     * Configuration object.
     */
-   final BuddyReplicationConfig config;
+   BuddyReplicationConfig config;
 
    /**
     * Buddy locator class
@@ -70,8 +65,11 @@
    /**
     * back-refernce to the CacheImpl object
     */
-   private CacheImpl<?,?> cache;
-
+   private CacheSPI<?, ?> cache;
+   private Configuration configuration;
+   private RegionManager regionManager;
+   private StateTransferManager stateTransferManager;
+   private RPCManager rpcManager;
    /**
     * The buddy group set up for this instance
     */
@@ -133,8 +131,18 @@
 
    private boolean receivedBuddyInfo;
 
+   public BuddyManager()
+   {
+   }
+
    public BuddyManager(BuddyReplicationConfig config)
    {
+      setupInternals(config);
+   }
+
+
+   private void setupInternals(BuddyReplicationConfig config)
+   {
       this.config = config;
 
       BuddyLocatorConfig blc = config.getBuddyLocatorConfig();
@@ -157,6 +165,18 @@
       }
    }
 
+   @Inject
+   private void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager, StateTransferManager stateTransferManager, RPCManager rpcManager)
+   {
+      this.cache = cache;
+      this.configuration = configuration;
+      this.regionManager = regionManager;
+      this.stateTransferManager = stateTransferManager;
+      this.rpcManager = rpcManager;
+
+      setupInternals(configuration.getBuddyReplicationConfig());
+   }
+
    public BuddyReplicationConfig getConfig()
    {
       return config;
@@ -210,10 +230,9 @@
       }
    }
 
-   public void init(CacheImpl<?, ?> cache) throws CacheException
+   public void init() throws CacheException
    {
       log.debug("Starting buddy manager");
-      this.cache = cache;
       buddyGroup = new BuddyGroup();
       buddyGroup.setDataOwner(cache.getLocalAddress());
       buddyGroup.setGroupName(getGroupNameFromAddress(cache.getLocalAddress()));
@@ -367,7 +386,7 @@
       if (buddyGroupMutated)
       {
          if (log.isInfoEnabled()) log.info("Buddy group members have changed. New buddy group: " + buddyGroup);
-         cache.getConfiguration().getRuntimeConfig().setBuddyGroup(buddyGroup);
+         configuration.getRuntimeConfig().setBuddyGroup(buddyGroup);
       }
       else
          log.debug("Nothing has changed; new buddy list is identical to the old one.");
@@ -382,7 +401,7 @@
     */
    private List<Address> checkBuddyStatus(List<Address> members)
    {
-      Channel ch = cache.getConfiguration().getRuntimeConfig().getChannel();
+      Channel ch = configuration.getRuntimeConfig().getChannel();
       View currentView = ch.getView();
       List<Address> deadBuddies = new LinkedList<Address>();
       for (Address a : members) if (!currentView.containsMember(a)) deadBuddies.add(a);
@@ -449,7 +468,7 @@
          // should be a LOCAL call.
          cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
 
-         cache.remove(new Fqn(BUDDY_BACKUP_SUBTREE_FQN, groupName));
+         cache.removeNode(new Fqn(BUDDY_BACKUP_SUBTREE_FQN, groupName));
       }
       catch (CacheException e)
       {
@@ -475,7 +494,8 @@
       {
          if (!initialisationLatch.await(0, TimeUnit.NANOSECONDS))
          {
-            if (log.isDebugEnabled()) log.debug("Local buddy mamanger not initialized, rejecting assign call " + newGroup);
+            if (log.isDebugEnabled())
+               log.debug("Local buddy mamanger not initialized, rejecting assign call " + newGroup);
             throw new BuddyNotInitException("Not yet initialised");
          }
       }
@@ -489,14 +509,12 @@
 
       // Integrate state transfer from the data owner of the buddy group
       Fqn integrationBase = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
-              newGroup.getGroupName());
+            newGroup.getGroupName());
 
-      StateTransferManager stateMgr = cache.getStateTransferManager();
-
       for (Map.Entry<Fqn, byte[]> entry : state.entrySet())
       {
          Fqn fqn = entry.getKey();
-         if (!cache.getRegionManager().isInactive(fqn))
+         if (!regionManager.isInactive(fqn))
          {
             //ClassLoader cl = (marshaller == null) ? null : marshaller.getClassLoader(fqnS);
             Fqn integrationRoot = new Fqn(integrationBase, fqn);
@@ -508,22 +526,22 @@
                ByteArrayInputStream bais = new ByteArrayInputStream(stateBuffer);
                in = new MarshalledValueInputStream(bais);
                //stateMgr.setState(in, integrationRoot, cl);
-               stateMgr.setState(in, integrationRoot);
+               stateTransferManager.setState(in, integrationRoot);
             }
             catch (Throwable t)
             {
-            	if (t instanceof CacheException)
-                {
-            		//excepected/common and can happen due to inactive regions and so on
-            		log.debug(t);
-                }
-            	else
-            	{
-            		//something has gone wrong
-            		log.error("State for fqn " + fqn
-									+ " could not be transferred to a buddy at "
-									+ cache.getLocalAddress(), t);
-            	}
+               if (t instanceof CacheException)
+               {
+                  //excepected/common and can happen due to inactive regions and so on
+                  log.debug(t);
+               }
+               else
+               {
+                  //something has gone wrong
+                  log.error("State for fqn " + fqn
+                        + " could not be transferred to a buddy at "
+                        + cache.getLocalAddress(), t);
+               }
             }
             finally
             {
@@ -535,7 +553,7 @@
          }
       }
    }
-   
+
    /**
     * Returns a List<IpAddress> identifying the DataOwner for each buddy
     * group for which this node serves as a backup node.
@@ -549,8 +567,6 @@
       }
       return owners;
    }
-   
-   
 
    // -------------- static util methods ------------------
 
@@ -724,9 +740,9 @@
 
       Map<Fqn, byte[]> stateMap = new HashMap<Fqn, byte[]>();
       byte[] state;
-      if (cache.getConfiguration().isUseRegionBasedMarshalling())
+      if (configuration.isUseRegionBasedMarshalling())
       {
-         Collection<Region> regions = cache.getRegionManager().getAllRegions(Region.Type.MARSHALLING);
+         Collection<Region> regions = regionManager.getAllRegions(Region.Type.MARSHALLING);
          if (regions.size() > 0)
          {
             for (Region r : regions)
@@ -739,7 +755,7 @@
                }
             }
          }
-         else if (!cache.getConfiguration().isInactiveOnStartup())
+         else if (!configuration.isInactiveOnStartup())
          {
             // No regions defined; try the root
             state = acquireState(Fqn.ROOT);
@@ -852,7 +868,7 @@
       if (timeoutException != null)
       {
          throw new CacheException("acquireState(): Failed getting state due to timeout",
-                 timeoutException);
+               timeoutException);
       }
 
       if (log.isDebugEnabled())
@@ -891,7 +907,7 @@
       {
          ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
          out = new MarshalledValueOutputStream(baos);
-         cache.getStateTransferManager().getState(out, fqn, timeout, force, suppressErrors);
+         stateTransferManager.getState(out, fqn, timeout, force, suppressErrors);
          result = baos.getRawBuffer();
       }
       finally
@@ -948,7 +964,7 @@
          }
       }
 
-      cache.getRPCManager().callRemoteMethods(recipients, call, sync, true, config.getBuddyCommunicationTimeout());
+      rpcManager.callRemoteMethods(recipients, call, sync, true, config.getBuddyCommunicationTimeout());
    }
 
 

Modified: core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -47,10 +47,6 @@
    private int buddyCommunicationTimeout = 10000;
    private BuddyLocatorConfig buddyLocatorConfig;
 
-   public BuddyReplicationConfig()
-   {
-   }
-
    public boolean isAutoDataGravitation()
    {
       return autoDataGravitation;
@@ -138,12 +134,12 @@
       {
          BuddyReplicationConfig other = (BuddyReplicationConfig) obj;
          return (this.autoDataGravitation == other.autoDataGravitation)
-                 && (this.dataGravitationRemoveOnFind == other.dataGravitationRemoveOnFind)
-                 && (this.dataGravitationSearchBackupTrees == other.dataGravitationSearchBackupTrees)
-                 && (this.enabled == other.enabled)
-                 && (this.buddyCommunicationTimeout == other.buddyCommunicationTimeout)
-                 && safeEquals(this.buddyPoolName, other.buddyPoolName)
-                 && safeEquals(this.buddyLocatorConfig, other.buddyLocatorConfig);
+               && (this.dataGravitationRemoveOnFind == other.dataGravitationRemoveOnFind)
+               && (this.dataGravitationSearchBackupTrees == other.dataGravitationSearchBackupTrees)
+               && (this.enabled == other.enabled)
+               && (this.buddyCommunicationTimeout == other.buddyCommunicationTimeout)
+               && safeEquals(this.buddyPoolName, other.buddyPoolName)
+               && safeEquals(this.buddyLocatorConfig, other.buddyLocatorConfig);
       }
 
       return false;
@@ -166,7 +162,7 @@
    public BuddyReplicationConfig clone() throws CloneNotSupportedException
    {
       BuddyReplicationConfig clone = (BuddyReplicationConfig) super.clone();
-      if (buddyLocatorConfig != null) 
+      if (buddyLocatorConfig != null)
          clone.setBuddyLocatorConfig(buddyLocatorConfig.clone());
       return clone;
    }
@@ -176,13 +172,8 @@
       private static final long serialVersionUID = -8003634097931826091L;
 
       private String buddyLocatorClass = NextMemberBuddyLocator.class.getName();
-      ;
       private Properties buddyLocatorProperties;
 
-      public BuddyLocatorConfig()
-      {
-      }
-
       public String getBuddyLocatorClass()
       {
          return buddyLocatorClass;
@@ -216,7 +207,7 @@
          {
             BuddyLocatorConfig other = (BuddyLocatorConfig) obj;
             return (safeEquals(this.buddyLocatorClass, other.buddyLocatorClass)
-                    && safeEquals(this.buddyLocatorProperties, other.buddyLocatorProperties));
+                  && safeEquals(this.buddyLocatorProperties, other.buddyLocatorProperties));
          }
          return false;
       }
@@ -232,7 +223,7 @@
       public String toString()
       {
          return super.toString() + " class=" + buddyLocatorClass +
-                 " properties=" + buddyLocatorProperties;
+               " properties=" + buddyLocatorProperties;
       }
 
       @Override
@@ -243,8 +234,7 @@
             clone.buddyLocatorProperties = (Properties) buddyLocatorProperties.clone();
          return clone;
       }
-      
-      
 
+
    }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,8 +6,8 @@
  */
 package org.jboss.cache.config;
 
-import org.jboss.cache.xml.XmlHelper;
 import org.jboss.cache.loader.SingletonStoreCacheLoader;
+import org.jboss.cache.xml.XmlHelper;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -33,10 +33,6 @@
 
    private boolean shared;
 
-   public CacheLoaderConfig()
-   {
-   }
-
    public String getPreload()
    {
       return preload;
@@ -117,9 +113,9 @@
       {
          CacheLoaderConfig other = (CacheLoaderConfig) obj;
          return (this.passivation == other.passivation)
-                 && (this.shared == other.shared)
-                 && safeEquals(this.preload, other.preload)
-                 && safeEquals(this.cacheLoaderConfigs, other.cacheLoaderConfigs);
+               && (this.shared == other.shared)
+               && safeEquals(this.preload, other.preload)
+               && safeEquals(this.cacheLoaderConfigs, other.cacheLoaderConfigs);
       }
       return false;
    }
@@ -134,14 +130,12 @@
       result = 51 * result + (cacheLoaderConfigs == null ? 0 : cacheLoaderConfigs.hashCode());
       return result;
    }
-   
-   
 
 
    @Override
    public CacheLoaderConfig clone() throws CloneNotSupportedException
    {
-      CacheLoaderConfig clone =  (CacheLoaderConfig) super.clone();
+      CacheLoaderConfig clone = (CacheLoaderConfig) super.clone();
       if (cacheLoaderConfigs != null)
       {
          List<IndividualCacheLoaderConfig> clcs = new ArrayList<IndividualCacheLoaderConfig>(cacheLoaderConfigs.size());
@@ -155,8 +149,6 @@
    }
 
 
-
-
    /**
     * Configuration object that holds the confguration of an individual cache loader.
     *
@@ -178,10 +170,6 @@
 
       private SingletonStoreConfig singletonStoreConfig;
 
-      public IndividualCacheLoaderConfig()
-      {
-      }
-
       protected void populateFromBaseConfig(IndividualCacheLoaderConfig base)
       {
          if (base != null)
@@ -282,7 +270,7 @@
 
       public void setSingletonStoreConfig(SingletonStoreConfig singletonStoreConfig)
       {
-         testImmutability("singletonStoreConfig");      
+         testImmutability("singletonStoreConfig");
          replaceChildConfig(this.singletonStoreConfig, singletonStoreConfig);
          this.singletonStoreConfig = singletonStoreConfig;
       }
@@ -292,16 +280,16 @@
       {
          if (!(obj instanceof IndividualCacheLoaderConfig))
             return false;
-         IndividualCacheLoaderConfig i = (IndividualCacheLoaderConfig)obj;
+         IndividualCacheLoaderConfig i = (IndividualCacheLoaderConfig) obj;
          return equalsExcludingProperties(i)
-                 && safeEquals(this.properties, i.properties);
+               && safeEquals(this.properties, i.properties);
       }
 
       protected boolean equalsExcludingProperties(Object obj)
       {
          if (!(obj instanceof IndividualCacheLoaderConfig))
             return false;
-         IndividualCacheLoaderConfig other = (IndividualCacheLoaderConfig)obj;
+         IndividualCacheLoaderConfig other = (IndividualCacheLoaderConfig) obj;
 
          return safeEquals(this.className, other.className)
                && (this.async == other.async)
@@ -333,17 +321,16 @@
       public String toString()
       {
          return new StringBuffer().append("IndividualCacheLoaderConfig{").append("className='").append(className).append('\'')
-                 .append(", async=").append(async)
-                 .append(", ignoreModifications=").append(ignoreModifications)
-                 .append(", fetchPersistentState=").append(fetchPersistentState)
-                 .append(", properties=").append(properties)
-                 .append(", purgeOnStartup=").append(purgeOnStartup).append("},")
-                 .append("SingletonStoreConfig{").append(singletonStoreConfig).append('}')
-                 .toString();
+               .append(", async=").append(async)
+               .append(", ignoreModifications=").append(ignoreModifications)
+               .append(", fetchPersistentState=").append(fetchPersistentState)
+               .append(", properties=").append(properties)
+               .append(", purgeOnStartup=").append(purgeOnStartup).append("},")
+               .append("SingletonStoreConfig{").append(singletonStoreConfig).append('}')
+               .toString();
       }
-      
-      
 
+
       @Override
       public IndividualCacheLoaderConfig clone() throws CloneNotSupportedException
       {
@@ -356,7 +343,6 @@
       }
 
 
-
       /**
        * Configuration for a SingletonStoreCacheLoader
        */
@@ -430,13 +416,13 @@
             {
                SingletonStoreConfig other = (SingletonStoreConfig) obj;
                return ((this.singletonStoreEnabled == other.singletonStoreEnabled)
-                       && safeEquals(this.singletonStoreClass, other.singletonStoreClass)
-                       && safeEquals(this.singletonStoreproperties, other.singletonStoreproperties));
+                     && safeEquals(this.singletonStoreClass, other.singletonStoreClass)
+                     && safeEquals(this.singletonStoreproperties, other.singletonStoreproperties));
             }
             return false;
          }
 
-         @Override         
+         @Override
          public int hashCode()
          {
             int result = 19;
@@ -446,12 +432,12 @@
             return result;
          }
 
-         @Override         
+         @Override
          public String toString()
          {
             return super.toString() + " enabled=" + singletonStoreEnabled +
-                    " class=" + singletonStoreClass +
-                    " properties=" + singletonStoreproperties;
+                  " class=" + singletonStoreClass +
+                  " properties=" + singletonStoreproperties;
          }
 
          @Override
@@ -462,8 +448,8 @@
                clone.singletonStoreproperties = (Properties) singletonStoreproperties.clone();
             return clone;
          }
-         
-         
+
+
       }
    }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,10 +6,10 @@
  */
 package org.jboss.cache.config;
 
-import org.jboss.cache.CacheImpl;
 import org.jboss.cache.Version;
 import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.marshall.Marshaller;
 import org.w3c.dom.Element;
 
 import java.net.URL;
@@ -27,6 +27,18 @@
    private static final long serialVersionUID = 5553791890144997466L;
    private int numberOfNotifierThreads = 25;
 
+   private Marshaller marshaller;
+
+   public void setCacheMarshaller(Marshaller instance)
+   {
+      marshaller = instance;
+   }
+
+   public Marshaller getMarshaller()
+   {
+      return marshaller;
+   }
+
    /**
     * Cache replication mode.
     */
@@ -57,13 +69,13 @@
        */
       INVALIDATION_ASYNC;
 
-       /**
-        * Returns true if the mode is invalidation, either sync or async.
-        */
-       public boolean isInvalidation()
-       {
-           return this.equals(INVALIDATION_SYNC) || this.equals(INVALIDATION_SYNC);
-       }
+      /**
+       * Returns true if the mode is invalidation, either sync or async.
+       */
+      public boolean isInvalidation()
+      {
+         return this.equals(INVALIDATION_SYNC) || this.equals(INVALIDATION_SYNC);
+      }
 
    }
 
@@ -83,7 +95,7 @@
             return CacheMode.INVALIDATION_SYNC;
          default:
             throw new IllegalArgumentException("Unknown legacy cache mode " +
-                                               legacyMode);
+                  legacyMode);
       }
    }
 
@@ -153,30 +165,9 @@
    private String muxStackName = null;
    private boolean usingMultiplexer = false;
    private transient RuntimeConfig runtimeConfig;
-   private String marshallerClass = "org.jboss.cache.marshall.VersionAwareMarshaller";
+   private String marshallerClass;// = "org.jboss.cache.marshall.VersionAwareMarshaller";
 
    // ------------------------------------------------------------------------------------------------------------
-   //   CONSTRUCTORS
-   // ------------------------------------------------------------------------------------------------------------
-
-   /**
-    * Sets a reference to an existing CacheImpl instance
-    *
-    * @param cache
-    */
-   public Configuration(CacheImpl cache)
-   {
-      setCacheImpl(cache);
-   }
-
-   /**
-    * Default empty constructor
-    */
-   public Configuration()
-   {
-   }
-
-   // ------------------------------------------------------------------------------------------------------------
    //   SETTERS - MAKE SURE ALL SETTERS PERFORM testImmutability()!!!
    // ------------------------------------------------------------------------------------------------------------
 
@@ -640,6 +631,7 @@
 
    /**
     * Returns a {@link java.net.URL} to a default JGroups configuration file.
+    *
     * @return a default JGroups config file
     */
    public URL getDefaultClusterConfig()
@@ -649,7 +641,6 @@
       return url;
    }
 
-
    // ------------------------------------------------------------------------------------------------------------
    //   HELPERS
    // ------------------------------------------------------------------------------------------------------------

Modified: core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -8,7 +8,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.factories.annotations.Inject;
 
 import java.io.Serializable;
 import java.util.Collection;
@@ -29,9 +31,9 @@
    private static final long serialVersionUID = 4879873994727821938L;
 
    protected transient Log log = LogFactory.getLog(getClass());
-   private transient CacheImpl cache; // back-reference to test whether the cache is running.
+   private transient CacheSPI cache; // back-reference to test whether the cache is running.
    private final Set<ConfigurationComponent> children =
-           Collections.synchronizedSet(new HashSet<ConfigurationComponent>());
+         Collections.synchronizedSet(new HashSet<ConfigurationComponent>());
 
    protected ConfigurationComponent()
    {
@@ -41,14 +43,14 @@
    {
       if (child != null)
       {
-         child.setCacheImpl(cache);
+         child.setCache(cache);
       }
    }
 
    protected void addChildConfig(ConfigurationComponent child)
    {
       if (child != null && children.add(child))
-         child.setCacheImpl(cache);
+         child.setCache(cache);
    }
 
    protected void addChildConfigs(Collection<? extends ConfigurationComponent> toAdd)
@@ -99,7 +101,7 @@
    {
       try
       {
-         if (cache != null && cache.isStarted() && !getClass().getDeclaredField(fieldName).isAnnotationPresent(Dynamic.class))
+         if (cache != null && (cache.getCacheStatus() == CacheStatus.STARTED || cache.getCacheStatus() == CacheStatus.STARTING) && !getClass().getDeclaredField(fieldName).isAnnotationPresent(Dynamic.class))
          {
             throw new ConfigurationException("Attempted to modify a non-Dynamic configuration element [" + fieldName + "] after the cache has started!");
          }
@@ -110,24 +112,20 @@
       }
    }
 
-   protected CacheImpl getTreeCache()
-   {
-      return cache;
-   }
-
    /**
     * Sets a back-reference to the cache associated with this configuration
     *
     * @param cache
     */
-   public void setCacheImpl(CacheImpl cache)
+   @Inject
+   public void setCache(CacheSPI cache)
    {
       this.cache = cache;
       synchronized (children)
       {
          for (ConfigurationComponent child : children)
          {
-            child.setCacheImpl(cache);
+            child.setCache(cache);
          }
       }
    }
@@ -135,7 +133,7 @@
    public ConfigurationComponent clone() throws CloneNotSupportedException
    {
       ConfigurationComponent c = (ConfigurationComponent) super.clone();
-      c.setCacheImpl(null);
+      c.setCache(null);
       return c;
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -21,11 +21,11 @@
  */
 package org.jboss.cache.config;
 
-import java.lang.reflect.Method;
-
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Fqn;
 
+import java.lang.reflect.Method;
+
 public class EvictionRegionConfig extends ConfigurationComponent
 {
    /**
@@ -43,10 +43,6 @@
    private Integer eventQueueSize;
    private EvictionPolicyConfig evictionPolicyConfig;
 
-   public EvictionRegionConfig()
-   {
-   }
-
    public EvictionPolicyConfig getEvictionPolicyConfig()
    {
       return evictionPolicyConfig;
@@ -101,8 +97,8 @@
       if (queueSize <= 0)
       {
          LogFactory.getLog(EvictionRegionConfig.class).warn("Ignoring invalid queue capacity " +
-                 queueSize + " -- using " +
-                 EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+               queueSize + " -- using " +
+               EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
          queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
       }
       this.eventQueueSize = queueSize;
@@ -148,16 +144,17 @@
          {
             throw new CloneNotSupportedException(evictionPolicyConfig + " is not Cloneable");
          }
-           
+
          if (evictionPolicyConfig instanceof ConfigurationComponent)
          {
             clone.setEvictionPolicyConfig((EvictionPolicyConfig) ((ConfigurationComponent) evictionPolicyConfig).clone());
          }
-         else {
+         else
+         {
             try
             {
-               Method cloneMethod = evictionPolicyConfig.getClass().getDeclaredMethod("clone", new Class[]{});
-               EvictionPolicyConfig epc = (EvictionPolicyConfig) cloneMethod.invoke(evictionPolicyConfig, new Object[]{});
+               Method cloneMethod = evictionPolicyConfig.getClass().getDeclaredMethod("clone");
+               EvictionPolicyConfig epc = (EvictionPolicyConfig) cloneMethod.invoke(evictionPolicyConfig);
                clone.setEvictionPolicyConfig(epc);
             }
             catch (Exception e)
@@ -168,11 +165,9 @@
             }
          }
       }
-      
+
       return clone;
    }
-   
-   
 
 
 }
\ No newline at end of file

Modified: core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -28,11 +28,6 @@
    private transient BuddyGroup buddyGroup;
    private RPCManager rpcManager;
 
-   public RuntimeConfig()
-   {
-      // needs a public ctor for DI frameworks to instantiate.
-   }
-
    /**
     * Resets the runtime to default values.
     */
@@ -155,9 +150,9 @@
       {
          RuntimeConfig other = (RuntimeConfig) obj;
          return safeEquals(transactionManager, other.transactionManager)
-                && safeEquals(muxChannelFactory, other.muxChannelFactory)
-                && safeEquals(rpcManager, other.rpcManager)
-                && safeEquals(channel, other.channel);
+               && safeEquals(muxChannelFactory, other.muxChannelFactory)
+               && safeEquals(rpcManager, other.rpcManager)
+               && safeEquals(channel, other.channel);
       }
 
       return false;
@@ -199,6 +194,6 @@
    {
       return (RuntimeConfig) super.clone();
    }
-   
-   
+
+
 }

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -81,7 +81,8 @@
       Configuration c = region.getCacheConfiguration();
       Configuration.CacheMode cm = c != null ? c.getCacheMode() : Configuration.CacheMode.LOCAL;
       allowTombstones = c != null && c.isNodeLockingOptimistic() &&
-                        (cm == Configuration.CacheMode.INVALIDATION_ASYNC || cm == Configuration.CacheMode.INVALIDATION_SYNC);
+            (cm == Configuration.CacheMode.INVALIDATION_ASYNC || cm == Configuration.CacheMode.INVALIDATION_SYNC);
+
    }
 
    /**
@@ -151,8 +152,8 @@
          {
             case ADD_NODE_EVENT:
                this.processAddedNodes(fqn,
-                       node.getElementDifference(),
-                       node.isResetElementCount());
+                     node.getElementDifference(),
+                     node.isResetElementCount());
                break;
             case REMOVE_NODE_EVENT:
                this.processRemovedNodes(fqn);
@@ -216,7 +217,7 @@
       {
          log.trace("Attempting to evict cache node with fqn of " + fqn);
       }
-      
+
       EvictionPolicy policy = region.getEvictionPolicy();
       try
       {
@@ -365,7 +366,7 @@
          if (log.isTraceEnabled())
          {
             log.trace("processRemoveNodes(): Can't find node associated with fqn: " + fqn
-                    + "Could have been evicted earlier. Will just continue.");
+                  + "Could have been evicted earlier. Will just continue.");
          }
          return;
       }
@@ -417,7 +418,7 @@
          if (log.isDebugEnabled())
          {
             log.debug("Removing element from " + fqn + " but eviction queue does not contain this node. " +
-                    "Ignoring removeElement event.");
+                  "Ignoring removeElement event.");
          }
          return;
       }
@@ -543,13 +544,14 @@
    public String toString()
    {
       return super.toString() +
-              " reqion=" + region.getFqn() +
-              " recycle=" + recycleQueue.size() +
-              " evict=" + evictionQueue.getNumberOfNodes();
+            " reqion=" + region.getFqn() +
+            " recycle=" + recycleQueue.size() +
+            " evict=" + evictionQueue.getNumberOfNodes();
    }
 
    /**
     * Tests whether a node entry is younger than the minimum time to live - if one is configured.
+    *
     * @param entry the node entry being examined
     * @return true if the node is younger than - or exactly equal to - the minimum time to live, if one is configured for the given region.  False otherwise.
     */

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -14,10 +14,6 @@
 {
    protected CacheSPI cache_;
 
-   public BaseEvictionPolicy()
-   {
-   }
-
    /** EvictionPolicy interface implementation */
 
    /**

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -8,16 +8,7 @@
 
 import org.jboss.cache.Fqn;
 
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
 
 /**
  * @author Daniel Huang
@@ -181,9 +172,6 @@
     */
    static class MaxElementComparator implements Comparator<NodeEntry>
    {
-      MaxElementComparator()
-      {
-      }
 
       public int compare(NodeEntry ne1, NodeEntry ne2)
       {

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -16,22 +16,17 @@
    public static final String EXPIRATION_KEY = "expiration";
 
    /**
-    * Node key name used to indicate the expiration of a node. 
+    * Node key name used to indicate the expiration of a node.
     */
    @Dynamic
    private String expirationKeyName = EXPIRATION_KEY;
-   
+
    @Dynamic
    private boolean warnNoExpirationKey = true;
 
    @Dynamic
    private int timeToLiveSeconds = 0;
 
-   public ExpirationConfiguration()
-   {
-      super();      
-   }
-
    @Override
    protected void setEvictionPolicyClassName()
    {
@@ -85,8 +80,7 @@
    public ExpirationConfiguration clone() throws CloneNotSupportedException
    {
       return (ExpirationConfiguration) super.clone();
-   }   
-   
-   
+   }
 
+
 }

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -22,11 +22,6 @@
    private static final Log log = LogFactory.getLog(FIFOAlgorithm.class);
 
 
-   public FIFOAlgorithm()
-   {
-      super();
-   }
-
    protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
    {
       return new FIFOQueue();
@@ -40,7 +35,7 @@
       // check the minimum time to live and see if we should not evict the node.  This check will
       // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
       if (isYoungerThanMinimumTimeToLive(ne)) return false;
-      
+
       FIFOConfiguration config = (FIFOConfiguration) region.getEvictionPolicyConfig();
       if (log.isTraceEnabled())
       {

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -37,11 +37,6 @@
    private static final Log log = LogFactory.getLog(LFUAlgorithm.class);
 
 
-   public LFUAlgorithm()
-   {
-      super();
-   }
-
    protected boolean shouldEvictNode(NodeEntry ne)
    {
       if (log.isTraceEnabled())
@@ -51,7 +46,7 @@
 
       // check the minimum time to live and see if we should not evict the node.  This check will
       // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
-      if (isYoungerThanMinimumTimeToLive(ne)) return false;      
+      if (isYoungerThanMinimumTimeToLive(ne)) return false;
 
       LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig();
       int size = this.getEvictionQueue().getNumberOfNodes();

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -9,7 +9,7 @@
 import org.jboss.cache.config.Dynamic;
 
 /**
- * Configuration implementation for {@link LFUPolicy}. 
+ * Configuration implementation for {@link LFUPolicy}.
  * <p/>
  * If configured via XML, expects the following:
  * <p/>
@@ -25,17 +25,14 @@
  */
 public class LFUConfiguration extends EvictionPolicyConfigBase
 {
-   /** The serialVersionUID */
+   /**
+    * The serialVersionUID
+    */
    private static final long serialVersionUID = 1865801530398969179L;
-   
+
    @Dynamic
    private int minNodes;
 
-   public LFUConfiguration()
-   {
-      super();
-   }
-
    @Override
    protected void setEvictionPolicyClassName()
    {
@@ -52,7 +49,7 @@
       testImmutability("minNodes");
       this.minNodes = minNodes;
    }
-   
+
    public String toString()
    {
       StringBuffer ret = new StringBuffer();

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -8,16 +8,7 @@
 
 import org.jboss.cache.Fqn;
 
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
 
 /**
  * LFUQueue EvictionQueue implementation for LFU Policy.
@@ -192,9 +183,6 @@
     */
    static class LFUComparator implements Comparator<NodeEntry>
    {
-      LFUComparator()
-      {
-      }
 
       public int compare(NodeEntry ne1, NodeEntry ne2)
       {

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -24,11 +24,6 @@
 {
    private static final Log log = LogFactory.getLog(LRUAlgorithm.class);
 
-   public LRUAlgorithm()
-   {
-      super();
-   }
-
    protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
    {
       return new LRUQueue();

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -1,9 +1,9 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.CacheImpl;
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.config.Option;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.marshall.MethodCall;
 import org.jboss.cache.marshall.MethodDeclarations;
 import org.jboss.cache.transaction.GlobalTransaction;
@@ -23,18 +23,14 @@
  */
 public class CallInterceptor extends Interceptor
 {
-   private CacheImpl cache;
+   private CacheImpl cacheImpl;
 
-   public void setCache(CacheSPI cache)
+   @Inject
+   private void injectDependencies(CacheImpl cacheImpl)
    {
-      super.setCache(cache);
+      this.cacheImpl = cacheImpl;
    }
 
-   public void setTreeCacheInstance(CacheImpl c)
-   {
-      cache = c;
-   }
-
    public Object invoke(InvocationContext ctx) throws Throwable
    {
       MethodCall m = ctx.getMethodCall();
@@ -45,8 +41,7 @@
          if (log.isTraceEnabled()) log.trace("Passing up method " + m + " so it gets invoked on cache.");
          try
          {
-            //retval = nextInterceptor(m);
-            retval = m.invoke(cache);
+            retval = m.invoke(cacheImpl);
          }
          catch (Throwable t)
          {

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -27,6 +27,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
 
 import javax.transaction.Status;
 import javax.transaction.SystemException;
@@ -36,7 +37,7 @@
 
 /**
  * Class representing an interceptor.
- * <em>Note that this will be replaced by {@link org.jboss.aop.advice.Interceptor} in one of the nextInterceptor releases</em>
+ * <em>Note that this will be replaced by {@link org.jboss.aop.advice.Interceptor} in one of the next releases</em>
  *
  * @author Bela Ban
  * @version $Id$
@@ -64,12 +65,19 @@
       return next;
    }
 
+   @Inject
    public void setCache(CacheSPI cache)
    {
       this.cache = cache;
-      this.configuration = cache.getConfiguration();
+      //this.configuration = cache.getConfiguration();
    }
 
+   @Inject
+   private void injectDependencies(Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+
    /**
     * Using this method call for forwarding a call in the chain is not redable and error prone in the case of interceptors
     * extending other interceptors. This metod rather refers to interceptor doing its business operations rather than
@@ -174,7 +182,7 @@
       return isActive(tx) || isPreparing(tx);
    }
 
-    /**
+   /**
     * Tests whether the caller is in a valid transaction.  If not, will throw a CacheException.
     */
    protected void assertTransactionValid(InvocationContext ctx)
@@ -193,10 +201,10 @@
    public String toString()
    {
       return getClass().getName()
-              + "{next: "
-              + (getNext() == null ? null : getNext().getClass())
-              + "; last: "
-              + (getLast() == null ? null : getLast().getClass())
-              + "}";
+            + "{next: "
+            + (getNext() == null ? null : getNext().getClass())
+            + "; last: "
+            + (getLast() == null ? null : getLast().getClass())
+            + "}";
    }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -7,7 +7,15 @@
 package org.jboss.cache.interceptors;
 
 import org.apache.commons.logging.Log;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.ComponentName;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.lock.LockingException;
 import org.jboss.cache.lock.NodeLock;
@@ -17,7 +25,12 @@
 import org.jboss.cache.transaction.TransactionTable;
 import org.jgroups.Address;
 
-import java.util.*;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /*
 * todo refactorings ideas
@@ -41,17 +54,24 @@
    private TransactionTable tx_table = null;
 
    /**
-    * Map<Object, java.util.List>. Keys = threads, values = lists of locks held by that thread
+    * Map<Thread, List<NodeLock>>. Keys = threads, values = lists of locks held by that thread
     */
    private Map<Thread, List<NodeLock>> lock_table;
    private long lock_acquisition_timeout;
 
+   @Inject
+   public void injectDependencies(@ComponentName("LockTable")Map<Thread, List<NodeLock>> lockTable, Configuration configuration)
+   {
+      this.lock_table = lockTable;
+      lock_acquisition_timeout = configuration.getLockAcquisitionTimeout();
+   }
+
    public void setCache(CacheSPI cache)
    {
       super.setCache(cache);
       tx_table = cache.getTransactionTable();
-      lock_table = cache.getLockTable();
-      lock_acquisition_timeout = cache.getConfiguration().getLockAcquisitionTimeout();
+      //lock_table = cache.getLockTable();
+      //lock_acquisition_timeout = cache.getConfiguration().getLockAcquisitionTimeout();
    }
 
    protected Log getLog()
@@ -75,7 +95,7 @@
    }
 
    private Object handlePutMethod(InvocationContext ctx, Fqn fqn)
-      throws Throwable
+         throws Throwable
    {
       log.trace("Suppressing locking");
       if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSuppressLocking())
@@ -92,7 +112,8 @@
             manageReverseRemove(ctx.getGlobalTransaction(), child_node, true);
             n = child_node;
          }
-      } else
+      }
+      else
       {
          acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, true, false, false, true);
       }
@@ -174,7 +195,7 @@
       long timeout = ctx.getContextLockAcquisitionTimeout(lock_acquisition_timeout);
       // this call will ensure the node gets a WL and it's current parent gets RL.
       if (log.isTraceEnabled()) log.trace("Attempting to get WL on node to be moved [" + from + "]");
-      if (from != null && ! (configuration.getIsolationLevel() == IsolationLevel.NONE))
+      if (from != null && !(configuration.getIsolationLevel() == IsolationLevel.NONE))
       {
          lock(ctx, from, NodeLock.LockType.WRITE, false, timeout, true, false);
          if (ctx.getGlobalTransaction() != null)
@@ -195,7 +216,7 @@
       NodeSPI n = cache.peek(from, true);
       if (n != null)
       {
-          n.getLock().releaseAll(Thread.currentThread());
+         n.getLock().releaseAll(Thread.currentThread());
       }
       return retValue;
    }
@@ -215,7 +236,7 @@
          NodeSPI n = cache.peek(fqn, true);
          if (n != null)
          {
-             n.getLock().releaseAll(Thread.currentThread());
+            n.getLock().releaseAll(Thread.currentThread());
          }
       }
       // if this is a delete op and we had to create the node, return a FALSE as nothing *really* was deleted!
@@ -253,49 +274,49 @@
 
    protected Object handleGetKeyValueMethod(InvocationContext ctx, Fqn fqn, Object key, boolean sendNodeEvent) throws Throwable
    {
-       acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
-       return nextInterceptor(ctx);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
+      return nextInterceptor(ctx);
    }
 
-    protected Object handleGetNodeMethod(InvocationContext ctx, Fqn fqn) throws Throwable
+   protected Object handleGetNodeMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-       acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
-       return nextInterceptor(ctx);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
+      return nextInterceptor(ctx);
    }
 
    protected Object handleGetKeysMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-       acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
-       return nextInterceptor(ctx);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
+      return nextInterceptor(ctx);
    }
 
    protected Object handleGetChildrenNamesMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-       acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
-       return nextInterceptor(ctx);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
+      return nextInterceptor(ctx);
    }
 
    protected Object handlePrintMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-       acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
-       return nextInterceptor(ctx);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
+      return nextInterceptor(ctx);
    }
 
    protected Object handleReleaseAllLocksMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-       acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
-       return nextInterceptor(ctx);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false);
+      return nextInterceptor(ctx);
    }
 
    private boolean acquireLocksWithTimeout(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType,
                                            boolean createIfNotExists, boolean zeroLockTimeout,
                                            boolean acquireLockOnParent, boolean reverseRemoveCheck)
-      throws InterruptedException
+         throws InterruptedException
    {
       if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE)
       {
          return false;
-      }      
+      }
       boolean created;
       long timeout = zeroLockTimeout ? 0 : ctx.getContextLockAcquisitionTimeout(lock_acquisition_timeout);
       // make sure we can bail out of this loop
@@ -319,14 +340,15 @@
     * Acquires locks on the node and on its parrents. Read locks are acquired for exsiting ancestors, with two exceptions:
     * 1) createIfNotExists is true. If an ancestor is created on the fly, then an WL is acquired by default
     * 2) acquireWriteLockOnParent is true. If so AND {@link org.jboss.cache.Node#isLockForChildInsertRemove()} then a read
-    *  lock will be aquired for the parent of the node.
-    * @param createIfNotExists if true, then missing nodes will be cretaed on the fly. If false, method returns if we
-    * reach a node that does not exists
+    * lock will be aquired for the parent of the node.
+    *
+    * @param createIfNotExists  if true, then missing nodes will be cretaed on the fly. If false, method returns if we
+    *                           reach a node that does not exists
     * @param reverseRemoveCheck see {@link #manageReverseRemove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.NodeSPI, boolean)}
     */
    private boolean lock(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType, boolean createIfNotExists, long timeout,
                         boolean acquireWriteLockOnParent, boolean reverseRemoveCheck)
-           throws TimeoutException, LockingException, InterruptedException
+         throws TimeoutException, LockingException, InterruptedException
    {
       Thread currentThread = Thread.currentThread();
       GlobalTransaction gtx = ctx.getGlobalTransaction();
@@ -356,7 +378,8 @@
             }
             else
             {
-               if (log.isTraceEnabled()) log.trace("failed to find or create child " + childName + " of node " + currentNode);
+               if (log.isTraceEnabled())
+                  log.trace("failed to find or create child " + childName + " of node " + currentNode);
                return false;
             }
          }
@@ -376,7 +399,8 @@
          NodeSPI repeek = cache.peek(currentNode.getFqn(), true, true);
          if (currentNode != repeek)
          {
-            if (log.isTraceEnabled()) log.trace("Was waiting for and obtained a lock on a node that doesn't exist anymore!  Attempting lock acquisition again.");
+            if (log.isTraceEnabled())
+               log.trace("Was waiting for and obtained a lock on a node that doesn't exist anymore!  Attempting lock acquisition again.");
             // we have an orphan!! Lose the unnecessary lock and re-acquire the lock (and potentially recreate the node).
             // check if the parent exists!!
             // look into invalidated nodes as well
@@ -384,7 +408,8 @@
             if (cache.peek(parent.getFqn(), true, true) == null)
             {
                // crap!
-               if (log.isTraceEnabled()) log.trace("Parent has been deleted again.  Go through the lock method all over again.");
+               if (log.isTraceEnabled())
+                  log.trace("Parent has been deleted again.  Go through the lock method all over again.");
                currentNode = cache.getRoot();
                parent = null;
             }
@@ -413,22 +438,22 @@
    }
 
 
-    /**
-     * Acquires nodes on the children of this node. nodes on the node itself are not aquired.
-     * If the supplied parent node is null the method returns(no op).
-     */
+   /**
+    * Acquires nodes on the children of this node. nodes on the node itself are not aquired.
+    * If the supplied parent node is null the method returns(no op).
+    */
    private void acquireLocksOnChildren(NodeSPI parentNode, NodeLock.LockType lockType, InvocationContext ctx)
-      throws InterruptedException
+         throws InterruptedException
    {
       if (parentNode == null)
       {
-          return;
+         return;
       }
       long timeout = ctx.getContextLockAcquisitionTimeout(lock_acquisition_timeout);
       GlobalTransaction gtx = ctx.getGlobalTransaction();
       Object owner = (gtx != null) ? gtx : Thread.currentThread();
 
-       Set<NodeLock> acquiredLocks = parentNode.getLock().acquireAll(owner, timeout, lockType);
+      Set<NodeLock> acquiredLocks = parentNode.getLock().acquireAll(owner, timeout, lockType);
       if (acquiredLocks.size() > 0)
       {
          if (gtx != null)
@@ -443,16 +468,16 @@
       }
    }
 
-    /**
-     * Used by {@link #lock(org.jboss.cache.InvocationContext, org.jboss.cache.Fqn, org.jboss.cache.lock.NodeLock.LockType, boolean, long, boolean, boolean)}.
-     * Determins whter an arbitrary node from the supplied fqn needs an write lock.
-     */
+   /**
+    * Used by {@link #lock(org.jboss.cache.InvocationContext, org.jboss.cache.Fqn, org.jboss.cache.lock.NodeLock.LockType, boolean, long, boolean, boolean)}.
+    * Determins whter an arbitrary node from the supplied fqn needs an write lock.
+    */
    private boolean writeLockNeeded(InvocationContext ctx, NodeLock.LockType lockType, int currentNodeIndex, boolean acquireWriteLockOnParent, boolean createIfNotExists, Fqn targetFqn, NodeSPI currentNode)
    {
       int treeNodeSize = targetFqn.size();
       // write lock forced!!
-       boolean isTargetNode = currentNodeIndex == (treeNodeSize - 1);
-       if (ctx.getOptionOverrides().isForceWriteLock() && isTargetNode) return true;
+      boolean isTargetNode = currentNodeIndex == (treeNodeSize - 1);
+      if (ctx.getOptionOverrides().isForceWriteLock() && isTargetNode) return true;
       //this can be injected, from the caller as a param named wlParent
       if (currentNode.isLockForChildInsertRemove())
       {
@@ -468,31 +493,31 @@
       return lockType == NodeLock.LockType.WRITE && isTargetNode;//write lock explicitly requested and this is the target to be written to.
    }
 
-    private void acquireNodeLock(NodeSPI node, Object owner, GlobalTransaction gtx, NodeLock.LockType lockType, long lockTimeout) throws LockingException, TimeoutException, InterruptedException
+   private void acquireNodeLock(NodeSPI node, Object owner, GlobalTransaction gtx, NodeLock.LockType lockType, long lockTimeout) throws LockingException, TimeoutException, InterruptedException
    {
       boolean acquired = node.getLock().acquire(owner, lockTimeout, lockType);
       if (acquired)
       {
          // Record the lock for release on method return or tx commit/rollback
-          NodeLock lock = node.getLock();
-          if (gtx != null)
-          {
-             cache.getTransactionTable().recordNodeLock(gtx, lock);
-          }
-          else
-          {
-             Thread currentThread = Thread.currentThread();
-             List<NodeLock> locks = getLocks(currentThread);
-             if (!locks.contains(lock))
-             {
-                locks.add(lock);
-                lock_table.put(currentThread, locks);
-             }
-          }
+         NodeLock lock = node.getLock();
+         if (gtx != null)
+         {
+            cache.getTransactionTable().recordNodeLock(gtx, lock);
+         }
+         else
+         {
+            Thread currentThread = Thread.currentThread();
+            List<NodeLock> locks = getLocks(currentThread);
+            if (!locks.contains(lock))
+            {
+               locks.add(lock);
+               lock_table.put(currentThread, locks);
+            }
+         }
       }
    }
 
-    private List<NodeLock> getLocks(Thread currentThread)
+   private List<NodeLock> getLocks(Thread currentThread)
    {
       // This sort of looks like a get/put race condition, but
       // since we key off the Thread, it's not
@@ -506,16 +531,16 @@
    }
 
 
-    /**
-     * Test if this node needs to be 'undeleted'
-     * reverse the "remove" if the node has been previously removed in the same tx, if this operation is a put()
-     */
+   /**
+    * Test if this node needs to be 'undeleted'
+    * reverse the "remove" if the node has been previously removed in the same tx, if this operation is a put()
+    */
    private void manageReverseRemove(GlobalTransaction gtx, NodeSPI childNode, boolean reverseRemoveCheck)
    {
       boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && tx_table.get(gtx).getRemovedNodes().contains(childNode.getFqn());
       if (gtx != null && needToReverseRemove)
       {
-          childNode.markAsDeleted(false);
+         childNode.markAsDeleted(false);
       }
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,10 +6,15 @@
  */
 package org.jboss.cache.interceptors;
 
-import org.jboss.cache.*;
-import org.jboss.cache.lock.NodeLock;
+import org.apache.commons.logging.Log;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.ReplicationException;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
+import org.jboss.cache.lock.NodeLock;
 import org.jboss.cache.marshall.MethodCall;
 import org.jboss.cache.marshall.MethodCallFactory;
 import org.jboss.cache.marshall.MethodDeclarations;
@@ -17,7 +22,6 @@
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jboss.cache.transaction.OptimisticTransactionEntry;
 import org.jboss.cache.transaction.TransactionEntry;
-import org.apache.commons.logging.Log;
 import org.jgroups.Address;
 
 import javax.transaction.Status;
@@ -82,7 +86,8 @@
             if (log.isTraceEnabled()) log.trace("received my own message (discarding it)");
             result = null;
          }
-      } catch (Throwable e)
+      }
+      catch (Throwable e)
       {
          throwIfNeeded(ctx, e);
       }
@@ -119,14 +124,16 @@
             if (log.isTraceEnabled()) log.trace("received my own message (discarding it)");
             result = null;
          }
-      } catch (Throwable throwable)
+      }
+      catch (Throwable throwable)
       {
          throwIfNeeded(ctx, throwable);
-      } finally
+      }
+      finally
       {
          scrubOnExist(ctx, scrubTxsOnExit);
       }
-      return result;      
+      return result;
    }
 
 
@@ -332,7 +339,7 @@
 
    // --------------------------------------------------------------
 
-   private Object handleRemotePrepare(InvocationContext ctx,List<MethodCall> modifications, boolean onePhase ) throws Throwable
+   private Object handleRemotePrepare(InvocationContext ctx, List<MethodCall> modifications, boolean onePhase) throws Throwable
    {
       GlobalTransaction gtx = ctx.getGlobalTransaction();
       // Is there a local transaction associated with GTX ?
@@ -442,8 +449,8 @@
          GlobalTransaction gtx = ctx.getGlobalTransaction();
 
          try
-      {
-         result = nextInterceptor(ctx);
+         {
+            result = nextInterceptor(ctx);
             if (implicitTransaction)
             {
                copyInvocationScopeOptionsToTxScope(ctx);
@@ -473,7 +480,8 @@
             }
          }
          return result;
-      } catch (Throwable throwable)
+      }
+      catch (Throwable throwable)
       {
          throwIfNeeded(ctx, throwable);
          return null;
@@ -486,7 +494,7 @@
    private void copyForcedCacheModeToTxScope(InvocationContext ctx)
    {
       Option optionOverride = ctx.getOptionOverrides();
-      if (optionOverride != null 
+      if (optionOverride != null
             && (optionOverride.isForceAsynchronous() || optionOverride.isForceSynchronous()))
       {
          TransactionEntry entry = txTable.get(ctx.getGlobalTransaction());
@@ -550,8 +558,8 @@
       if (!isActive(ltx))
       {
          throw new ReplicationException("prepare() failed -- " +
-                 "local transaction status is not STATUS_ACTIVE;" +
-                 " is " + ltx.getStatus());
+               "local transaction status is not STATUS_ACTIVE;" +
+               " is " + ltx.getStatus());
       }
       return retval;
    }
@@ -566,7 +574,7 @@
          try
          {
             replayModifications(modifications, ctx, false);
-             if (m.isOnePhaseCommitPrepareMehod())
+            if (m.isOnePhaseCommitPrepareMehod())
             {
                log.trace("Using one-phase prepare.  Not propagating the prepare call up the stack until called to do so by the sync handler.");
             }
@@ -579,8 +587,8 @@
             if (!isActive(ltx))
             {
                throw new ReplicationException("prepare() failed -- " +
-                       "local transaction status is not STATUS_ACTIVE;" +
-                       " is " + ltx.getStatus());
+                     "local transaction status is not STATUS_ACTIVE;" +
+                     " is " + ltx.getStatus());
             }
          }
          catch (Throwable th)
@@ -866,13 +874,13 @@
             if (configuration.isNodeLockingOptimistic())
             {
                commitMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod,
-                       gtx, modifications, null, cache.getLocalAddress(), true);
+                     gtx, modifications, null, cache.getLocalAddress(), true);
             }
             else
             {
                commitMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
-                       gtx, modifications, cache.getLocalAddress(),
-                       true);
+                     gtx, modifications, cache.getLocalAddress(),
+                     true);
             }
          }
          else
@@ -979,8 +987,8 @@
       else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
       {
          prepareMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
-                 gtx, modifications, cache.getLocalAddress(),
-                 false);// don't commit or rollback - wait for call
+               gtx, modifications, cache.getLocalAddress(),
+               false);// don't commit or rollback - wait for call
       }
       //}
       else
@@ -1148,7 +1156,7 @@
    {
       Transaction tx = null;
       GlobalTransaction gtx = null;
-//      CacheSPI cache = null;
+      //      CacheSPI cache = null;
       List modifications = null;
       TransactionEntry entry = null;
       protected InvocationContext ctx; // the context for this call.

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -1,15 +1,17 @@
 package org.jboss.cache.interceptors;
 
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.factories.annotations.ComponentName;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.lock.IdentityLock;
+import org.jboss.cache.lock.NodeLock;
+
+import javax.transaction.Transaction;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 
-import javax.transaction.Transaction;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.lock.IdentityLock;
-
 /**
  * When a call returns, unlocks all locks held by the current thread in the
  * LockTable. This is a no-op if a transaction is used.
@@ -20,9 +22,15 @@
 public class UnlockInterceptor extends Interceptor
 {
 
-   Map lock_table = null;
+   Map<Thread, List<NodeLock>> lock_table = null;
    boolean trace = log.isTraceEnabled();
 
+   @Inject
+   private void injectDependencies(@ComponentName("LockTable")Map<Thread, List<NodeLock>> lockTable)
+   {
+      this.lock_table = lockTable;
+   }
+
    public void setCache(CacheSPI cache)
    {
       super.setCache(cache);

Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -27,6 +27,7 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.CacheFactory;
 import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.config.BuddyReplicationConfig;
@@ -37,23 +38,14 @@
 import org.jboss.cache.config.RuntimeConfig;
 import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.interceptors.Interceptor;
+import org.jboss.cache.util.CachePrinter;
 import org.jgroups.Address;
 import org.jgroups.Channel;
 import org.jgroups.ChannelFactory;
 import org.jgroups.jmx.JChannelFactoryMBean;
 import org.w3c.dom.Element;
 
-import javax.management.AttributeChangeNotification;
-import javax.management.JMException;
-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.List;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -76,7 +68,7 @@
    private MBeanServer server;
    private String cacheObjectName;
    private boolean interceptorsRegistered;
-   private CacheImpl<K, V> cache;
+   private CacheSPI<K, V> cache;
    private Configuration config;
    private boolean registerInterceptors = true;
    private final AtomicInteger listenerCount = new AtomicInteger(0);
@@ -86,7 +78,7 @@
    private String notificationServiceName;
    private boolean registered;
    private boolean disableStateChangeNotifications;
-   
+
    // Legacy config support
 
    private Element buddyReplConfig;
@@ -140,12 +132,12 @@
 
    public String printCacheDetails()
    {
-      return cache == null ? "Cache is null" : cache.printDetails();
+      return cache == null ? "Cache is null" : CachePrinter.printCacheDetails(cache);
    }
 
    public String printCacheDetailsAsHtml()
    {
-      return cache == null ? "Cache is null" : formatHtml(cache.printDetails());
+      return cache == null ? "Cache is null" : formatHtml(CachePrinter.printCacheDetails(cache));
    }
 
    public CacheStatus getCacheStatus()
@@ -201,12 +193,12 @@
 
    public String printLockInfo()
    {
-      return cache == null ? "Cache is null" : cache.printLockInfo();
+      return cache == null ? "Cache is null" : CachePrinter.printCacheLockingInfo(cache);
    }
 
    public String printLockInfoAsHtml()
    {
-      return cache == null ? "Cache is null" : formatHtml(cache.printLockInfo());
+      return cache == null ? "Cache is null" : formatHtml(CachePrinter.printCacheLockingInfo(cache));
    }
 
    public boolean getRegisterInterceptors()
@@ -397,7 +389,7 @@
    public void setCacheLoaderConfiguration(Element config)
    {
       log.warn("MBean attribute 'CacheLoaderConfiguration' is deprecated; " +
-               "use 'CacheLoaderConfig'");
+            "use 'CacheLoaderConfig'");
       setCacheLoaderConfig(config);
    }
 
@@ -452,7 +444,7 @@
    public void setUseInterceptorMbeans(boolean use)
    {
       log.warn("MBean attribute 'UseInterceptorMbeans' is deprecated; " +
-               "use 'ExposeManagementStatistics'");
+            "use 'ExposeManagementStatistics'");
       setExposeManagementStatistics(use);
    }
 
@@ -606,7 +598,7 @@
          cacheStatus = CacheStatus.STARTING;
          int startingState = getState();
          sendStateChangeNotification(oldState, startingState, getClass().getSimpleName() + " starting", null);
-         
+
          cache.start();
 
          registerInterceptors();
@@ -636,7 +628,7 @@
          cacheStatus = CacheStatus.STOPPING;
          int stoppingState = getState();
          sendStateChangeNotification(oldState, stoppingState, getClass().getSimpleName() + " stopping", null);
-         
+
          cache.stop();
 
          if (cache.getCacheStatus() == CacheStatus.DESTROYED)
@@ -654,7 +646,7 @@
          if (failed)
          {
             log.warn("Attempted to stop() from FAILED state, " +
-                     "but caught exception; try calling destroy()", t);
+                  "but caught exception; try calling destroy()", t);
          }
          handleLifecycleTransitionFailure(t);
       }
@@ -673,7 +665,7 @@
             catch (CacheException e)
             {
                log.warn("Needed to call stop() before destroying but stop() " +
-                        "threw exception. Proceeding to destroy", e);
+                     "threw exception. Proceeding to destroy", e);
             }
          }
          else
@@ -737,7 +729,7 @@
    public void postRegister(Boolean registrationDone)
    {
       if (Boolean.TRUE.equals(registrationDone))
-      {         
+      {
          log.debug("Registered in JMX under " + cacheObjectName);
 
          if (cache != null && CacheStatus.STARTED.equals(cache.getCacheStatus()))
@@ -751,7 +743,7 @@
                log.error("Caught exception registering cache interceptors with JMX", e);
             }
          }
-         
+
          registered = true;
       }
    }
@@ -796,14 +788,13 @@
    public void setCache(Cache<K, V> cache)
    {
       if (cacheStatus != CacheStatus.INSTANTIATED
-          && cacheStatus != CacheStatus.CREATING
-          && cacheStatus != CacheStatus.DESTROYED)
+            && cacheStatus != CacheStatus.CREATING
+            && cacheStatus != CacheStatus.DESTROYED)
       {
          throw new IllegalStateException("Cannot set underlying cache after call to create()");
       }
 
-      // FIXME -- having to cast is ugly!!
-      this.cache = (CacheImpl<K, V>) cache;
+      this.cache = (CacheSPI<K, V>) cache;
       this.config = (cache == null ? null : cache.getConfiguration());
       synchronized (listenerCount)
       {
@@ -836,7 +827,7 @@
    /**
     * Gets whether sending of JMX notifications for this mbean's
     * start/stop lifecycle changes is disabled.
-    * 
+    *
     * @see #setDisableStateChangeNotifications(boolean)
     */
    public boolean isDisableStateChangeNotifications()
@@ -847,8 +838,9 @@
    /**
     * Hook to allow PojoCacheJmxWrapper to suppress state change
     * notifications from this mbean in lieu of its own.
-    * 
+    *
     * @param disableStateChangeNotifications
+    *
     */
    public void setDisableStateChangeNotifications(boolean disableStateChangeNotifications)
    {
@@ -1050,12 +1042,12 @@
     * @throws Error
     */
    private void handleLifecycleTransitionFailure(Throwable t)
-         throws CacheException, RuntimeException, Error
+         throws RuntimeException, Error
    {
       int oldState = getState();
       cacheStatus = CacheStatus.FAILED;
       sendStateChangeNotification(oldState, getState(), getClass().getSimpleName() + " failed", t);
-      
+
       if (t instanceof CacheException)
          throw (CacheException) t;
       else if (t instanceof RuntimeException)
@@ -1065,7 +1057,7 @@
       else
          throw new CacheException(t);
    }
-   
+
    /**
     * Helper for sending out state change notifications
     */
@@ -1073,17 +1065,17 @@
    {
       if (isDisableStateChangeNotifications())
          return;
-         
+
       long now = System.currentTimeMillis();
-      
+
       AttributeChangeNotification stateChangeNotification = new AttributeChangeNotification(
-         this,
-         getNextNotificationSequenceNumber(), now, msg,
-         "State", "java.lang.Integer",
-         Integer.valueOf(oldState), Integer.valueOf(newState)
-         );
+            this,
+            getNextNotificationSequenceNumber(), now, msg,
+            "State", "java.lang.Integer",
+            Integer.valueOf(oldState), Integer.valueOf(newState)
+      );
       stateChangeNotification.setUserData(t);
-      
-      sendNotification(stateChangeNotification);      
+
+      sendNotification(stateChangeNotification);
    }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -92,12 +92,13 @@
          // no persistent state sent across; return?
          return;
       }
-      if (objectFromStream instanceof NodeDataExceptionMarker){
-    	  NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) objectFromStream;
-    	  throw new CacheException("State provider cacheloader at node " + ndem.getCacheNodeIdentity()
-                                   + " threw exception during loadState (see Caused by)", ndem.getCause());  
+      if (objectFromStream instanceof NodeDataExceptionMarker)
+      {
+         NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) objectFromStream;
+         throw new CacheException("State provider cacheloader at node " + ndem.getCacheNodeIdentity()
+               + " threw exception during loadState (see Caused by)", ndem.getCause());
       }
-      
+
       List nodeData = (List) objectFromStream;
 
       //for (nd = (NodeData) in.readObject(); nd != null && !nd.isMarker(); nd = (NodeData) in.readObject())
@@ -110,7 +111,7 @@
          {
             NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
             throw new CacheException("State provider cacheloader at node " + ndem.getCacheNodeIdentity()
-                                     + " threw exception during loadState (see Caused by)", ndem.getCause());
+                  + " threw exception during loadState (see Caused by)", ndem.getCause());
          }
 
          if (moveToBuddy)
@@ -190,7 +191,7 @@
    protected void getNodeDataList(Fqn fqn, List<NodeData> list) throws Exception
    {
       Map<Object, Object> attrs;
-      Set<? extends Object> children_names;
+      Set<?> children_names;
       String child_name;
       Fqn tmp_fqn;
       NodeData nd;

Modified: core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -63,7 +63,7 @@
                if (log.isDebugEnabled())
                {
                   log.debug(property + "=" + sysPropertyValue + " defined as system property. It will override the value defined in XML which was: " + xmlPropertyValue);
-               };
+               }
             }
          }
       }
@@ -86,7 +86,10 @@
    public Connection checkoutConnection() throws SQLException
    {
       Connection connection = ds.getConnection();
-      if (log.isTraceEnabled()) { log.trace("Connection checked out: " + connection); }
+      if (log.isTraceEnabled())
+      {
+         log.trace("Connection checked out: " + connection);
+      }
       return connection;
    }
 
@@ -95,8 +98,12 @@
       try
       {
          DataSources.destroy(ds);
-         if (log.isDebugEnabled()) { log.debug("Pooled datasource destroyed."); }
-      } catch (SQLException sqle)
+         if (log.isDebugEnabled())
+         {
+            log.debug("Pooled datasource destroyed.");
+         }
+      }
+      catch (SQLException sqle)
       {
          log.warn("Could not destroy C3P0 connection pool: " + ds, sqle);
       }

Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -14,6 +14,7 @@
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
+import org.jboss.cache.factories.annotations.Inject;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -71,18 +72,22 @@
     * @param cache
     * @throws CacheException
     */
+   @Inject
    public void setConfig(CacheLoaderConfig config, CacheSPI cache) throws CacheException
    {
       this.config = config == null ? new CacheLoaderConfig() : config;
       this.cache = cache;
-      try
+      if (config != null)
       {
-         loader = createCacheLoader();
+         try
+         {
+            loader = createCacheLoader();
+         }
+         catch (Exception e)
+         {
+            throw new CacheException("Unable to create cache loaders", e);
+         }
       }
-      catch (Exception e)
-      {
-         throw new CacheException("Unable to create cache loaders", e);
-      }
    }
 
    /**
@@ -100,7 +105,7 @@
       // don't use a chaining cache loader at all.
 
       ArrayList<IndividualCacheLoaderConfig> finalConfigs =
-              new ArrayList<IndividualCacheLoaderConfig>();
+            new ArrayList<IndividualCacheLoaderConfig>();
 
       // also if we are using passivation then just directly use the first cache loader.
       if (config.useChainingCacheLoader())
@@ -193,7 +198,7 @@
             * underlying cacheloader can be set. */
             if (decorator instanceof AbstractDelegatingCacheLoader)
             {
-               AbstractDelegatingCacheLoader singletonDecorator = (AbstractDelegatingCacheLoader)decorator;
+               AbstractDelegatingCacheLoader singletonDecorator = (AbstractDelegatingCacheLoader) decorator;
                /* set the cache loader to where calls will be delegated by the class providing the singleton
                * store functionality. */
                singletonDecorator.setCacheLoader(tmpLoader);
@@ -225,12 +230,12 @@
     * Sets the cache instance associated with the given cache loader. This method was created for testing purpouses
     * so that it can be overriden in the mock version of the CacheLoaderManager.
     *
-    * @param c instance of cache to be set in cache loader
+    * @param c      instance of cache to be set in cache loader
     * @param loader cache loader to which assign the cache instance
     */
    protected void setCacheInLoader(CacheSPI c, CacheLoader loader)
    {
-      loader.setCache(c);      
+      loader.setCache(c);
    }
 
    private CacheLoader createInstance(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException
@@ -401,7 +406,7 @@
       {
          CacheLoaderConfig.IndividualCacheLoaderConfig first = getCacheLoaderConfig().getFirstCacheLoaderConfig();
          if (force ||
-                 (first != null && first.isPurgeOnStartup()))
+               (first != null && first.isPurgeOnStartup()))
          {
             loader.remove(Fqn.ROOT);
          }

Modified: core/trunk/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,14 +6,15 @@
  */
 package org.jboss.cache.loader;
 
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 
@@ -37,13 +38,13 @@
 {
 
    IndividualCacheLoaderConfig config;
-   CacheImpl delegate = null;
+   CacheSPI delegate = null;
 
    public LocalDelegatingCacheLoader()
    {
    }
 
-   public LocalDelegatingCacheLoader(CacheImpl delegate)
+   public LocalDelegatingCacheLoader(CacheSPI delegate)
    {
       this.delegate = delegate;
    }
@@ -60,8 +61,11 @@
 
    public Set<?> getChildrenNames(Fqn fqn) throws Exception
    {
-      Set cn = delegate.getChildrenNames(fqn);
+      Node node = delegate.getRoot().getChild(fqn);
+      if (node == null) return null;
 
+      Set cn = node.getChildrenNames();
+
       // the cache loader contract is a bit different from the cache when it comes to dealing with childrenNames
       if (cn.isEmpty()) return null;
       return cn;
@@ -69,17 +73,17 @@
 
    public Map<Object, Object> get(Fqn name) throws Exception
    {
-      NodeSPI n = (NodeSPI) delegate.get(name);
+      NodeSPI n = (NodeSPI) delegate.getRoot().getChild(name);
       if (n == null) return null;
       // after this stage we know that the node exists.  So never return a null - at worst, an empty map.
-      Map m = n.getDataDirect();
-      if (m == null) m = new HashMap(0);
+      Map<Object, Object> m = n.getDataDirect();
+      if (m == null) m = Collections.emptyMap();
       return m;
    }
 
    public boolean exists(Fqn name) throws Exception
    {
-      return delegate.exists(name);
+      return delegate.peek(name, false, false) != null;
    }
 
    public Object put(Fqn name, Object key, Object value) throws Exception
@@ -99,15 +103,16 @@
 
    public void remove(Fqn fqn) throws Exception
    {
-      delegate.remove(fqn);
+      delegate.removeNode(fqn);
    }
 
    public void removeData(Fqn fqn) throws Exception
    {
-      delegate.removeData(fqn);
+      Node node = delegate.getRoot().getChild(fqn);
+      if (node != null) node.clearData();
    }
 
-   protected void setDelegateCache(CacheImpl delegate)
+   protected void setDelegateCache(CacheSPI delegate)
    {
       this.delegate = delegate;
    }

Modified: core/trunk/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -54,10 +54,6 @@
    static Log log = LogFactory.getLog(TcpCacheServer.class);
 
 
-   public TcpCacheServer()
-   {
-   }
-
    public String getBindAddress()
    {
       return bind_addr != null ? bind_addr.toString() : "n/a";
@@ -118,8 +114,8 @@
             if (cache == null)
             {
                throw new CacheException("cache cannot be obtained from CacheJmxWrapperMBean;" +
-                                        " be sure start() is invoked on wrapper before it is invoked on the" +
-                                        " TcpCacheServer");
+                     " be sure start() is invoked on wrapper before it is invoked on the" +
+                     " TcpCacheServer");
             }
          }
          else if (config != null)

Modified: core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -128,9 +128,9 @@
     * Return a copy of the reader lock owner in List. Size is zero is not available. Note that this list
     * is synchronized.
     *
-    * @return Set of readers
+    * @return Collection<Object> of readers
     */
-   public Set<Object> getReaderOwners()
+   public Collection<Object> getReaderOwners()
    {
       return map_.readerOwners();
    }
@@ -213,7 +213,7 @@
             release(caller);// bug fix: remember to release the read lock before throwing the exception
             map_.removeReader(caller);
             String errStr = "upgrade lock for " + getFqn() + " could not be acquired after " + timeout + " ms." +
-                            " Lock map ownership " + map_.printInfo() + " (caller=" + caller + ", lock info: " + toString(true) + ')';
+                  " Lock map ownership " + map_.printInfo() + " (caller=" + caller + ", lock info: " + toString(true) + ')';
             log.trace(errStr);
             throw new UpgradeException(errStr);
          }
@@ -239,7 +239,7 @@
          if (!rc)
          {
             String errStr = "write lock for " + getFqn() + " could not be acquired after " + timeout + " ms. " +
-                            "Locks: " + map_.printInfo() + " (caller=" + caller + ", lock info: " + toString(true) + ')';
+                  "Locks: " + map_.printInfo() + " (caller=" + caller + ", lock info: " + toString(true) + ')';
             log.trace(errStr);
             throw new TimeoutException(errStr);
          }

Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,10 +6,10 @@
  */
 package org.jboss.cache.lock;
 
-import org.jboss.cache.util.concurrent.ConcurrentHashSet;
-
+import java.util.Collection;
 import java.util.Collections;
-import java.util.Set;
+import java.util.LinkedList;
+import java.util.List;
 
 /**
  * Provide lock ownership mapping.
@@ -25,13 +25,9 @@
 
    private Object writeOwner_ = null;
 
-   // This is more efficient (lower CPU utilisation and better concurrency) than a CopyOnWriteArraySet.
-   private final Set<Object> readOwnerList_ = new ConcurrentHashSet<Object>();
+   // This is more efficient (lower CPU utilisation and better concurrency) than a CopyOnWriteArraySet or ConcurrentHashSet.
+   private final List<Object> readOwnerList_ = Collections.synchronizedList(new LinkedList<Object>());
 
-   public LockMap()
-   {
-   }
-
    /**
     * Check whether this owner has reader or writer ownership.
     *
@@ -116,9 +112,9 @@
    /**
     * Returns an unmodifiable set of reader owner objects.
     */
-   public Set<Object> readerOwners()
+   public Collection<Object> readerOwners()
    {
-      return Collections.unmodifiableSet(readOwnerList_);
+      return Collections.unmodifiableList(readOwnerList_);
    }
 
    public void releaseReaderOwners(LockStrategy lock)

Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -1,10 +1,11 @@
 package org.jboss.cache.lock;
 
+import java.util.Collection;
 import java.util.Set;
 
 
 /**
- * Interface for a lock for nodes. 
+ * Interface for a lock for nodes.
  */
 public interface NodeLock
 {
@@ -15,13 +16,13 @@
    }
 
    /**
-    * Returns a copy of the reader lock owner in List. 
+    * Returns a copy of the reader lock owner in List.
     * Size is zero is not available. Note that this list
     * is synchronized.
     *
-    * @return Set of readers
+    * @return Collection<Object> of readers
     */
-   Set getReaderOwners();
+   Collection<Object> getReaderOwners();
 
    /**
     * Returns the writer lock owner object. Null if not available.
@@ -98,8 +99,9 @@
 
    /**
     * Recursively acquire locks for this node and all subnodes.
-    * @param caller lock owner
-    * @param timeout time to wait
+    *
+    * @param caller    lock owner
+    * @param timeout   time to wait
     * @param lock_type type of lock
     * @return locks acquired
     * @throws LockingException

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -12,6 +12,8 @@
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
 import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.transaction.GlobalTransaction;
 
 import java.io.ByteArrayOutputStream;
@@ -39,6 +41,12 @@
     */
    private Map<GlobalTransaction, Fqn> transactions = new ConcurrentHashMap<GlobalTransaction, Fqn>(16);
 
+   @Inject
+   private void injectDependencies(RegionManager regionManager, Configuration configuration)
+   {
+      init(regionManager, configuration.isInactiveOnStartup(), configuration.isUseRegionBasedMarshalling());
+   }
+
    protected void init(RegionManager manager, boolean defaultInactive, boolean useRegionBasedMarshalling)
    {
       this.useRegionBasedMarshalling = useRegionBasedMarshalling;
@@ -135,7 +143,7 @@
          case MethodDeclarations.dataGravitationMethod_id:
          case MethodDeclarations.evictNodeMethodLocal_id:
          case MethodDeclarations.evictVersionedNodeMethodLocal_id:
-         case MethodDeclarations.invalidateMethodLocal_id:   
+         case MethodDeclarations.invalidateMethodLocal_id:
          case MethodDeclarations.getChildrenNamesMethodLocal_id:
          case MethodDeclarations.getDataMapMethodLocal_id:
          case MethodDeclarations.getKeysMethodLocal_id:

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -67,6 +67,10 @@
    // this is pretty nasty, and may need more thought.
    protected final ThreadLocal<Fqn> regionForCall = new ThreadLocal<Fqn>();
 
+   public CacheMarshaller200()
+   {
+   }
+
    public CacheMarshaller200(RegionManager manager, boolean defaultInactive, boolean useRegionBasedMarshalling)
    {
       init(manager, defaultInactive, useRegionBasedMarshalling);
@@ -108,7 +112,8 @@
             // a Fqn region.
             region = regionForCall.get();
             regionForCall.remove();
-            if (log.isTraceEnabled()) log.trace("Suspect this is a return value.  Extract region from ThreadLocal as " + region);
+            if (log.isTraceEnabled())
+               log.trace("Suspect this is a return value.  Extract region from ThreadLocal as " + region);
 
             // otherwise, we need to marshall the retval.
          }
@@ -184,7 +189,8 @@
       }
       if (region == null)
       {
-         if (log.isDebugEnabled()) log.debug("Region does not exist for Fqn " + regionFqn + " - not using a context classloader.");
+         if (log.isDebugEnabled())
+            log.debug("Region does not exist for Fqn " + regionFqn + " - not using a context classloader.");
          retValue = unmarshallObject(in, refMap);
       }
       else
@@ -223,7 +229,7 @@
          {
             // No region but default inactive means region is inactive
             throw new InactiveRegionException("Cannot unmarshall message for region " + fqn + ". By default region " + fqn
-                    + " is inactive.");
+                  + " is inactive.");
          }
          else
          {
@@ -766,6 +772,7 @@
 
    /**
     * Reads a reference from a given stream.
+    *
     * @param in the stream to read from
     * @return an int representing a reference in RefMap.
     * @throws IOException propagated from the OIS
@@ -777,7 +784,8 @@
 
    /**
     * Writes a reference to a given object output stream.
-    * @param out the stream to write to
+    *
+    * @param out       the stream to write to
     * @param reference the reference to write
     * @throws java.io.IOException propagated from the OOS
     */

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -18,6 +18,10 @@
  */
 public class CacheMarshaller210 extends CacheMarshaller200
 {
+   public CacheMarshaller210()
+   {
+   }
+
    public CacheMarshaller210(RegionManager manager, boolean defaultInactive, boolean useRegionBasedMarshalling)
    {
       super(manager, defaultInactive, useRegionBasedMarshalling);

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallFactory.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallFactory.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -16,10 +16,12 @@
  */
 public class MethodCallFactory
 {
+
    /**
-    * Creates and initialised an instance of MethodCall
+    * Creates and initialised an instance of MethodCall.
     *
     * @param method    Method instance of the MethodCall
+    * @param target    The InvocationTarget instance to invoke the call on
     * @param arguments list of parameters
     * @return a new instance of MethodCall with the method id initialised
     */

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -5,11 +5,6 @@
 
    private static final long serialVersionUID = 4851793846346021014L;
 
-   public NodeDataMarker()
-   {
-      super();
-   }
-
    public boolean isMarker()
    {
       return true;

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -31,11 +31,11 @@
  */
 public class VersionAwareMarshaller extends AbstractMarshaller
 {
-   
+
    private static final Log log = LogFactory.getLog(VersionAwareMarshaller.class);
    private static final int VERSION_200 = 20;
    private static final int VERSION_210 = 21;
-   
+
    private RegionManager manager;
    private boolean defaultInactive, useRegionBasedMarshalling;
    Marshaller defaultMarshaller;
@@ -44,6 +44,11 @@
 
    public VersionAwareMarshaller(RegionManager manager, boolean defaultInactive, boolean useRegionBasedMarshalling, String version)
    {
+      this(manager, defaultInactive, useRegionBasedMarshalling, version, null);
+   }
+
+   public VersionAwareMarshaller(RegionManager manager, boolean defaultInactive, boolean useRegionBasedMarshalling, String version, Marshaller defaultMarshaller)
+   {
       this.manager = manager;
       this.defaultInactive = defaultInactive;
       this.useRegionBasedMarshalling = useRegionBasedMarshalling;
@@ -54,12 +59,22 @@
       versionInt = toMinorVersionInt(version);
 
       // this will cause the correct marshaller to be created and put in the map of marshallers
-      defaultMarshaller = getMarshaller(versionInt);
+      if (defaultMarshaller == null)
+      {
+         this.defaultMarshaller = getMarshaller(versionInt);
+      }
+      else
+      {
+         log.debug("Using the marshaller passed in - " + defaultMarshaller);
+         this.defaultMarshaller = defaultMarshaller;
+         marshallers.put(versionInt, defaultMarshaller);
+      }
 
+
       if (log.isDebugEnabled())
       {
          log.debug("Initialised with version " + version + " and versionInt " + versionInt);
-         log.debug("Using default marshaller " + defaultMarshaller.getClass());
+         log.debug("Using default marshaller class " + this.defaultMarshaller.getClass());
       }
    }
 
@@ -68,6 +83,11 @@
       this(regionManager, configuration.isInactiveOnStartup(), configuration.isUseRegionBasedMarshalling(), configuration.getReplVersionString());
    }
 
+   public VersionAwareMarshaller(RegionManager regionManager, Configuration configuration, Marshaller defaultMarshaller)
+   {
+      this(regionManager, configuration.isInactiveOnStartup(), configuration.isUseRegionBasedMarshalling(), configuration.getReplVersionString(), defaultMarshaller);
+   }
+
    /**
     * Converts versions to known compatible version ids.
     * <p/>
@@ -195,13 +215,14 @@
             if (marshaller == null)
             {
                marshaller = new CacheMarshaller200(manager, defaultInactive, useRegionBasedMarshalling);
-               marshallers.put(VERSION_210, marshaller);
+               marshallers.put(VERSION_200, marshaller);
             }
             break;
          case VERSION_210:
             knownVersion = true;
          default:
-            if (!knownVersion) log.warn("Unknown replication version String.  Falling back to the default marshaller, which is Version 2.1.0.");
+            if (!knownVersion)
+               log.warn("Unknown replication version String.  Falling back to the default marshaller, which is Version 2.1.0.");
             marshaller = marshallers.get(VERSION_210);
             if (marshaller == null)
             {

Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -13,6 +13,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.notifications.annotation.*;
 import org.jboss.cache.notifications.event.*;
 import static org.jboss.cache.notifications.event.Event.Type.*;
@@ -45,17 +46,27 @@
    private static Class emptyMap = Collections.emptyMap().getClass();
    private static Class singletonMap = Collections.singletonMap(null, null).getClass();
    private static final Class[] allowedMethodAnnotations =
-           {
-                   CacheStarted.class, CacheStopped.class, CacheBlocked.class, CacheUnblocked.class, NodeCreated.class, NodeRemoved.class, NodeVisited.class, NodeModified.class, NodeMoved.class,
-                   NodeActivated.class, NodePassivated.class, NodeLoaded.class, NodeEvicted.class, TransactionRegistered.class, TransactionCompleted.class, ViewChanged.class
-           };
+         {
+               CacheStarted.class, CacheStopped.class, CacheBlocked.class, CacheUnblocked.class, NodeCreated.class, NodeRemoved.class, NodeVisited.class, NodeModified.class, NodeMoved.class,
+               NodeActivated.class, NodePassivated.class, NodeLoaded.class, NodeEvicted.class, TransactionRegistered.class, TransactionCompleted.class, ViewChanged.class
+         };
    private static final Class[] parameterTypes =
-           {
-                   CacheStartedEvent.class, CacheStoppedEvent.class, CacheBlockedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemovedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedEvent.class,
-                   NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class
-           };
+         {
+               CacheStartedEvent.class, CacheStoppedEvent.class, CacheBlockedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemovedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedEvent.class,
+               NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class
+         };
    final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
 
+   public Notifier()
+   {
+   }
+
+   @Inject
+   private void injectDependencies(Cache cache)
+   {
+      this.cache = cache;
+   }
+
    public Notifier(Cache cache)
    {
       this.cache = cache;

Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -8,7 +8,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Node;
 import org.jboss.cache.NodeSPI;
@@ -31,11 +31,11 @@
 
    private Log log = LogFactory.getLog(getClass().getName());
 
-   private CacheImpl cache;
+   private CacheSPI cache;
 
    private Set<Fqn> internalFqns;
 
-   protected DefaultStateTransferGenerator(CacheImpl cache)
+   protected DefaultStateTransferGenerator(CacheSPI cache)
    {
       this.cache = cache;
       this.internalFqns = cache.getInternalFqns();
@@ -179,10 +179,4 @@
    {
       // no-op in this base class      
    }
-
-   protected CacheImpl getTreeCache()
-   {
-      return cache;
-   }
-
 }

Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -9,18 +9,18 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.Node;
 import org.jboss.cache.NodeFactory;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.Region;
-import org.jboss.cache.RegionManager;
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.eviction.EvictedEventNode;
 import org.jboss.cache.eviction.NodeEventType;
 import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.CacheLoaderManager;
 import org.jboss.cache.marshall.NodeData;
 import org.jboss.cache.marshall.NodeDataExceptionMarker;
 import org.jboss.cache.marshall.NodeDataMarker;
@@ -40,7 +40,7 @@
 
    protected Log log = LogFactory.getLog(getClass().getName());
 
-   private CacheImpl cache;
+   private CacheSPI cache;
 
    private Fqn targetFqn;
 
@@ -50,14 +50,14 @@
 
    private Set<Fqn> internalFqns;
 
-   public DefaultStateTransferIntegrator(Fqn targetFqn, CacheImpl cache)
+   public DefaultStateTransferIntegrator(Fqn targetFqn, CacheSPI cache)
    {
       this.targetFqn = targetFqn;
       this.cache = cache;
       this.factory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
       this.nodeType = cache.getConfiguration().isNodeLockingOptimistic()
-                      ? NodeFactory.NodeType.VERSIONED_NODE
-                      : NodeFactory.NodeType.UNVERSIONED_NODE;
+            ? NodeFactory.NodeType.VERSIONED_NODE
+            : NodeFactory.NodeType.UNVERSIONED_NODE;
       this.internalFqns = cache.getInternalFqns();
    }
 
@@ -91,13 +91,13 @@
          notifyAllNodesCreated(cache.getInvocationContext(), target);
       }
       catch (Exception e)
-      {         
+      {
          throw new CacheException(e);
       }
       finally
       {
          if (!transientSet)
-         {            
+         {
             target.clearDataDirect();
             target.removeChildrenDirect();
          }
@@ -121,8 +121,8 @@
    protected void integratePersistentState(ObjectInputStream in) throws Exception
    {
 
-      CacheLoader loader = cache.getCacheLoader();
-      if (loader == null)
+      CacheLoaderManager loaderManager = cache.getCacheLoaderManager();
+      if (loaderManager == null)
       {
          if (log.isTraceEnabled())
          {
@@ -131,6 +131,7 @@
       }
       else
       {
+         CacheLoader loader = loaderManager.getCacheLoader();
          if (log.isTraceEnabled())
          {
             log.trace("integrating persistent state using " + loader.getClass().getName());
@@ -152,7 +153,7 @@
          catch (ClassCastException cce)
          {
             log.error("Failed integrating persistent state. One of cacheloaders is not"
-                      + " adhering to state stream format. See JBCACHE-738.");
+                  + " adhering to state stream format. See JBCACHE-738.");
             throw cce;
          }
          finally
@@ -173,11 +174,6 @@
       }
    }
 
-   protected CacheImpl getCache()
-   {
-      return cache;
-   }
-
    protected NodeFactory getFactory()
    {
       return factory;
@@ -201,13 +197,13 @@
    {
       if (curr == null) return;
       ctx.setOriginLocal(false);
-      getCache().getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx);
-      getCache().getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx);
+      cache.getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx);
+      cache.getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx);
       // AND notify that they have been modified!!
       if (!curr.getKeysDirect().isEmpty())
       {
-         getCache().getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
-         getCache().getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getDataDirect(), ctx);
+         cache.getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
+         cache.getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getDataDirect(), ctx);
       }
       ctx.setOriginLocal(true);
 
@@ -268,7 +264,7 @@
                Fqn tferFqn = nd.getFqn();
                Fqn tgtFqn = target.getFqn();
                boolean move = tgtFqn.isChildOrEquals(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)
-                              && !tferFqn.isChildOrEquals(tgtFqn);
+                     && !tferFqn.isChildOrEquals(tgtFqn);
                // If it is an integration, calculate how many levels of offset
                int offset = move ? tgtFqn.size() - tferFqn.size() : 0;
 
@@ -346,7 +342,7 @@
          if (region != null && region.getEvictionPolicy() != null)
          {
             region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT,
-                                                     attrs == null ? 0 : attrs.size()));
+                  attrs == null ? 0 : attrs.size()));
          }
 
          // Recursively call, which will walk down the tree
@@ -357,7 +353,7 @@
       {
          NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
          throw new CacheException("State provider node " + ndem.getCacheNodeIdentity()
-                                  + " threw exception during loadState", ndem.getCause());
+               + " threw exception during loadState", ndem.getCause());
       }
       return null;
    }

Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,7 +6,7 @@
  */
 package org.jboss.cache.statetransfer;
 
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Version;
 
@@ -31,8 +31,7 @@
     * @return the {@link StateTransferGenerator}
     * @throws IllegalStateException if the cache's ReplicationVersion is < 2.0.0
     */
-   public static StateTransferGenerator
-   getStateTransferGenerator(CacheImpl cache)
+   public static StateTransferGenerator getStateTransferGenerator(CacheSPI cache)
    {
       short version = cache.getConfiguration().getReplicationVersion();
 
@@ -44,10 +43,10 @@
          return new DefaultStateTransferGenerator(cache); // current default
    }
 
-   public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheImpl cache)
-           throws Exception
+   public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheSPI cache)
+         throws Exception
    {
-      short version = 0;
+      short version;
       try
       {
          version = (Short) cache.getMarshaller().objectFromObjectStream(in);
@@ -59,7 +58,9 @@
          {
             in.close();
          }
-         catch (IOException ignored) {}
+         catch (IOException ignored)
+         {
+         }
          throw new IllegalStateException("Stream corrupted ", io);
       }
 
@@ -70,5 +71,4 @@
       else
          return new DefaultStateTransferIntegrator(fqn, cache); // current default
    }
-
 }

Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -9,9 +9,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.loader.CacheLoaderManager;
 import org.jboss.cache.lock.NodeLock;
 import org.jboss.cache.lock.TimeoutException;
@@ -30,16 +31,21 @@
 
    public static final String PARTIAL_STATE_DELIMITER = "_PARTIAL_STATE_DELIMITER";
 
-   private final CacheImpl cache;
+   private CacheSPI cache;
 
-   public StateTransferManager(CacheImpl cache)
+   public StateTransferManager()
    {
+   }
+
+   @Inject
+   private void injectDependencies(CacheSPI cache)
+   {
       this.cache = cache;
    }
 
-   public CacheImpl getTreeCache()
+   public StateTransferManager(CacheSPI cache)
    {
-      return cache;
+      this.cache = cache;
    }
 
    /**
@@ -64,7 +70,7 @@
    public void getState(ObjectOutputStream out, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Throwable
    {
       // can't give state for regions currently being activated/inactivated
-      boolean canProvideState = (!cache.getRegionManager().isInactive(fqn) && cache.findNode(fqn) != null);
+      boolean canProvideState = (!cache.getRegionManager().isInactive(fqn) && cache.peek(fqn, false, false) != null);
 
       boolean fetchTransientState = cache.getConfiguration().isFetchInMemoryState();
       CacheLoaderManager cacheLoaderManager = cache.getCacheLoaderManager();
@@ -76,7 +82,7 @@
          StateTransferGenerator generator = getStateTransferGenerator();
          Object owner = getOwnerForLock();
          long startTime = System.currentTimeMillis();
-         NodeSPI rootNode = cache.findNode(fqn);
+         NodeSPI rootNode = cache.peek(fqn, false, false);
 
          try
          {
@@ -108,7 +114,7 @@
             {
                exceptionMessage += " Region for fqn " + fqn + " is inactive.";
             }
-            if (cache.findNode(fqn) == null)
+            if (cache.peek(fqn, false, false) == null)
             {
                exceptionMessage += " There is no cache node at fqn " + fqn;
             }
@@ -141,17 +147,16 @@
     */
    public void setState(ObjectInputStream in, Fqn targetRoot) throws Exception
    {
-      CacheImpl cache = getTreeCache();
-      NodeSPI target = cache.findNode(targetRoot);
+      NodeSPI target = cache.peek(targetRoot, false, false);
       if (target == null)
       {
          // Create the integration root, but do not replicate
          cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
-         
+
          //needed for BR state transfers
          cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
          cache.put(targetRoot, null);
-         target = cache.findNode(targetRoot);
+         target = cache.peek(targetRoot, false, false);
       }
       Object o = cache.getMarshaller().objectFromObjectStream(in);
       Boolean hasState = (Boolean) o;
@@ -162,7 +167,7 @@
       else
       {
          throw new CacheException("Cache instance at " + cache.getLocalAddress()
-                                  + " cannot integrate state since state provider could not provide state due to " + cache.getMarshaller().objectFromObjectStream(in));
+               + " cannot integrate state since state provider could not provide state due to " + cache.getMarshaller().objectFromObjectStream(in));
       }
    }
 
@@ -246,7 +251,7 @@
       catch (TimeoutException te)
       {
          log.error("Caught TimeoutException acquiring locks on region " +
-                   root.getFqn(), te);
+               root.getFqn(), te);
          if (force)
          {
             // Until we have FLUSH in place, don't force locks
@@ -289,12 +294,12 @@
 
    protected StateTransferGenerator getStateTransferGenerator()
    {
-      return StateTransferFactory.getStateTransferGenerator(getTreeCache());
+      return StateTransferFactory.getStateTransferGenerator(cache);
    }
 
    protected StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream istream, Fqn fqn) throws Exception
    {
-      return StateTransferFactory.getStateTransferIntegrator(istream, fqn, getTreeCache());
+      return StateTransferFactory.getStateTransferIntegrator(istream, fqn, cache);
    }
 
    /**
@@ -303,7 +308,7 @@
     */
    private Object getOwnerForLock()
    {
-      Object owner = getTreeCache().getCurrentTransaction();
+      Object owner = cache.getCurrentTransaction();
       if (owner == null)
       {
          owner = Thread.currentThread();

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManager.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManager.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -6,31 +6,32 @@
 /**
  * Not really a transaction manager in the truest sense of the word.  Only used to batch up operations.  Proper
  * transactional symantics of rollbacks and recovery are NOT used here.  This is used by PojoCache.
- * 
+ *
  * @author bela
  * @version $Revision$
  *          Date: May 15, 2003
  *          Time: 4:11:37 PM
  */
-public class BatchModeTransactionManager extends DummyBaseTransactionManager {
-   static BatchModeTransactionManager instance=null;
-   static Log log=LogFactory.getLog(BatchModeTransactionManager.class);
-   private static final long serialVersionUID = 5656602677430350961L;  
+public class BatchModeTransactionManager extends DummyBaseTransactionManager
+{
+   static BatchModeTransactionManager instance = null;
+   static Log log = LogFactory.getLog(BatchModeTransactionManager.class);
+   private static final long serialVersionUID = 5656602677430350961L;
 
-   public BatchModeTransactionManager() {
-   }
-
-   public static BatchModeTransactionManager getInstance() {
-      if(instance == null) {
-         instance=new BatchModeTransactionManager();
+   public static BatchModeTransactionManager getInstance()
+   {
+      if (instance == null)
+      {
+         instance = new BatchModeTransactionManager();
       }
       return instance;
    }
 
-   public static void destroy() {
-      if(instance == null) return;
+   public static void destroy()
+   {
+      if (instance == null) return;
       instance.setTransaction(null);
-      instance=null;
+      instance = null;
    }
 
 }

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyContextFactory.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyContextFactory.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -10,12 +10,13 @@
  *         Date: May 15, 2003
  *         Time: 6:22:02 PM
  */
-public class DummyContextFactory implements InitialContextFactory {
+public class DummyContextFactory implements InitialContextFactory
+{
 
-   static Context instance=null;
+   static Context instance = null;
 
-   public DummyContextFactory() {
-      ;
+   public DummyContextFactory()
+   {
    }
 
    /**
@@ -34,9 +35,10 @@
     *         interface.
     * @throws NamingException If cannot create an initial context.
     */
-   public Context getInitialContext(Hashtable environment) throws NamingException {
-      if(instance == null)
-         instance=new DummyContext();
+   public Context getInitialContext(Hashtable environment) throws NamingException
+   {
+      if (instance == null)
+         instance = new DummyContext();
       return instance;
    }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -1,14 +1,13 @@
 package org.jboss.cache.transaction;
 
-import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import java.util.Properties;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 /**
  * Simple transaction manager implementation that maintains transaction state
  * in memory only.
@@ -27,10 +26,6 @@
 
    private static final long serialVersionUID = 4396695354693176535L;
 
-   public DummyTransactionManager()
-   {
-   }
-
    public static DummyTransactionManager getInstance()
    {
       if (instance == null)

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/JBossTransactionManagerLookup.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/JBossTransactionManagerLookup.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/JBossTransactionManagerLookup.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -11,13 +11,12 @@
  * @author Bela Ban, Aug 26 2003
  * @version $Id$
  */
-public class JBossTransactionManagerLookup implements TransactionManagerLookup {
+public class JBossTransactionManagerLookup implements TransactionManagerLookup
+{
 
-   public JBossTransactionManagerLookup() {
+   public TransactionManager getTransactionManager() throws Exception
+   {
+      return (TransactionManager) new InitialContext().lookup("java:/TransactionManager");
    }
 
-   public TransactionManager getTransactionManager() throws Exception {
-      return (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
-   }
-
 }

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -21,10 +21,6 @@
 {
    private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
 
-   public OptimisticTransactionEntry()
-   {
-   }
-
    public String toString()
    {
       StringBuffer sb = new StringBuffer(super.toString());

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -96,13 +96,6 @@
    private List<Fqn> removedNodes = new LinkedList<Fqn>();
 
    /**
-    * Constructs a new TransactionEntry.
-    */
-   public TransactionEntry()
-   {
-   }
-
-   /**
     * Adds a modification to the modification list.
     */
    public void addModification(MethodCall m)

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java	2007-12-11 17:26:38 UTC (rev 4833)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java	2007-12-11 17:28:33 UTC (rev 4834)
@@ -45,13 +45,6 @@
    private static final Log log = LogFactory.getLog(TransactionTable.class);
 
    /**
-    * Constructs a new table.
-    */
-   public TransactionTable()
-   {
-   }
-
-   /**
     * Returns the number of local transactions.
     */
    public int getNumLocalTransactions()
@@ -279,7 +272,7 @@
    /**
     * Add the lock to the list of locks maintained for this transaction
     * (needed for release of locks on commit or rollback)
-     */
+    */
    public void recordNodeLock(GlobalTransaction gtx, NodeLock lock)
    {
       try




More information about the jbosscache-commits mailing list