[exo-jcr-commits] exo-jcr SVN: r1321 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 8 05:32:08 EST 2010


Author: skabashnyuk
Date: 2010-01-08 05:32:08 -0500 (Fri, 08 Jan 2010)
New Revision: 1321

Added:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
Removed:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJbossCache.java
Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-371 : BufferedJbossCache renamed BufferedJBossCache

Copied: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java (from rev 1319, jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJbossCache.java)
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java	2010-01-08 10:32:08 UTC (rev 1321)
@@ -0,0 +1,663 @@
+package org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.Region;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jgroups.Address;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.transaction.TransactionManager;
+
+ at SuppressWarnings("unchecked")
+public class BufferedJBossCache implements Cache<Serializable, Object>
+{
+//   private final Log log = ExoLogger.getLogger(BufferedJbossCache.class);
+
+   /**
+    * Parent cache.
+    */
+   private final Cache<Serializable, Object> parentCache;
+
+   private ThreadLocal<List<ChangesContainer>> changesList = new ThreadLocal<List<ChangesContainer>>();
+
+   public BufferedJBossCache(Cache<Serializable, Object> parentCache)
+   {
+      super();
+      this.parentCache = parentCache;
+   }
+
+   /**
+    * Start buffering process.
+    */
+   public void beginTransaction()
+   {
+      changesList.set(new ArrayList<ChangesContainer>());
+   }
+
+   /**
+    * Sort changes and commit data to the cache.
+    */
+   public void commitTransaction()
+   {
+      List<ChangesContainer> changesContainer = changesList.get();
+      if (changesContainer == null)
+      {
+         throw new IllegalStateException("changesContainer should not be empty");
+      }
+      try
+      {
+         //log.info("Before=" + changesContainer.toString());
+         Collections.sort(changesContainer);
+         //log.info("After=" + changesContainer.toString());
+         for (ChangesContainer cacheChange : changesContainer)
+         {
+            cacheChange.apply();
+         }
+      }
+      finally
+      {
+         changesList.set(null);
+      }
+   }
+
+   /**
+    * Forget about changes
+    */
+   public void rollbackTransaction()
+   {
+      changesList.set(null);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#addCacheListener(java.lang.Object)
+    */
+   public void addCacheListener(Object listener)
+   {
+      parentCache.addCacheListener(listener);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor, java.lang.Class)
+    */
+   public void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
+   {
+      parentCache.addInterceptor(i, afterInterceptor);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor, int)
+    */
+   public void addInterceptor(CommandInterceptor i, int position)
+   {
+      parentCache.addInterceptor(i, position);
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#clearData(org.jboss.cache.Fqn)
+    */
+   public void clearData(Fqn fqn)
+   {
+      parentCache.clearData(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#clearData(java.lang.String)
+    */
+   public void clearData(String fqn)
+   {
+      parentCache.clearData(fqn);
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#create()
+    */
+   public void create() throws CacheException
+   {
+      parentCache.create();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#destroy()
+    */
+   public void destroy()
+   {
+      parentCache.destroy();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#endBatch(boolean)
+    */
+   public void endBatch(boolean successful)
+   {
+      parentCache.endBatch(successful);
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#evict(org.jboss.cache.Fqn, boolean)
+    */
+   public void evict(Fqn fqn, boolean recursive)
+   {
+      parentCache.evict(fqn, recursive);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#evict(org.jboss.cache.Fqn)
+    */
+   public void evict(Fqn fqn)
+   {
+      parentCache.evict(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#get(org.jboss.cache.Fqn, java.lang.Object)
+    */
+   public Object get(Fqn fqn, Serializable key)
+   {
+      return parentCache.get(fqn, key);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#get(java.lang.String, java.lang.Object)
+    */
+   public Object get(String fqn, Serializable key)
+   {
+      return parentCache.get(fqn, key);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getCacheListeners()
+    */
+   public Set<Object> getCacheListeners()
+   {
+      return parentCache.getCacheListeners();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getCacheStatus()
+    */
+   public CacheStatus getCacheStatus()
+   {
+      return parentCache.getCacheStatus();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getChildrenNames(org.jboss.cache.Fqn)
+    */
+   public Set<Object> getChildrenNames(Fqn fqn)
+   {
+      return parentCache.getChildrenNames(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getChildrenNames(java.lang.String)
+    */
+   public Set<String> getChildrenNames(String fqn)
+   {
+      return parentCache.getChildrenNames(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getConfiguration()
+    */
+   public Configuration getConfiguration()
+   {
+      return parentCache.getConfiguration();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getData(org.jboss.cache.Fqn)
+    */
+   public Map<Serializable, Object> getData(Fqn fqn)
+   {
+      return parentCache.getData(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getInvocationContext()
+    */
+   public InvocationContext getInvocationContext()
+   {
+      return parentCache.getInvocationContext();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)
+    */
+   public Set<Serializable> getKeys(Fqn fqn)
+   {
+      return parentCache.getKeys(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getKeys(java.lang.String)
+    */
+   public Set<Serializable> getKeys(String fqn)
+   {
+      return parentCache.getKeys(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getLocalAddress()
+    */
+   public Address getLocalAddress()
+   {
+      return parentCache.getLocalAddress();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getMembers()
+    */
+   public List<Address> getMembers()
+   {
+      return parentCache.getMembers();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)
+    */
+   public Node<Serializable, Object> getNode(Fqn fqn)
+   {
+      return parentCache.getNode(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getNode(java.lang.String)
+    */
+   public Node<Serializable, Object> getNode(String fqn)
+   {
+      return parentCache.getNode(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getRegion(org.jboss.cache.Fqn, boolean)
+    */
+   public Region getRegion(Fqn fqn, boolean createIfAbsent)
+   {
+      return parentCache.getRegion(fqn, createIfAbsent);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getRoot()
+    */
+   public Node<Serializable, Object> getRoot()
+   {
+      return parentCache.getRoot();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#getVersion()
+    */
+   public String getVersion()
+   {
+      return parentCache.getVersion();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#isLeaf(org.jboss.cache.Fqn)
+    */
+   public boolean isLeaf(Fqn fqn)
+   {
+      return parentCache.isLeaf(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#isLeaf(java.lang.String)
+    */
+   public boolean isLeaf(String fqn)
+   {
+      return parentCache.isLeaf(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)
+    */
+   public void move(Fqn nodeToMove, Fqn newParent) throws NodeNotExistsException
+   {
+      parentCache.move(nodeToMove, newParent);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#move(java.lang.String, java.lang.String)
+    */
+   public void move(String nodeToMove, String newParent) throws NodeNotExistsException
+   {
+      parentCache.move(nodeToMove, newParent);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#put(org.jboss.cache.Fqn, java.util.Map)
+    */
+   public void put(Fqn fqn, Map<? extends Serializable, ? extends Object> data)
+   {
+      //parentCache.put(fqn, data);
+      List<ChangesContainer> changesContainer = changesList.get();
+      if (changesContainer == null)
+      {
+         throw new IllegalStateException("changesContainer should not be empty");
+      }
+      changesContainer.add(new PutObjectContainer(fqn, data, parentCache));
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
+    */
+   public Object put(Fqn fqn, Serializable key, Object value)
+   {
+      List<ChangesContainer> changesContainer = changesList.get();
+      if (changesContainer == null)
+      {
+         throw new IllegalStateException("changesContainer should not be empty");
+      }
+      changesContainer.add(new PutKeyValueContainer(fqn, key, value, parentCache));
+
+      return parentCache.get(fqn, key);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#put(java.lang.String, java.util.Map)
+    */
+   public void put(String fqn, Map<? extends Serializable, ? extends Object> data)
+   {
+      throw new UnsupportedOperationException(
+         "Unexpected method call use put(Fqn fqn, Map<? extends Serializable, ? extends Object> data)");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#put(java.lang.String, java.lang.Object, java.lang.Object)
+    */
+   public Object put(String fqn, Serializable key, Object value)
+   {
+      throw new UnsupportedOperationException("Unexpected method call use put(Fqn fqn, Serializable key, Object value)");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
+    */
+   public void putForExternalRead(Fqn fqn, Serializable key, Object value)
+   {
+      throw new UnsupportedOperationException("Unexpected method call ");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#remove(org.jboss.cache.Fqn, java.lang.Object)
+    */
+   public Object remove(Fqn fqn, Serializable key)
+   {
+      List<ChangesContainer> changesContainer = changesList.get();
+      if (changesContainer == null)
+      {
+         throw new IllegalStateException("changesContainer should not be empty");
+      }
+      changesContainer.add(new RemoveKeyContainer(fqn, key, parentCache));
+      return parentCache.get(fqn, key);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#remove(java.lang.String, java.lang.Object)
+    */
+   public Object remove(String fqn, Serializable key)
+   {
+      throw new UnsupportedOperationException("Unexpected method call. Use remove(Fqn fqn, Serializable key)");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#removeCacheListener(java.lang.Object)
+    */
+   public void removeCacheListener(Object listener)
+   {
+      parentCache.removeCacheListener(listener);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#removeInterceptor(java.lang.Class)
+    */
+   public void removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
+   {
+      parentCache.removeInterceptor(interceptorType);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#removeInterceptor(int)
+    */
+   public void removeInterceptor(int position)
+   {
+      parentCache.removeInterceptor(position);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#removeNode(org.jboss.cache.Fqn)
+    */
+   public boolean removeNode(Fqn fqn)
+   {
+      List<ChangesContainer> changesContainer = changesList.get();
+      if (changesContainer == null)
+      {
+         throw new IllegalStateException("changesContainer should not be empty");
+      }
+      changesContainer.add(new RemoveNodeContainer(fqn, parentCache));
+      return true;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#removeNode(java.lang.String)
+    */
+   public boolean removeNode(String fqn)
+   {
+      throw new UnsupportedOperationException("Unexpected method call. Use remove removeNode(Fqn fqn)");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#removeRegion(org.jboss.cache.Fqn)
+    */
+   public boolean removeRegion(Fqn fqn)
+   {
+      return parentCache.removeRegion(fqn);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#setInvocationContext(org.jboss.cache.InvocationContext)
+    */
+   public void setInvocationContext(InvocationContext ctx)
+   {
+      parentCache.setInvocationContext(ctx);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#start()
+    */
+   public void start() throws CacheException
+   {
+      parentCache.start();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#startBatch()
+    */
+   public void startBatch()
+   {
+      parentCache.startBatch();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.cache.Cache#stop()
+    */
+   public void stop()
+   {
+      parentCache.stop();
+   }
+
+   public TransactionManager getTransactionManager()
+   {
+      return ((CacheSPI<Serializable, Object>)parentCache).getTransactionManager();
+   }
+
+   private static enum ChangesType
+   {
+      REMOVED, ADDED;
+   }
+
+   /**
+    * Container for changes
+    * @author sj
+    *
+    */
+   private static abstract class ChangesContainer implements Comparable<ChangesContainer>
+   {
+      protected final Fqn fqn;
+
+      protected final ChangesType changesType;
+
+      protected final Cache<Serializable, Object> cache;
+
+      public ChangesContainer(Fqn fqn, ChangesType changesType, Cache<Serializable, Object> cache)
+      {
+         super();
+         this.fqn = fqn;
+         this.changesType = changesType;
+         this.cache = cache;
+      }
+
+      /**
+       * @return the fqn
+       */
+      public Fqn getFqn()
+      {
+         return fqn;
+      }
+
+      /**
+       * @return the changesType
+       */
+      public ChangesType getChangesType()
+      {
+         return changesType;
+      }
+
+      /* (non-Javadoc)
+       * @see java.lang.Object#toString()
+       */
+      @Override
+      public String toString()
+      {
+         return fqn + " type=" + changesType;
+      }
+
+      public int compareTo(ChangesContainer o)
+      {
+         int result = fqn.compareTo(o.getFqn());
+         return result == 0 ? -1 : result;
+      }
+
+      public abstract void apply();
+   }
+
+   /**
+    * Put object container;
+    * @author sj
+    *
+    */
+   private static class PutObjectContainer extends ChangesContainer
+   {
+      private final Map<? extends Serializable, ? extends Object> data;
+
+      public PutObjectContainer(Fqn fqn, Map<? extends Serializable, ? extends Object> data,
+         Cache<Serializable, Object> cache)
+      {
+         super(fqn, ChangesType.ADDED, cache);
+
+         this.data = data;
+      }
+
+      @Override
+      public void apply()
+      {
+         cache.put(fqn, data);
+      }
+   }
+
+   /**
+    * Put  container.
+    * @author sj
+    *
+    */
+   private static class PutKeyValueContainer extends ChangesContainer
+   {
+      private final Serializable key;
+
+      private final Object value;
+
+      public PutKeyValueContainer(Fqn fqn, Serializable key, Object value, Cache<Serializable, Object> cache)
+      {
+         super(fqn, ChangesType.ADDED, cache);
+         this.key = key;
+         this.value = value;
+      }
+
+      @Override
+      public void apply()
+      {
+         cache.put(fqn, key, value);
+      }
+   }
+
+   /**
+    * Remove container.
+    * @author sj
+    *
+    */
+   private static class RemoveKeyContainer extends ChangesContainer
+   {
+      private final Serializable key;
+
+      public RemoveKeyContainer(Fqn fqn, Serializable key, Cache<Serializable, Object> cache)
+      {
+         super(fqn, ChangesType.REMOVED, cache);
+         this.key = key;
+      }
+
+      @Override
+      public void apply()
+      {
+         cache.remove(fqn, key);
+
+      }
+
+   }
+
+   /**
+    * Remove container.
+    * @author sj
+    *
+    */
+   private static class RemoveNodeContainer extends ChangesContainer
+   {
+
+      public RemoveNodeContainer(Fqn fqn, Cache<Serializable, Object> cache)
+      {
+         super(fqn, ChangesType.REMOVED, cache);
+      }
+
+      @Override
+      public void apply()
+      {
+         cache.removeNode(fqn);
+      }
+   }
+}


Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJbossCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJbossCache.java	2010-01-08 10:30:56 UTC (rev 1320)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJbossCache.java	2010-01-08 10:32:08 UTC (rev 1321)
@@ -1,663 +0,0 @@
-package org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.Region;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jgroups.Address;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.transaction.TransactionManager;
-
- at SuppressWarnings("unchecked")
-public class BufferedJbossCache implements Cache<Serializable, Object>
-{
-//   private final Log log = ExoLogger.getLogger(BufferedJbossCache.class);
-
-   /**
-    * Parent cache.
-    */
-   private final Cache<Serializable, Object> parentCache;
-
-   private ThreadLocal<List<ChangesContainer>> changesList = new ThreadLocal<List<ChangesContainer>>();
-
-   public BufferedJbossCache(Cache<Serializable, Object> parentCache)
-   {
-      super();
-      this.parentCache = parentCache;
-   }
-
-   /**
-    * Start buffering process.
-    */
-   public void beginTransaction()
-   {
-      changesList.set(new ArrayList<ChangesContainer>());
-   }
-
-   /**
-    * Sort changes and commit data to the cache.
-    */
-   public void commitTransaction()
-   {
-      List<ChangesContainer> changesContainer = changesList.get();
-      if (changesContainer == null)
-      {
-         throw new IllegalStateException("changesContainer should not be empty");
-      }
-      try
-      {
-         //log.info("Before=" + changesContainer.toString());
-         Collections.sort(changesContainer);
-         //log.info("After=" + changesContainer.toString());
-         for (ChangesContainer cacheChange : changesContainer)
-         {
-            cacheChange.apply();
-         }
-      }
-      finally
-      {
-         changesList.set(null);
-      }
-   }
-
-   /**
-    * Forget about changes
-    */
-   public void rollbackTransaction()
-   {
-      changesList.set(null);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#addCacheListener(java.lang.Object)
-    */
-   public void addCacheListener(Object listener)
-   {
-      parentCache.addCacheListener(listener);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor, java.lang.Class)
-    */
-   public void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
-   {
-      parentCache.addInterceptor(i, afterInterceptor);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor, int)
-    */
-   public void addInterceptor(CommandInterceptor i, int position)
-   {
-      parentCache.addInterceptor(i, position);
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#clearData(org.jboss.cache.Fqn)
-    */
-   public void clearData(Fqn fqn)
-   {
-      parentCache.clearData(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#clearData(java.lang.String)
-    */
-   public void clearData(String fqn)
-   {
-      parentCache.clearData(fqn);
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#create()
-    */
-   public void create() throws CacheException
-   {
-      parentCache.create();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#destroy()
-    */
-   public void destroy()
-   {
-      parentCache.destroy();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#endBatch(boolean)
-    */
-   public void endBatch(boolean successful)
-   {
-      parentCache.endBatch(successful);
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#evict(org.jboss.cache.Fqn, boolean)
-    */
-   public void evict(Fqn fqn, boolean recursive)
-   {
-      parentCache.evict(fqn, recursive);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#evict(org.jboss.cache.Fqn)
-    */
-   public void evict(Fqn fqn)
-   {
-      parentCache.evict(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#get(org.jboss.cache.Fqn, java.lang.Object)
-    */
-   public Object get(Fqn fqn, Serializable key)
-   {
-      return parentCache.get(fqn, key);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#get(java.lang.String, java.lang.Object)
-    */
-   public Object get(String fqn, Serializable key)
-   {
-      return parentCache.get(fqn, key);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getCacheListeners()
-    */
-   public Set<Object> getCacheListeners()
-   {
-      return parentCache.getCacheListeners();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getCacheStatus()
-    */
-   public CacheStatus getCacheStatus()
-   {
-      return parentCache.getCacheStatus();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getChildrenNames(org.jboss.cache.Fqn)
-    */
-   public Set<Object> getChildrenNames(Fqn fqn)
-   {
-      return parentCache.getChildrenNames(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getChildrenNames(java.lang.String)
-    */
-   public Set<String> getChildrenNames(String fqn)
-   {
-      return parentCache.getChildrenNames(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getConfiguration()
-    */
-   public Configuration getConfiguration()
-   {
-      return parentCache.getConfiguration();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getData(org.jboss.cache.Fqn)
-    */
-   public Map<Serializable, Object> getData(Fqn fqn)
-   {
-      return parentCache.getData(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getInvocationContext()
-    */
-   public InvocationContext getInvocationContext()
-   {
-      return parentCache.getInvocationContext();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)
-    */
-   public Set<Serializable> getKeys(Fqn fqn)
-   {
-      return parentCache.getKeys(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getKeys(java.lang.String)
-    */
-   public Set<Serializable> getKeys(String fqn)
-   {
-      return parentCache.getKeys(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getLocalAddress()
-    */
-   public Address getLocalAddress()
-   {
-      return parentCache.getLocalAddress();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getMembers()
-    */
-   public List<Address> getMembers()
-   {
-      return parentCache.getMembers();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)
-    */
-   public Node<Serializable, Object> getNode(Fqn fqn)
-   {
-      return parentCache.getNode(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getNode(java.lang.String)
-    */
-   public Node<Serializable, Object> getNode(String fqn)
-   {
-      return parentCache.getNode(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getRegion(org.jboss.cache.Fqn, boolean)
-    */
-   public Region getRegion(Fqn fqn, boolean createIfAbsent)
-   {
-      return parentCache.getRegion(fqn, createIfAbsent);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getRoot()
-    */
-   public Node<Serializable, Object> getRoot()
-   {
-      return parentCache.getRoot();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#getVersion()
-    */
-   public String getVersion()
-   {
-      return parentCache.getVersion();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#isLeaf(org.jboss.cache.Fqn)
-    */
-   public boolean isLeaf(Fqn fqn)
-   {
-      return parentCache.isLeaf(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#isLeaf(java.lang.String)
-    */
-   public boolean isLeaf(String fqn)
-   {
-      return parentCache.isLeaf(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)
-    */
-   public void move(Fqn nodeToMove, Fqn newParent) throws NodeNotExistsException
-   {
-      parentCache.move(nodeToMove, newParent);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#move(java.lang.String, java.lang.String)
-    */
-   public void move(String nodeToMove, String newParent) throws NodeNotExistsException
-   {
-      parentCache.move(nodeToMove, newParent);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#put(org.jboss.cache.Fqn, java.util.Map)
-    */
-   public void put(Fqn fqn, Map<? extends Serializable, ? extends Object> data)
-   {
-      //parentCache.put(fqn, data);
-      List<ChangesContainer> changesContainer = changesList.get();
-      if (changesContainer == null)
-      {
-         throw new IllegalStateException("changesContainer should not be empty");
-      }
-      changesContainer.add(new PutObjectContainer(fqn, data, parentCache));
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
-    */
-   public Object put(Fqn fqn, Serializable key, Object value)
-   {
-      List<ChangesContainer> changesContainer = changesList.get();
-      if (changesContainer == null)
-      {
-         throw new IllegalStateException("changesContainer should not be empty");
-      }
-      changesContainer.add(new PutKeyValueContainer(fqn, key, value, parentCache));
-
-      return parentCache.get(fqn, key);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#put(java.lang.String, java.util.Map)
-    */
-   public void put(String fqn, Map<? extends Serializable, ? extends Object> data)
-   {
-      throw new UnsupportedOperationException(
-         "Unexpected method call use put(Fqn fqn, Map<? extends Serializable, ? extends Object> data)");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#put(java.lang.String, java.lang.Object, java.lang.Object)
-    */
-   public Object put(String fqn, Serializable key, Object value)
-   {
-      throw new UnsupportedOperationException("Unexpected method call use put(Fqn fqn, Serializable key, Object value)");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
-    */
-   public void putForExternalRead(Fqn fqn, Serializable key, Object value)
-   {
-      throw new UnsupportedOperationException("Unexpected method call ");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#remove(org.jboss.cache.Fqn, java.lang.Object)
-    */
-   public Object remove(Fqn fqn, Serializable key)
-   {
-      List<ChangesContainer> changesContainer = changesList.get();
-      if (changesContainer == null)
-      {
-         throw new IllegalStateException("changesContainer should not be empty");
-      }
-      changesContainer.add(new RemoveKeyContainer(fqn, key, parentCache));
-      return parentCache.get(fqn, key);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#remove(java.lang.String, java.lang.Object)
-    */
-   public Object remove(String fqn, Serializable key)
-   {
-      throw new UnsupportedOperationException("Unexpected method call. Use remove(Fqn fqn, Serializable key)");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#removeCacheListener(java.lang.Object)
-    */
-   public void removeCacheListener(Object listener)
-   {
-      parentCache.removeCacheListener(listener);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#removeInterceptor(java.lang.Class)
-    */
-   public void removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
-   {
-      parentCache.removeInterceptor(interceptorType);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#removeInterceptor(int)
-    */
-   public void removeInterceptor(int position)
-   {
-      parentCache.removeInterceptor(position);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#removeNode(org.jboss.cache.Fqn)
-    */
-   public boolean removeNode(Fqn fqn)
-   {
-      List<ChangesContainer> changesContainer = changesList.get();
-      if (changesContainer == null)
-      {
-         throw new IllegalStateException("changesContainer should not be empty");
-      }
-      changesContainer.add(new RemoveNodeContainer(fqn, parentCache));
-      return true;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#removeNode(java.lang.String)
-    */
-   public boolean removeNode(String fqn)
-   {
-      throw new UnsupportedOperationException("Unexpected method call. Use remove removeNode(Fqn fqn)");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#removeRegion(org.jboss.cache.Fqn)
-    */
-   public boolean removeRegion(Fqn fqn)
-   {
-      return parentCache.removeRegion(fqn);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#setInvocationContext(org.jboss.cache.InvocationContext)
-    */
-   public void setInvocationContext(InvocationContext ctx)
-   {
-      parentCache.setInvocationContext(ctx);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#start()
-    */
-   public void start() throws CacheException
-   {
-      parentCache.start();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#startBatch()
-    */
-   public void startBatch()
-   {
-      parentCache.startBatch();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.cache.Cache#stop()
-    */
-   public void stop()
-   {
-      parentCache.stop();
-   }
-
-   public TransactionManager getTransactionManager()
-   {
-      return ((CacheSPI<Serializable, Object>)parentCache).getTransactionManager();
-   }
-
-   private static enum ChangesType
-   {
-      REMOVED, ADDED;
-   }
-
-   /**
-    * Container for changes
-    * @author sj
-    *
-    */
-   private static abstract class ChangesContainer implements Comparable<ChangesContainer>
-   {
-      protected final Fqn fqn;
-
-      protected final ChangesType changesType;
-
-      protected final Cache<Serializable, Object> cache;
-
-      public ChangesContainer(Fqn fqn, ChangesType changesType, Cache<Serializable, Object> cache)
-      {
-         super();
-         this.fqn = fqn;
-         this.changesType = changesType;
-         this.cache = cache;
-      }
-
-      /**
-       * @return the fqn
-       */
-      public Fqn getFqn()
-      {
-         return fqn;
-      }
-
-      /**
-       * @return the changesType
-       */
-      public ChangesType getChangesType()
-      {
-         return changesType;
-      }
-
-      /* (non-Javadoc)
-       * @see java.lang.Object#toString()
-       */
-      @Override
-      public String toString()
-      {
-         return fqn + " type=" + changesType;
-      }
-
-      public int compareTo(ChangesContainer o)
-      {
-         int result = fqn.compareTo(o.getFqn());
-         return result == 0 ? -1 : result;
-      }
-
-      public abstract void apply();
-   }
-
-   /**
-    * Put object container;
-    * @author sj
-    *
-    */
-   private static class PutObjectContainer extends ChangesContainer
-   {
-      private final Map<? extends Serializable, ? extends Object> data;
-
-      public PutObjectContainer(Fqn fqn, Map<? extends Serializable, ? extends Object> data,
-         Cache<Serializable, Object> cache)
-      {
-         super(fqn, ChangesType.ADDED, cache);
-
-         this.data = data;
-      }
-
-      @Override
-      public void apply()
-      {
-         cache.put(fqn, data);
-      }
-   }
-
-   /**
-    * Put  container.
-    * @author sj
-    *
-    */
-   private static class PutKeyValueContainer extends ChangesContainer
-   {
-      private final Serializable key;
-
-      private final Object value;
-
-      public PutKeyValueContainer(Fqn fqn, Serializable key, Object value, Cache<Serializable, Object> cache)
-      {
-         super(fqn, ChangesType.ADDED, cache);
-         this.key = key;
-         this.value = value;
-      }
-
-      @Override
-      public void apply()
-      {
-         cache.put(fqn, key, value);
-      }
-   }
-
-   /**
-    * Remove container.
-    * @author sj
-    *
-    */
-   private static class RemoveKeyContainer extends ChangesContainer
-   {
-      private final Serializable key;
-
-      public RemoveKeyContainer(Fqn fqn, Serializable key, Cache<Serializable, Object> cache)
-      {
-         super(fqn, ChangesType.REMOVED, cache);
-         this.key = key;
-      }
-
-      @Override
-      public void apply()
-      {
-         cache.remove(fqn, key);
-
-      }
-
-   }
-
-   /**
-    * Remove container.
-    * @author sj
-    *
-    */
-   private static class RemoveNodeContainer extends ChangesContainer
-   {
-
-      public RemoveNodeContainer(Fqn fqn, Cache<Serializable, Object> cache)
-      {
-         super(fqn, ChangesType.REMOVED, cache);
-      }
-
-      @Override
-      public void apply()
-      {
-         cache.removeNode(fqn);
-      }
-   }
-}

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-01-08 10:30:56 UTC (rev 1320)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java	2010-01-08 10:32:08 UTC (rev 1321)
@@ -120,7 +120,7 @@
 
    public static final Set<String> NO_CHILDS = Collections.emptySet();
 
-   protected final BufferedJbossCache cache;
+   protected final BufferedJBossCache cache;
 
    protected final Fqn<String> itemsRoot;
 
@@ -270,7 +270,7 @@
    {
       CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
       LOG.info("JBoss Cache configuration used: " + jbcConfig);
-      this.cache = new BufferedJbossCache(factory.createCache(jbcConfig, false));
+      this.cache = new BufferedJBossCache(factory.createCache(jbcConfig, false));
 
       this.cache.create();
       this.cache.start();



More information about the exo-jcr-commits mailing list