[jbosscache-commits] JBoss Cache SVN: r6859 - in core/branches/flat/src/main/java/org/jboss/starobrno: commands and 11 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Oct 8 05:34:41 EDT 2008


Author: mircea.markus
Date: 2008-10-08 05:34:41 -0400 (Wed, 08 Oct 2008)
New Revision: 6859

Added:
   core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/AbstractVisitor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/DataCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/VisitableCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/AbstractDataCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/DefaultFactoryFor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Destroy.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Inject.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Start.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Stop.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/PrePostProcessingCommandInterceptor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/SkipCheckChainedInterceptor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/invocation/
   core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java
   core/branches/flat/src/main/java/org/jboss/starobrno/transaction/
   core/branches/flat/src/main/java/org/jboss/starobrno/transaction/GlobalTransaction.java
   core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionContext.java
Removed:
   core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
   core/branches/flat/src/main/java/org/jboss/starobrno/test/
Modified:
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
   core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java
   core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
Log:


Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java	2008-10-08 09:30:07 UTC (rev 6858)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno;
-
-import org.jboss.util.NotImplementedException;
-import org.jboss.starobrno.config.CacheConfig;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Collection;
-import java.util.HashSet;
-
-/**
- * @author Mircea.Markus at jboss.com
- */
-public class Cache implements ConcurrentMap
-{
-   private ConcurrentHashMap data = new ConcurrentHashMap();
-   private Map<String, AtomicGroup> atomicGroups = new ConcurrentHashMap<String, AtomicGroup>(); 
-   private CacheConfig cacheConfig;
-
-
-   public Cache(CacheConfig cacheConfig)
-   {
-      this.cacheConfig = cacheConfig;
-   }
-
-   public Object putIfAbsent(Object key, Object value)
-   {
-      return data.putIfAbsent(key, value);
-   }
-
-   public boolean remove(Object key, Object value)
-   {
-      return data.remove(key, value);
-   }
-
-   public boolean replace(Object key, Object oldValue, Object newValue)
-   {
-      return data.replace(key, oldValue, newValue);
-   }
-
-   public Object replace(Object key, Object value)
-   {
-      return data.replace(key, value);
-   }
-
-   public int size()
-   {
-      throw new NotImplementedException("not impl!");
-   }
-
-   public boolean isEmpty()
-   {
-      throw new NotImplementedException("not impl!");
-   }
-
-   public boolean containsKey(Object key)
-   {
-      return false;
-   }
-
-   public boolean containsValue(Object value)
-   {
-      return data.contains(value);
-   }
-
-   public Object get(Object key)
-   {
-      return data.get(key);
-   }
-
-   public Object put(Object key, Object value)
-   {
-      return data.put(key, value);
-   }
-
-   public Object remove(Object key)
-   {
-      return data.remove(key);
-   }
-
-   public void putAll(Map t)
-   {
-      data.putAll(t);
-   }
-
-   public void clear()
-   {
-      data.clear();
-   }
-
-   public Set keySet()
-   {
-      throw new NotImplementedException("not impl!");
-   }
-
-   public Collection values()
-   {
-      throw new NotImplementedException("not impl!");
-   }
-
-   public Set entrySet()
-   {
-      throw new NotImplementedException("not impl!");
-   }
-
-   public boolean equals(Object o)
-   {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-
-      Cache cache = (Cache) o;
-
-      if (data != null ? !data.equals(cache.data) : cache.data != null) return false;
-
-      return true;
-   }
-
-   public int hashCode()
-   {
-      return (data != null ? data.hashCode() : 0);
-   }
-}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public interface Cache extends ConcurrentMap
+{
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.context.InvocationContext;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class CacheDelegate implements Cache
+{
+
+   protected InvocationContextContainer invocationContextContainer;
+
+   public Object putIfAbsent(Object key, Object value)
+   {
+      InvocationContext ctx = invocationContextContainer.get();
+      return null;
+   }
+
+   public boolean remove(Object key, Object value)
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean replace(Object key, Object oldValue, Object newValue)
+   {
+      return false;
+   }
+
+   public Object replace(Object key, Object value)
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public int size()
+   {
+      return 0;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean isEmpty()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean containsKey(Object key)
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean containsValue(Object value)
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Object get(Object key)
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Object put(Object key, Object value)
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Object remove(Object key)
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void putAll(Map t)
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void clear()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Set keySet()
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Collection values()
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Set entrySet()
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   protected void cacheStatusCheck(org.jboss.cache.InvocationContext ctx)
+   {
+      if (invocationContextContainer == null) throw new IllegalStateException("The cache has been destroyed!");
+   }   
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/CacheException.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+/**
+ * Thrown when operations on {@link org.jboss.cache.Cache} or {@link org.jboss.cache.Node} fail unexpectedly.
+ * <p/>
+ * Specific subclasses such as {@link org.jboss.cache.lock.TimeoutException}, {@link org.jboss.cache.config.ConfigurationException} and {@link org.jboss.cache.lock.LockingException}
+ * have more specific uses.
+ *
+ * @author <a href="mailto:bela at jboss.org">Bela Ban</a>
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
+ */
+public class CacheException extends RuntimeException
+{
+
+   private static final long serialVersionUID = -4386393072593859164L;
+
+   public CacheException()
+   {
+      super();
+   }
+
+   public CacheException(Throwable cause)
+   {
+      super(cause);
+   }
+
+   public CacheException(String msg)
+   {
+      super(msg);
+   }
+
+   public CacheException(String msg, Throwable cause)
+   {
+      super(msg, cause);
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java (from rev 6852, core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import org.jboss.util.NotImplementedException;
+import org.jboss.starobrno.config.CacheConfig;
+
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class CacheImpl implements Cache
+{
+   private ConcurrentHashMap data = new ConcurrentHashMap();
+   private Map<String, AtomicGroup> atomicGroups = new ConcurrentHashMap<String, AtomicGroup>(); 
+   private CacheConfig cacheConfig;
+
+
+   public CacheImpl(CacheConfig cacheConfig)
+   {
+      this.cacheConfig = cacheConfig;
+   }
+
+   public Object putIfAbsent(Object key, Object value)
+   {
+      return data.putIfAbsent(key, value);
+   }
+
+   public boolean remove(Object key, Object value)
+   {
+      return data.remove(key, value);
+   }
+
+   public boolean replace(Object key, Object oldValue, Object newValue)
+   {
+      return data.replace(key, oldValue, newValue);
+   }
+
+   public Object replace(Object key, Object value)
+   {
+      return data.replace(key, value);
+   }
+
+   public int size()
+   {
+      throw new NotImplementedException("not impl!");
+   }
+
+   public boolean isEmpty()
+   {
+      throw new NotImplementedException("not impl!");
+   }
+
+   public boolean containsKey(Object key)
+   {
+      return false;
+   }
+
+   public boolean containsValue(Object value)
+   {
+      return data.contains(value);
+   }
+
+   public Object get(Object key)
+   {
+      return data.get(key);
+   }
+
+   public Object put(Object key, Object value)
+   {
+      return data.put(key, value);
+   }
+
+   public Object remove(Object key)
+   {
+      return data.remove(key);
+   }
+
+   public void putAll(Map t)
+   {
+      data.putAll(t);
+   }
+
+   public void clear()
+   {
+      data.clear();
+   }
+
+   public Set keySet()
+   {
+      throw new NotImplementedException("not impl!");
+   }
+
+   public Collection values()
+   {
+      throw new NotImplementedException("not impl!");
+   }
+
+   public Set entrySet()
+   {
+      throw new NotImplementedException("not impl!");
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      CacheImpl cache = (CacheImpl) o;
+
+      if (data != null ? !data.equals(cache.data) : cache.data != null) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      return (data != null ? data.hashCode() : 0);
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java	2008-10-08 09:30:07 UTC (rev 6858)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -33,19 +33,19 @@
 public class CacheManager
 {
    private Configuration config;
-   private Map<String, Cache> caches = new HashMap<String, Cache>();
+   private Map<String, CacheImpl> caches = new HashMap<String, CacheImpl>();
 
    public CacheManager(Configuration config)
    {
       this.config = config;
    }
 
-   public Cache getCache(String confName)
+   public CacheImpl getCache(String confName)
    {
       if (caches.containsKey(confName)) return caches.get(confName);
       CacheConfig config = this.config.getCacheConfig(confName);
       if (config == null) throw new IllegalArgumentException("No such cache config: " + confName);
-      Cache result = new Cache(config);
+      CacheImpl result = new CacheImpl(config);
       caches.put(confName, result);
       return result;
    }

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/AbstractVisitor.java (from rev 6854, core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/AbstractVisitor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/AbstractVisitor.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+
+import java.util.Collection;
+
+/**
+ * An abstract implementation of a Visitor that delegates all visit calls to a default handler which can be overridden.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @author Manik Surtani
+ * @since 2.2.0
+ */
+public abstract class AbstractVisitor implements Visitor
+{
+   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+
+   /**
+    * A default handler for all commands visited.  This is called for any visit method called, unless a visit command is
+    * appropriately overridden.
+    *
+    * @param ctx     invocation context
+    * @param command command to handle
+    * @return return value
+    * @throws Throwable in the case of a problem
+    */
+   protected Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+   {
+      return null;
+   }
+
+   /**
+    * Helper method to visit a collection of VisitableCommands.
+    *
+    * @param ctx     Invocation context
+    * @param toVisit collection of commands to visit
+    * @throws Throwable in the event of problems
+    */
+   public void visitCollection(InvocationContext ctx, Collection<? extends VisitableCommand> toVisit) throws Throwable
+   {
+      for (VisitableCommand command : toVisit)
+      {
+         command.acceptVisitor(ctx, this);
+      }
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/DataCommand.java (from rev 6854, core/branches/flat/src/main/java/org/jboss/cache/commands/DataCommand.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/DataCommand.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/DataCommand.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+
+/**
+ * Commands of this type manipulate data in the cache.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public interface DataCommand extends VisitableCommand
+{
+   Object getKey();
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java (from rev 6854, core/branches/flat/src/main/java/org/jboss/cache/commands/ReplicableCommand.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.starobrno.context.InvocationContext;
+
+/**
+ * The core of the command-based cache framework.  Commands correspond to specific areas of functionality in the cache,
+ * and can be replicated using the {@link org.jboss.cache.marshall.Marshaller} framework.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @author Manik Surtani
+ * @since 2.2.0
+ */
+public interface ReplicableCommand
+{
+   /**
+    * Performs the primary function of the command.  Please see specific implementation classes for details on what is
+    * performed as well as return types.
+    * <b>Important</b>: this method will be invoked at the end of interceptors chain. It should never be called directly from
+    * a custom interceptor.
+    *
+    * @param ctx invocation context
+    * @return arbitrary return value generated by performing this command
+    * @throws Throwable in the event of problems.
+    */
+   Object perform(InvocationContext ctx) throws Throwable;
+
+   /**
+    * Used by marshallers to convert this command into an id for streaming.
+    *
+    * @return the method id of this command.  This is compatible with pre-2.2.0 MethodCall ids.
+    */
+   int getCommandId();
+
+   /**
+    * Used by marshallers to stream this command across a network
+    *
+    * @return an object array of arguments, compatible with pre-2.2.0 MethodCall args.
+    */
+   Object[] getParameters();
+
+   /**
+    * Used by the {@link org.jboss.cache.commands.CommandsFactory} to create a command from raw data read off a stream.
+    *
+    * @param commandId  command id to set.  This is usually unused but *could* be used in the event of a command having multiple IDs, such as {@link org.jboss.cache.commands.write.PutKeyValueCommand}.
+    * @param parameters object array of args
+    */
+   void setParameters(int commandId, Object[] parameters);
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/VisitableCommand.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/commands/VisitableCommand.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/VisitableCommand.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/VisitableCommand.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.starobrno.context.InvocationContext;
+
+
+/**
+ * A type of command that can accept {@link org.jboss.cache.commands.Visitor}s, such as {@link org.jboss.cache.interceptors.base.CommandInterceptor}s.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public interface VisitableCommand extends ReplicableCommand
+{
+   /**
+    * Accept a visitor, and return the result of accepting this visitor.
+    *
+    * @param ctx     invocation context
+    * @param visitor visitor to accept
+    * @return arbitrary return value
+    * @throws Throwable in the event of problems
+    */
+   Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable;
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java (from rev 6854, core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+
+/**
+ * This interface is the core of JBoss Cache, where each {@link org.jboss.cache.commands.VisitableCommand} can be visited by a Visitor implementation.
+ * Visitors which are accepted by the {@link org.jboss.cache.commands.VisitableCommand} are able to modify the command
+ * based on any logic encapsulated by the visitor.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @author Manik Surtani
+ * @since 2.2.0
+ */
+public interface Visitor
+{
+
+   /**
+    * Visits a PutKeyValueCommand.
+    *
+    * @param ctx     invocation context
+    * @param command command to visit
+    * @return response from the visit
+    * @throws Throwable in the event of problems.
+    */
+   Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable;
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java (from rev 6854, core/branches/flat/src/main/java/org/jboss/cache/commands/WriteCommand.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.commands.*;
+import org.jboss.cache.commands.DataCommand;
+
+/**
+ * A write command that has a reference to a {@link org.jboss.cache.transaction.GlobalTransaction}.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public interface WriteCommand extends DataCommand
+{
+   /**
+    * @return a GlobalTransaction associated with this command.
+    */
+   GlobalTransaction getGlobalTransaction();
+
+   /**
+    * Sets a GlobalTransaction on this command.
+    *
+    * @param gtx global transaction to set
+    */
+   void setGlobalTransaction(GlobalTransaction gtx);
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/AbstractDataCommand.java (from rev 6854, core/branches/flat/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/AbstractDataCommand.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/AbstractDataCommand.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands.read;
+
+import org.jboss.starobrno.commands.DataCommand;
+import org.jboss.starobrno.DataContainer;
+
+/**
+ * An abstract class providing basic functionality of all {@link org.jboss.cache.commands.DataCommand}s.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public abstract class AbstractDataCommand implements DataCommand
+{
+   protected DataContainer dataContainer;
+
+   public void initialize(DataContainer dataContainer)
+   {
+      this.dataContainer = dataContainer;
+   }
+
+   private Object key;
+
+   /**
+    * Basic versions of these methods
+    */
+   public Object[] getParameters()
+   {
+      return new Object[]{key};
+   }
+
+   /**
+    * Basic versions of these methods
+    */
+   public void setParameters(int commandId, Object[] args)
+   {
+      key = args[0];
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      AbstractDataCommand that = (AbstractDataCommand) o;
+
+      if (key != null ? !key.equals(that.key) : that.key != null) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result;
+      result = (dataContainer != null ? dataContainer.hashCode() : 0);
+      result = 31 * result + (key != null ? key.hashCode() : 0);
+      return result;
+   }
+
+
+   public String toString()
+   {
+      return "AbstractDataCommand{" +
+            "key=" + key +
+            '}';
+   }
+}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
+
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.commands.read.AbstractDataCommand;
+import org.jboss.starobrno.commands.Visitor;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#put(org.jboss.cache.Fqn, Object, Object)}.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class PutKeyValueCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 3;
+   public static final int VERSIONED_METHOD_ID = 39;
+
+   private static final Log log = LogFactory.getLog(org.jboss.cache.commands.write.PutKeyValueCommand.class);
+   private static final boolean trace = log.isTraceEnabled();
+
+   /* parametres */
+   protected Object key;
+   protected Object value;
+
+   public PutKeyValueCommand(GlobalTransaction gtx, Object key, Object value)
+   {
+      this.key = key;
+      this.value = value;
+   }
+
+   public PutKeyValueCommand()
+   {
+   }
+
+   /**
+    * Puts the specified key and value into the data map in the node referenced by the specified Fqn.
+    *
+    * @param ctx invocation context
+    * @return the value being overwritten, if any, otherwise a null.
+    */
+   public Object perform(InvocationContext ctx)
+   {
+      if (trace) log.trace("Perform(, k='" + key + "', v='" + value + "')");
+      return null;
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.visitPutKeyValueCommand(ctx, this);
+   }
+
+   public Object getKey()
+   {
+      return key;
+   }
+
+   public Object getValue()
+   {
+      return value;
+   }
+
+   public void setKey(Object key)
+   {
+      this.key = key;
+   }
+
+   public void setValue(Object value)
+   {
+      this.value = value;
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      return new Object[]{key, value, false};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      key = args[0];
+      value = args[1];
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      PutKeyValueCommand that = (PutKeyValueCommand) o;
+
+      if (key != null ? !key.equals(that.key) : that.key != null) return false;
+      if (value != null ? !value.equals(that.value) : that.value != null) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (key != null ? key.hashCode() : 0);
+      result = 31 * result + (value != null ? value.hashCode() : 0);
+      return result;
+   }
+}
\ No newline at end of file

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java	2008-10-08 09:30:07 UTC (rev 6858)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -1,55 +1,55 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.config;
-
-import org.jboss.util.NotImplementedException;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author Mircea.Markus at jboss.com
- */
-public class Configuration
-{
-   public Map<String, CacheConfig> cacheConfigs = new HashMap<String, CacheConfig>();
-
-   //todo - to be implemented, do the parsing here
-   public Configuration(String configFile)
-   {
-      throw new NotImplementedException("not impl!");
-   }
-
-   public Configuration()
-   {
-   }
-
-   public CacheConfig getCacheConfig(String name)
-   {
-      return cacheConfigs.get(name);
-   }
-
-   public void addCacheConfig(String name, CacheConfig config)
-   {
-      cacheConfigs.put(name, config);
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.config;
+
+import org.jboss.util.NotImplementedException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class Configuration
+{
+   public Map<String, CacheConfig> cacheConfigs = new HashMap<String, CacheConfig>();
+
+   //todo - to be implemented, do the parsing here
+   public Configuration(String configFile)
+   {
+      throw new NotImplementedException("not impl!");
+   }
+
+   public Configuration()
+   {
+   }
+
+   public CacheConfig getCacheConfig(String name)
+   {
+      return cacheConfigs.get(name);
+   }
+
+   public void addCacheConfig(String name, CacheConfig config)
+   {
+      cacheConfigs.put(name, config);
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java	2008-10-08 09:30:07 UTC (rev 6858)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -21,9 +21,9 @@
  */
 package org.jboss.starobrno.context;
 
-import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.config.Option;
-import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.transaction.GlobalTransaction;
 
 import javax.transaction.Transaction;
 import java.util.List;

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java	2008-10-08 09:30:07 UTC (rev 6858)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -23,15 +23,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.starobrno.mvcc.MVCCEntry;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.commands.VisitableCommand;
 import org.jboss.cache.config.Option;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
 import org.jboss.cache.util.Immutables;
-import org.jboss.starobrno.mvcc.MVCCEntry;
+import org.jboss.cache.transaction.TransactionTable;
 
 import javax.transaction.Transaction;
 import java.util.Collections;
@@ -60,8 +57,6 @@
    private boolean originLocal = true;
    private boolean localRollbackOnly;
    @Deprecated
-   private MethodCall methodCall;
-   @Deprecated
    private VisitableCommand command;
 
    /**
@@ -456,7 +451,6 @@
       optionOverrides = null;
       originLocal = true;
       invocationLocks = null;
-      methodCall = null;
       command = null;
       if (lookedUpEntries != null)
       {
@@ -485,42 +479,6 @@
    }
 
    /**
-    * @return the method call associated with this invocation
-    */
-   @Deprecated
-   @SuppressWarnings("deprecation")
-   public MethodCall getMethodCall()
-   {
-      if (methodCall == null)
-      {
-         methodCall = createMethodCall();
-      }
-      return methodCall;
-   }
-
-   @SuppressWarnings("deprecation")
-   private MethodCall createMethodCall()
-   {
-      if (command == null) return null;
-      MethodCall call = new MethodCall();
-      call.setMethodId(command.getCommandId());
-      call.setArgs(command.getParameters());
-      return call;
-   }
-
-   /**
-    * Sets the method call associated with this invocation.
-    *
-    * @param methodCall methodcall to set
-    * @deprecated not used anymore.  Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
-    */
-   @Deprecated
-   public void setMethodCall(MethodCall methodCall)
-   {
-      this.methodCall = methodCall;
-   }
-
-   /**
     * If the lock acquisition timeout is overridden for current call using an option, then return that one.
     * If not overridden, return default value.
     *

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/DefaultFactoryFor.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/DefaultFactoryFor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/DefaultFactoryFor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/DefaultFactoryFor.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation that is used internally, for defining a DEFAULT factory to be used when constructing components.  This
+ * annotation allows you to define which components can be constructed by the annotated factory.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+ at Target(TYPE)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface DefaultFactoryFor
+{
+   /**
+    * Components that may be constructed by a factory annotated with this annotation.
+    *
+    * @return classes that can be constructed by this factory
+    */
+   public abstract Class[] classes();
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Destroy.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/Destroy.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Destroy.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Destroy.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Method level annotation that indicates a (no-param) method to be called on a component registered in the ComponentRegistry
+ * when the cache is destroyed.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+ at Target(METHOD)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Destroy
+{
+   /**
+    * Optional parameter which defines the order in which this method will be called when the ComponentRegistry moves
+    * to the STARTED state.  Defaults to 10.
+    *
+    * @return execution priority
+    * @since 2.2.0
+    */
+   public abstract int priority() default 10;
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Inject.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/Inject.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Inject.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Inject.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Used to annotate a method as one that is used to inject a registered component into another component.  The component
+ * to be constructed must be built using the {@link org.jboss.cache.factories.ComponentFactory#construct(Class)} method, or if your object that needs
+ * components injected into it already exists, it can be built using the {@link org.jboss.cache.factories.ComponentRegistry#wireDependencies(Object)}
+ * method.
+ * <p/>
+ * Usage example:
+ * <pre>
+ *       public class MyClass
+ *       {
+ *          private TransactionManager tm;
+ *          private BuddyManager bm;
+ *          private Notifier n;
+ * <p/>
+ *          &amp;Inject
+ *          public void setTransactionManager(TransactionManager tm)
+ *          {
+ *             this.tm = tm;
+ *          }
+ * <p/>
+ *          &amp;Inject
+ *          public void injectMoreStuff(BuddyManager bm, Notifier n)
+ *          {
+ *             this.bm = bm;
+ *             this.n = n;
+ *          }
+ *       }
+ * <p/>
+ * </pre>
+ * and an instance of this class can be constructed and wired using
+ * <pre>
+ *       MyClass myClass = componentFactory.construct(MyClass.class); // instance will have dependencies injected.
+ * </pre>
+ *
+ * @author Manik Surtani
+ * @since 2.1.0
+ */
+// ensure this annotation is available at runtime.
+ at Retention(RetentionPolicy.RUNTIME)
+
+// only applies to fields.
+ at Target(ElementType.METHOD)
+public @interface Inject
+{
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/NonVolatile.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used for components that will be registered in the {@link org.jboss.cache.factories.ComponentRegistry},
+ * that are resilient to changes in configuration.  Examples are the {@link org.jboss.cache.CacheSPI} implementation used, which does
+ * not change regardless of the configuration.  Components such as the {@link org.jboss.cache.lock.LockManager}, though, should
+ * <b>never</b> be marked as <tt>@NonVolatile</tt> since based on the configuration, different lock manager implementations
+ * may be selected.  LockManager is, hence, <b>not</b> resilient to changes in the configuration.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+// ensure this annotation is available at runtime.
+ at Retention(RetentionPolicy.RUNTIME)
+
+// only applies to classes.
+ at Target(ElementType.TYPE)
+public @interface NonVolatile
+{
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Start.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/Start.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Start.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Start.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Method level annotation that indicates a (no-param) method to be called on a component registered in the ComponentRegistry
+ * when the cache starts.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+ at Target(METHOD)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Start
+{
+   /**
+    * Optional parameter which defines the order in which this method will be called when the ComponentRegistry moves
+    * to the STARTED state.  Defaults to 10.
+    *
+    * @return execution priority
+    * @since 2.2.0
+    */
+   public abstract int priority() default 10;
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Stop.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/Stop.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Stop.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/Stop.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Method level annotation that indicates a (no-param) method to be called on a component registered in the ComponentRegistry
+ * when the cache stops.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+ at Target(METHOD)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Stop
+{
+   /**
+    * Optional parameter which defines the order in which this method will be called when the ComponentRegistry moves
+    * to the STARTED state.  Defaults to 10.
+    *
+    * @return execution priority
+    * @since 2.2.0
+    */
+   public abstract int priority() default 10;
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/factories/context/ContextFactory.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.factories.context;
+
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * This is the factory responsible for creating {@link org.jboss.cache.InvocationContext}s and {@link org.jboss.cache.transaction.TransactionContext}s
+ * for requests, based on the configuration used.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+public interface ContextFactory
+{
+   /**
+    * @return a new invocation context
+    */
+   InvocationContext createInvocationContext();
+
+   /**
+    * @param tx JTA transaction to associate the new context with
+    * @return a new transaction context
+    * @throws javax.transaction.RollbackException
+    *          in the event of an invalid transaaction
+    * @throws javax.transaction.SystemException
+    *          in the event of an invalid transaction
+    */
+   TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException;
+}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InterceptorChain.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,386 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.cache.util.CachePrinter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Knows how to build and manage an chain of interceptors. Also in charge with invoking methods on the chain.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ *        todo - if you add the same interceptor instance twice, things get really dirty.
+ *        -- this should be treated as an missuse and an exception should be thrown
+ */
+public class InterceptorChain
+{
+   /**
+    * reference to the first interceptor in the chain
+    */
+   private CommandInterceptor firstInChain;
+
+   /**
+    * used for invoking commands on the chain
+    */
+   private InvocationContextContainer invocationContextContainer;
+   private static final Log log = LogFactory.getLog(InterceptorChain.class);
+
+   /**
+    * Constructs an interceptor chain having the supplied interceptor as first.
+    */
+   public InterceptorChain(CommandInterceptor first)
+   {
+      this.firstInChain = first;
+   }
+
+   @Inject
+   public void initialize(InvocationContextContainer invocationContextContainer)
+   {
+      this.invocationContextContainer = invocationContextContainer;
+   }
+
+   @Start
+   private void printChainInfo()
+   {
+      if (log.isDebugEnabled()) log.debug("Interceptor chain is: " + toString());
+   }
+
+   /**
+    * Inserts the given interceptor at the specified position in the chain (o based indexing).
+    *
+    * @throws IllegalArgumentException if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain)
+    */
+   public synchronized void addInterceptor(CommandInterceptor interceptor, int position)
+   {
+      if (position == 0)
+      {
+         interceptor.setNext(firstInChain);
+         firstInChain = interceptor;
+         return;
+      }
+      if (firstInChain == null) return;
+      CommandInterceptor it = firstInChain;
+      int index = 0;
+      while (it != null)
+      {
+         if (++index == position)
+         {
+            interceptor.setNext(it.getNext());
+            it.setNext(interceptor);
+            return;
+         }
+         it = it.getNext();
+      }
+      throw new IllegalArgumentException("Invalid index: " + index + " !");
+   }
+
+   /**
+    * Removes the interceptor at the given postion.
+    *
+    * @throws IllegalArgumentException if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain)
+    */
+   public synchronized void removeInterceptor(int position)
+   {
+      if (firstInChain == null) return;
+      if (position == 0)
+      {
+         firstInChain = firstInChain.getNext();
+         return;
+      }
+      CommandInterceptor it = firstInChain;
+      int index = 0;
+      while (it != null)
+      {
+         if (++index == position)
+         {
+            if (it.getNext() == null) return; //nothing to remove
+            it.setNext(it.getNext().getNext());
+            return;
+         }
+         it = it.getNext();
+      }
+      throw new IllegalArgumentException("Invalid position: " + position + " !");
+   }
+
+   /**
+    * Returns the number of interceptors in the chain.
+    */
+   public int size()
+   {
+      int size = 0;
+      CommandInterceptor it = firstInChain;
+      while (it != null)
+      {
+         size++;
+         it = it.getNext();
+      }
+      return size;
+
+   }
+
+   /**
+    * Returns an unmofiable list with all the interceptors in sequence.
+    * If first in chain is null an empty list is returned.
+    */
+   public List<CommandInterceptor> asList()
+   {
+      if (firstInChain == null) return Collections.emptyList();
+
+      List<CommandInterceptor> retval = new LinkedList<CommandInterceptor>();
+      CommandInterceptor tmp = firstInChain;
+      do
+      {
+         retval.add(tmp);
+         tmp = tmp.getNext();
+      }
+      while (tmp != null);
+      return Collections.unmodifiableList(retval);
+   }
+
+
+   /**
+    * Removes all the occurences of supplied interceptor type from the chain.
+    */
+   public synchronized void removeInterceptor(Class<? extends CommandInterceptor> clazz)
+   {
+      if (firstInChain.getClass() == clazz)
+      {
+         firstInChain = firstInChain.getNext();
+      }
+      CommandInterceptor it = firstInChain.getNext();
+      CommandInterceptor prevIt = firstInChain;
+      while (it != null)
+      {
+         if (it.getClass() == clazz)
+         {
+            prevIt.setNext(it.getNext());
+         }
+         prevIt = it;
+         it = it.getNext();
+      }
+   }
+
+   /**
+    * Adds a new interceptor in list after an interceptor of a given type.
+    *
+    * @return true if the interceptor was added; i.e. the afterInterceptor exists
+    */
+   public synchronized boolean addAfterInterceptor(CommandInterceptor toAdd, Class<? extends CommandInterceptor> afterInterceptor)
+   {
+      CommandInterceptor it = firstInChain;
+      while (it != null)
+      {
+         if (it.getClass().equals(afterInterceptor))
+         {
+            toAdd.setNext(it.getNext());
+            it.setNext(toAdd);
+            return true;
+         }
+         it = it.getNext();
+      }
+      return false;
+   }
+
+   /**
+    * Adds a new interceptor in list after an interceptor of a given type.
+    *
+    * @return true if the interceptor was added; i.e. the afterInterceptor exists
+    */
+   public synchronized boolean addBeforeInterceptor(CommandInterceptor toAdd, Class<? extends CommandInterceptor> beforeInterceptor)
+   {
+      if (firstInChain.getClass().equals(beforeInterceptor))
+      {
+         toAdd.setNext(firstInChain);
+         firstInChain = toAdd;
+         return true;
+      }
+      CommandInterceptor it = firstInChain;
+      while (it.getNext() != null)
+      {
+         if (it.getNext().getClass().equals(beforeInterceptor))
+         {
+            toAdd.setNext(it.getNext());
+            it.setNext(toAdd);
+            return true;
+         }
+         it = it.getNext();
+      }
+      return false;
+   }
+
+   /**
+    * Appends at the end.
+    */
+   public void appendIntereceptor(CommandInterceptor ci)
+   {
+      CommandInterceptor it = firstInChain;
+      while (it.hasNext()) it = it.getNext();
+      it.setNext(ci);
+      // make sure we nullify the "next" pointer in the last interceptors.
+      ci.setNext(null);
+   }
+
+   /**
+    * Walks the command through the interceptor chain. The received ctx is being passed in.
+    */
+   @SuppressWarnings("deprecation")
+   public Object invoke(InvocationContext ctx, VisitableCommand command)
+   {
+      ctx.setCommand(command);
+      try
+      {
+         return command.acceptVisitor(ctx, firstInChain);
+      }
+      catch (CacheException e)
+      {
+         throw e;
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new CacheException(t);
+      }
+   }
+
+   /**
+    * Similar to {@link #invoke(org.jboss.cache.starbrnoInvocationContext , org.jboss.cache.starbrnocommands.VisitableCommand)}, but
+    * constructs a invocation context on the fly, using {@link org.jboss.cache.starbrnoinvocation.InvocationContextContainer#get()}
+    */
+   public Object invokeRemote(VisitableCommand cacheCommand) throws Throwable
+   {
+      InvocationContext ctxt = invocationContextContainer.get();
+      ctxt.setOriginLocal(false);
+      return cacheCommand.acceptVisitor(ctxt, firstInChain);
+   }
+
+   /**
+    * Similar to {@link #invoke(org.jboss.cache.starbrnoInvocationContext , org.jboss.cache.starbrnocommands.VisitableCommand)}, but
+    * constructs a invocation context on the fly, using {@link org.jboss.cache.starbrnoinvocation.InvocationContextContainer#get()} and setting the origin local flag to its default value.
+    */
+   public Object invoke(VisitableCommand cacheCommand) throws Throwable
+   {
+      InvocationContext ctxt = invocationContextContainer.get();
+      return cacheCommand.acceptVisitor(ctxt, firstInChain);
+   }
+
+   /**
+    * @return the first interceptor in the chain.
+    */
+   public CommandInterceptor getFirstInChain()
+   {
+      return firstInChain;
+   }
+
+   /**
+    * Mainly used by unit tests to replace the interceptor chain with the starting point passed in.
+    *
+    * @param interceptor interceptor to be used as the first interceptor in the chain.
+    */
+   public void setFirstInChain(CommandInterceptor interceptor)
+   {
+      this.firstInChain = interceptor;
+   }
+
+   public InvocationContext getInvocationContext()
+   {
+      return invocationContextContainer.get();
+   }
+
+   /**
+    * Returns all interceptors which extend the given command interceptor.
+    */
+   public List<CommandInterceptor> getInterceptorsWhichExtend(Class<? extends CommandInterceptor> interceptorClass)
+   {
+      List<CommandInterceptor> result = new ArrayList<CommandInterceptor>();
+      for (CommandInterceptor interceptor : asList())
+      {
+         boolean isSubclass = interceptorClass.isAssignableFrom(interceptor.getClass());
+         if (isSubclass)
+         {
+            result.add(interceptor);
+         }
+      }
+      return result;
+   }
+
+   /**
+    * Returns all the interceptors that have the fully qualified name of their class equal with the supplied class name.
+    */
+   public List<CommandInterceptor> getInterceptorsWithClassName(String fqName)
+   {
+      CommandInterceptor iterator = firstInChain;
+      List<CommandInterceptor> result = new ArrayList<CommandInterceptor>(2);
+      while (iterator != null)
+      {
+         if (iterator.getClass().getName().equals(fqName)) result.add(iterator);
+         iterator = iterator.getNext();
+      }
+      return result;
+   }
+
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder();
+      CommandInterceptor i = firstInChain;
+      if (i != null)
+      {
+         if (i.getNext() != null)
+         {
+            sb.append(i.getNext()).append("\n");
+         }
+         sb.append("\t>> ");
+         sb.append(i.getClass().getName());
+      }
+      return sb.toString();
+   }
+
+   /**
+    * Checks whether the chain contains the supplied interceptor instance.
+    */
+   public boolean containsInstance(CommandInterceptor interceptor)
+   {
+      CommandInterceptor it = firstInChain;
+      while (it != null)
+      {
+         if (it == interceptor) return true;
+         it = it.getNext();
+      }
+      return false;
+   }
+}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors.base;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.commands.AbstractVisitor;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.context.InvocationContext;
+
+/**
+ * This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
+ * allowing it to intercept invocations on {@link org.jboss.cache.commands.VisitableCommand}s.
+ * <p/>
+ * Commands are created either by the {@link org.jboss.cache.invocation.CacheInvocationDelegate} (for invocations on the {@link org.jboss.cache.Cache}
+ * public interface), the {@link org.jboss.cache.invocation.NodeInvocationDelegate} for invocations on the {@link org.jboss.cache.Node}
+ * public interface, or by the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher} for remotely originating invocations, and
+ * are passed up the interceptor chain by using the {@link org.jboss.cache.interceptors.InterceptorChain} helper class.
+ * <p/>
+ * When writing interceptors, authors can either override a specific visitXXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.InvocationContext , org.jboss.cache.commands.read.GetKeyValueCommand)})
+ * or the more generic {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)} which is the default behaviour of
+ * any visit method, as defined in {@link org.jboss.cache.commands.AbstractVisitor#handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
+ * <p/>
+ * The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}
+ * and then write a series of if statements or a switch block, if command-specific behaviour is needed.
+ * <p/>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @see org.jboss.cache.commands.VisitableCommand
+ * @see org.jboss.cache.commands.Visitor
+ * @see org.jboss.cache.interceptors.InterceptorChain
+ * @since 2.2
+ */
+public class CommandInterceptor extends AbstractVisitor
+{
+   private CommandInterceptor next;
+
+   protected Log log;
+   protected boolean trace;
+
+   protected Configuration configuration;
+
+   public CommandInterceptor()
+   {
+      log = LogFactory.getLog(getClass());
+      trace = log.isTraceEnabled();
+   }
+
+   @Inject
+   private void injectConfiguration(Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+
+   /**
+    * Retrieves the next interceptor in the chain.
+    *
+    * @return the next interceptor in the chain.
+    */
+   public CommandInterceptor getNext()
+   {
+      return next;
+   }
+
+   /**
+    * @return true if there is another interceptor in the chain after this; false otherwise.
+    */
+   public boolean hasNext()
+   {
+      return getNext() != null;
+   }
+
+   /**
+    * Sets the next interceptor in the chain to the interceptor passed in.
+    *
+    * @param next next interceptor in the chain.
+    */
+   public void setNext(CommandInterceptor next)
+   {
+      this.next = next;
+   }
+
+   /**
+    * Invokes the next interceptor in the chain.  This is how interceptor implementations should pass a call up the chain
+    * to the next interceptor.  In previous (pre-2.2.0) implementations of JBoss Cache, this was done by calling
+    * <pre>super.invoke()</pre>.
+    *
+    * @param ctx     invocation context
+    * @param command command to pass up the chain.
+    * @return return value of the invocation
+    * @throws Throwable in the event of problems
+    */
+   public Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command) throws Throwable
+   {
+      return command.acceptVisitor(ctx, next);
+   }
+
+   /**
+    * The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next
+    * interceptor in the chain.
+    *
+    * @param ctx     invocation context
+    * @param command command to invoke
+    * @return return value
+    * @throws Throwable in the event of problems
+    */
+   @Override
+   protected Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+   {
+      return invokeNextInterceptor(ctx, command);
+   }
+}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/PrePostProcessingCommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/PrePostProcessingCommandInterceptor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/PrePostProcessingCommandInterceptor.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,463 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors.base;
+
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.ClearDataCommand;
+import org.jboss.cache.commands.write.EvictCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+
+/**
+ * This interceptor adds pre and post processing to each <tt>visitXXX()</tt> method.
+ * <p/>
+ * For each <tt>visitXXX()</tt> method invoked, it will first call {@link #doBeforeCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * and if this method returns true, it will proceed to invoking a <tt>handleXXX()</tt> method and lastly, {@link #doAfterCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * in a <tt>finally</tt> block.  Note that the <tt>doAfterCall()</tt> method is still invoked even if <tt>doBeforeCall()</tt> returns <tt>false</tt>.
+ * <p/>
+ * Instead of overriding <tt>visitXXX()</tt> methods, implementations should override their <tt>handleXXX()</tt> counterparts defined in this class
+ * instead, as well as the {@link #doAfterCall(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method and
+ * optionally {@link #doBeforeCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * <p/>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public abstract class PrePostProcessingCommandInterceptor extends CommandInterceptor
+{
+   @Override
+   public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePutDataMapCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePutKeyValueCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   @Override
+   public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePutForExternalReadCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+
+   protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+
+   @Override
+   public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleRemoveNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleCreateNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   /**
+    * @deprecated in 3.0.  Will be removed when Optimistic and Pessimistic locking is removed.
+    */
+   @Deprecated
+   protected Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+
+   @Override
+   public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleClearDataCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleEvictFqnCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleInvalidateCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleRemoveKeyCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetDataMapCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleExistsNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetKeyValueCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetKeysCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetChildrenNamesCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleMoveCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGravitateDataCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePrepareCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleRollbackCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleCommitCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleOptimisticPrepareCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   /**
+    * Callback that is invoked after every handleXXX() method defined above.
+    *
+    * @param ctx     invocation context
+    * @param command command which was invoked
+    */
+   protected abstract void doAfterCall(InvocationContext ctx, VisitableCommand command);
+
+   protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
+   {
+      return true;
+   }
+}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/SkipCheckChainedInterceptor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/SkipCheckChainedInterceptor.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,395 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors.base;
+
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.ClearDataCommand;
+import org.jboss.cache.commands.write.EvictCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+
+/**
+ * This interceptor will call {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} before invoking each visit method
+ * (and the {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method).  If
+ * {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} returns <tt>false</tt>, the invocation will be skipped
+ * and passed up the interceptor chain instead.
+ * <p/>
+ * Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
+ * instead, as well as the {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
+ * Also, instead of overriding {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, implementors
+ * should override {@link #handleAll(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public abstract class SkipCheckChainedInterceptor extends CommandInterceptor
+{
+   @Override
+   public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handlePutDataMapCommand(ctx, command);
+   }
+
+   protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handlePutKeyValueCommand(ctx, command);
+   }
+
+   @Override
+   public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handlePutForExternalReadCommand(ctx, command);
+   }
+
+   protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleRemoveNodeCommand(ctx, command);
+   }
+
+   protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleRemoveDataCommand(ctx, command);
+   }
+
+   protected Object handleRemoveDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleEvictFqnCommand(ctx, command);
+   }
+
+   protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleInvalidateCommand(ctx, command);
+   }
+
+   protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleRemoveKeyCommand(ctx, command);
+   }
+
+   protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleGetDataMapCommand(ctx, command);
+   }
+
+   protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleExistsNodeCommand(ctx, command);
+   }
+
+   protected Object handleExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleGetKeyValueCommand(ctx, command);
+   }
+
+   protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleGetNodeCommand(ctx, command);
+   }
+
+   protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleGetKeysCommand(ctx, command);
+   }
+
+   protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleGetChildrenNamesCommand(ctx, command);
+   }
+
+   protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleMoveCommand(ctx, command);
+   }
+
+   protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleGravitateDataCommand(ctx, command);
+   }
+
+   protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handlePrepareCommand(ctx, command);
+   }
+
+   protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleRollbackCommand(ctx, command);
+   }
+
+   protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleCommitCommand(ctx, command);
+   }
+
+   protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleOptimisticPrepareCommand(ctx, command);
+   }
+
+   protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      return handleAll(ctx, command);
+   }
+
+   @Override
+   public final Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+   {
+      if (skipInterception(ctx, command))
+      {
+         return invokeNextInterceptor(ctx, command);
+      }
+      return handleAll(ctx, command);
+   }
+
+   /**
+    * Default implementation, which just passes the call up the interceptor chain
+    *
+    * @param ctx     invocation context
+    * @param command command
+    * @return return value
+    * @throws Throwable in the event of problems
+    */
+   protected Object handleAll(InvocationContext ctx, VisitableCommand command) throws Throwable
+   {
+      return invokeNextInterceptor(ctx, command);
+   }
+
+   /**
+    * Tests whether the command should be intercepted or not.  This is invoked before any of the handleXXX() methods.
+    *
+    * @param ctx     invocation context
+    * @param command command
+    * @return true if the invocation should skip the current interceptor and move on to the next in the chain, false otherwise.
+    */
+   protected abstract boolean skipInterception(InvocationContext ctx, VisitableCommand command);
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/invocation/InvocationContextContainer.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.invocation;
+
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.context.ContextFactory;
+import org.jboss.starobrno.context.InvocationContext;
+
+
+/**
+ * Container and factory for thread locals
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+ at NonVolatile
+public class InvocationContextContainer extends ThreadLocal<InvocationContext>
+{
+   ContextFactory contextFactory;
+
+   @Inject
+   public void injectContextFactory(ContextFactory contextFactory)
+   {
+      this.contextFactory = contextFactory;
+   }
+
+   @Override
+   protected InvocationContext initialValue()
+   {
+      // create if this is initially unset
+      return contextFactory.createInvocationContext();
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/GlobalTransaction.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/transaction/GlobalTransaction.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/GlobalTransaction.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/GlobalTransaction.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.transaction;
+
+
+import org.jgroups.Address;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+
+/**
+ * Uniquely identifies a transaction that spans all nodes in a cluster. This is used when
+ * replicating all modifications in a transaction; the PREPARE and COMMIT (or ROLLBACK)
+ * messages have to have a unique identifier to associate the changes with<br>
+ *
+ * @author <a href="mailto:bela at jboss.org">Bela Ban</a> Apr 12, 2003
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ * @version $Revision$
+ */
+public class GlobalTransaction implements Externalizable
+{
+
+   private static final long serialVersionUID = 8011434781266976149L;
+
+   private static long sid = 0;
+
+   private Address addr = null;
+   private long id = -1;
+   private transient boolean remote = false;
+
+   // cache the hashcode
+   private transient int hash_code = -1;  // in the worst case, hashCode() returns 0, then increases, so we're safe here
+
+   /**
+    * empty ctor used by externalization
+    */
+   public GlobalTransaction()
+   {
+   }
+
+   private GlobalTransaction(Address addr)
+   {
+      this.addr = addr;
+      id = newId();
+   }
+
+   private static synchronized long newId()
+   {
+      return ++sid;
+   }
+
+   public static GlobalTransaction create(Address addr)
+   {
+      return new GlobalTransaction(addr);
+   }
+
+   public Object getAddress()
+   {
+      return addr;
+   }
+
+   public void setAddress(Address address)
+   {
+      addr = address;
+   }
+
+   public long getId()
+   {
+      return id;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      if (hash_code == -1)
+      {
+         hash_code = (addr != null ? addr.hashCode() : 0) + (int) id;
+      }
+      return hash_code;
+   }
+
+   @Override
+   public boolean equals(Object other)
+   {
+      if (this == other)
+         return true;
+      if (!(other instanceof GlobalTransaction))
+         return false;
+
+      GlobalTransaction otherGtx = (GlobalTransaction) other;
+      boolean aeq = (addr == null) ? (otherGtx.addr == null) : addr.equals(otherGtx.addr);
+      return aeq && (id == otherGtx.id);
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder();
+      sb.append("GlobalTransaction:<").append(addr).append(">:").append(id);
+      return sb.toString();
+   }
+
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      out.writeObject(addr);
+      out.writeLong(id);
+      // out.writeInt(hash_code);
+   }
+
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      addr = (Address) in.readObject();
+      id = in.readLong();
+      hash_code = -1;
+   }
+
+   /**
+    * @return Returns the remote.
+    */
+   public boolean isRemote()
+   {
+      return remote;
+   }
+
+   /**
+    * @param remote The remote to set.
+    */
+   public void setRemote(boolean remote)
+   {
+      this.remote = remote;
+   }
+
+
+   public void setId(long id)
+   {
+      this.id = id;
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionContext.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionContext.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionContext.java	2008-10-08 09:34:41 UTC (rev 6859)
@@ -0,0 +1,283 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.transaction;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.WriteCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+
+import javax.transaction.Transaction;
+import java.util.List;
+
+/**
+ * Captures information pertaining to a specific JTA transaction.
+ * <p/>
+ * This was a concrete class called TransactionEntry prior to 3.0.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @see org.jboss.cache.InvocationContext
+ */
+public interface TransactionContext
+{
+   /**
+    * Adds a modification to the modification list.
+    *
+    * @param command modification
+    */
+   void addModification(WriteCommand command);
+
+   /**
+    * Returns all modifications.  If there are no modifications in this transaction this method will return an empty list.
+    *
+    * @return list of modifications.
+    */
+   List<WriteCommand> getModifications();
+
+   /**
+    * Adds a modification to the local modification list.
+    *
+    * @param command command to add to list.  Should not be null.
+    * @throws NullPointerException if the command to be added is null.
+    */
+   void addLocalModification(WriteCommand command);
+
+   /**
+    * Returns all modifications that have been invoked with the LOCAL cache mode option.  These will also be in the standard modification list.
+    *
+    * @return list of LOCAL modifications, or an empty list.
+    */
+   List<WriteCommand> getLocalModifications();
+
+   /**
+    * Adds the node that has been removed in the scope of the current transaction.
+    *
+    * @param fqn fqn that has been removed.
+    * @throws NullPointerException if the Fqn is null.
+    */
+   void addRemovedNode(Fqn fqn);
+
+   /**
+    * Gets the list of removed nodes.
+    *
+    * @return list of nodes removed in the current transaction scope.  Note that this method will return an empty list if nothing has been removed.  The list returned is defensively copied.
+    */
+   List<Fqn> getRemovedNodes();
+
+   /**
+    * Sets the local transaction to be associated with this transaction context.
+    *
+    * @param tx JTA transaction to associate with.
+    */
+   void setTransaction(Transaction tx);
+
+   /**
+    * Returns a local transaction associated with this context.
+    *
+    * @return a JTA transaction
+    */
+   Transaction getTransaction();
+
+   /**
+    * Adds a lock to the currently maintained collection of locks acquired.
+    * <p/>
+    * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#addLock(Object)} instead,
+    * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+    * <p/>
+    * Note that currently (as of 3.0.0) this lock is weakly typed.  This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
+    * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks).  Once support for
+    * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
+    *
+    * @param lock lock to add
+    * @see org.jboss.cache.InvocationContext#addLock(Object)
+    */
+   @SuppressWarnings("unchecked")
+   void addLock(Object lock);
+
+   /**
+    * Removes a lock from the currently maintained collection of locks acquired.
+    * <p/>
+    * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#removeLock(Object)}  instead,
+    * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+    * <p/>
+    * Note that currently (as of 3.0.0) this lock is weakly typed.  This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
+    * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks).  Once support for
+    * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
+    *
+    * @param lock lock to remove
+    * @see org.jboss.cache.InvocationContext#removeLock(Object)
+    */
+   @SuppressWarnings("unchecked")
+   void removeLock(Object lock);
+
+   /**
+    * Clears all locks from the currently maintained collection of locks acquired.
+    * <p/>
+    * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#clearLocks()} instead,
+    * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+    * <p/>
+    * Note that currently (as of 3.0.0) this lock is weakly typed.  This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
+    * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks).  Once support for
+    * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
+    *
+    * @see org.jboss.cache.InvocationContext#clearLocks()
+    */
+   void clearLocks();
+
+   /**
+    * Adds a List of locks to the currently maintained collection of locks acquired.
+    * <p/>
+    * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#addAllLocks(java.util.List)} instead,
+    * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+    * <p/>
+    * Note that currently (as of 3.0.0) this list is unchecked.  This is to allow support for both MVCC (which uses Fqns as locks)
+    * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks).  Once support for
+    * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
+    *
+    * @param newLocks locks to add
+    * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
+    */
+   @SuppressWarnings("unchecked")
+   void addAllLocks(List newLocks);
+
+   /**
+    * Returns an immutable,  defensive copy of the List of locks currently maintained for the transaction.
+    * <p/>
+    * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#getLocks()} instead,
+    * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+    * <p/>
+    * Note that currently (as of 3.0.0) this list is unchecked.  This is to allow support for both MVCC (which uses Fqns as locks)
+    * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks).  Once support for
+    * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
+    *
+    * @return locks held in current scope.
+    * @see org.jboss.cache.InvocationContext#getLocks()
+    */
+   @SuppressWarnings("unchecked")
+   List getLocks();
+
+   /**
+    * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#hasLock(Object)} ()} instead,
+    * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+    *
+    * @param lock lock to test
+    * @return true if the lock being tested is already held in the current scope, false otherwise.
+    */
+   boolean hasLock(Object lock);
+
+   /**
+    * Gets the value of the forceAsyncReplication flag.  Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+    * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+    * a transactional context.
+    *
+    * @return true if the forceAsyncReplication flag is set to true.
+    */
+   boolean isForceAsyncReplication();
+
+   /**
+    * Sets the value of the forceAsyncReplication flag.  Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+    * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+    * a transactional context. Also used by OptimisticReplicationInterceptor when dealing
+    * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
+    * non-transactional context (i.e. with an implicit transaction).
+    *
+    * @param forceAsyncReplication value of forceAsyncReplication
+    */
+   void setForceAsyncReplication(boolean forceAsyncReplication);
+
+   /**
+    * Gets the value of the forceSyncReplication flag.  Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+    * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+    * a transactional context.
+    *
+    * @return true if the forceAsyncReplication flag is set to true.
+    */
+   boolean isForceSyncReplication();
+
+   /**
+    * Sets the value of the forceSyncReplication flag.  Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+    * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+    * a transactional context.
+    *
+    * @param forceSyncReplication value of forceSyncReplication
+    */
+   void setForceSyncReplication(boolean forceSyncReplication);
+
+   /**
+    * Adds an Fqn to the list of uninitialized nodes created by the cache loader.
+    *
+    * @param fqn fqn to add.  Must not be null.
+    */
+   void addDummyNodeCreatedByCacheLoader(Fqn fqn);
+
+   /**
+    * @return a list of uninitialized nodes created by the cache loader, or an empty list.
+    */
+   List<Fqn> getDummyNodesCreatedByCacheLoader();
+
+   /**
+    * Sets a transaction-scope option override
+    *
+    * @param o option to set
+    */
+   void setOption(Option o);
+
+   /**
+    * Retrieves a transaction scope option override
+    *
+    * @return option
+    */
+   Option getOption();
+
+   /**
+    * @return the ordered sync handler associated with this transaction
+    */
+   OrderedSynchronizationHandler getOrderedSynchronizationHandler();
+
+   /**
+    * Associates an ordered sync handler with this transaction.
+    *
+    * @param orderedSynchronizationHandler to set
+    */
+   void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler);
+
+   /**
+    * @return true if modifications were registered.
+    */
+   boolean hasModifications();
+
+   /**
+    * @return true if any modifications have been invoked with cache mode being LOCAL.
+    */
+   boolean hasLocalModifications();
+
+   /**
+    * @return true if either there are modifications or local modifications that are not for replicating.
+    */
+   boolean hasAnyModifications();
+
+   /**
+    * Cleans up internal state, freeing up references.
+    */
+   void reset();
+}
\ No newline at end of file




More information about the jbosscache-commits mailing list