[infinispan-commits] Infinispan SVN: r164 - trunk/tree/src/main/java/org/infinispan/tree.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Apr 23 14:06:06 EDT 2009


Author: navssurtani
Date: 2009-04-23 14:06:06 -0400 (Thu, 23 Apr 2009)
New Revision: 164

Added:
   trunk/tree/src/main/java/org/infinispan/tree/TreeCacheFactory.java
Log:
Added in TreeCacheFactory. This should now be used for creating TreeCaches.

Added: trunk/tree/src/main/java/org/infinispan/tree/TreeCacheFactory.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/TreeCacheFactory.java	                        (rev 0)
+++ trunk/tree/src/main/java/org/infinispan/tree/TreeCacheFactory.java	2009-04-23 18:06:06 UTC (rev 164)
@@ -0,0 +1,42 @@
+package org.infinispan.tree;
+
+import org.infinispan.Cache;
+import org.infinispan.config.ConfigurationException;
+
+/**
+ * Factory class that contains API for users to create instances of {@link org.infinispan.tree.TreeCache}
+ *
+ * @author Navin Surtani
+ */
+
+
+public class TreeCacheFactory {
+
+   /**
+    * Creates a TreeCache instance by taking in a {@link org.infinispan.Cache} as a parameter
+    *
+    * @param cache
+    * @return instance of a {@link TreeCache}
+    * @throws NullPointerException if the cache parameter is null
+    * @throws ConfigurationException if the invocation batching configuration is not enabled.
+    *
+    */
+
+   public <K, V> TreeCache<K, V> createTreeCache(Cache<K, V> cache) {
+
+      // Validation to make sure that the cache is not null.
+
+      if (cache == null){
+         throw new NullPointerException("The cache parameter passed in is null");
+      }
+
+      // If invocationBatching is not enabled, throw a new configuration exception.
+
+      if (!cache.getConfiguration().isInvocationBatchingEnabled()) {
+         throw new ConfigurationException("invocationBatching is not enabled. Make sure this is enabled by" +
+               " calling config.setInvocationBatchingEnabled(true)");
+      }
+
+      return new TreeCacheImpl<K, V>(cache);
+   }
+}




More information about the infinispan-commits mailing list