[infinispan-commits] Infinispan SVN: r861 - in trunk: tree/src/main/java/org/infinispan/tree and 1 other directory.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Sep 25 11:25:04 EDT 2009


Author: manik.surtani at jboss.com
Date: 2009-09-25 11:25:03 -0400 (Fri, 25 Sep 2009)
New Revision: 861

Modified:
   trunk/core/src/main/java/org/infinispan/atomic/AtomicMapCache.java
   trunk/tree/src/main/java/org/infinispan/tree/TreeCache.java
   trunk/tree/src/main/java/org/infinispan/tree/TreeCacheImpl.java
   trunk/tree/src/main/java/org/infinispan/tree/TreeStructureSupport.java
Log:
[ISPN-195] (Tree API generics inconsistent)

Modified: trunk/core/src/main/java/org/infinispan/atomic/AtomicMapCache.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/atomic/AtomicMapCache.java	2009-09-25 15:05:24 UTC (rev 860)
+++ trunk/core/src/main/java/org/infinispan/atomic/AtomicMapCache.java	2009-09-25 15:25:03 UTC (rev 861)
@@ -31,13 +31,11 @@
  * @see AtomicMap
  * @since 4.0
  */
-public interface AtomicMapCache<K, V> extends Cache<K, V> {
+public interface AtomicMapCache<K> extends Cache<K, AtomicMap<?, ?>> {
    /**
     * Returns an atomic map.  The classes passed in are used to parameterize the Map returned.
     *
     * @param key          key under which to obtain and store this map in the cache
-    * @param <AMK>          map keys
-    * @param <AMV>          map values
     * @return a new or existing atomic map.  Never null.
     * @throws ClassCastException if there already is a value stored under the given key and the type of value cannot be
     *                            used as an AtomicMap.

Modified: trunk/tree/src/main/java/org/infinispan/tree/TreeCache.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/TreeCache.java	2009-09-25 15:05:24 UTC (rev 860)
+++ trunk/tree/src/main/java/org/infinispan/tree/TreeCache.java	2009-09-25 15:25:03 UTC (rev 861)
@@ -345,7 +345,7 @@
    /**
     * @return a reference to the underlying cache instance
     */
-   Cache<K, V> getCache();
+   Cache<?, ?> getCache();
 
    /**
     * Tests if an Fqn exists.  Convenience method for {@link #exists(Fqn)}

Modified: trunk/tree/src/main/java/org/infinispan/tree/TreeCacheImpl.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/TreeCacheImpl.java	2009-09-25 15:05:24 UTC (rev 860)
+++ trunk/tree/src/main/java/org/infinispan/tree/TreeCacheImpl.java	2009-09-25 15:25:03 UTC (rev 861)
@@ -40,7 +40,7 @@
    private static final Log log = LogFactory.getLog(TreeCacheImpl.class);
    private static final boolean trace = log.isTraceEnabled();
 
-   public TreeCacheImpl(Cache<K, V> cache) {
+   public TreeCacheImpl(Cache<?, ?> cache) {
       super(cache, ((AdvancedCache) cache).getBatchContainer(),
             ((AdvancedCache) cache).getInvocationContextContainer());
       assertBatchingSupported(cache.getConfiguration());
@@ -68,7 +68,7 @@
    public void put(Fqn fqn, Map<? extends K, ? extends V> data) {
       startAtomic();
       try {
-         Node n = getNode(fqn);
+         Node<K, V> n = getNode(fqn);
          if (n == null) createNodeInCache(fqn);
          n = getNode(fqn);
          n.putAll(data);
@@ -92,12 +92,11 @@
       put(fqn, data);
    }
 
-   @SuppressWarnings("unchecked")
    public V remove(Fqn fqn, K key) {
       startAtomic();
       try {
-         AtomicMap map = cache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
-         return map == null ? null : (V) map.remove(key);
+         AtomicMap<K, V> map = cache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
+         return map == null ? null : map.remove(key);
       }
       finally {
          endAtomic();
@@ -174,11 +173,10 @@
       return getNode(fqn);
    }
 
-   @SuppressWarnings("unchecked")
    public V get(Fqn fqn, K key) {
-      Map m = cache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
+      Map<K, V> m = cache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
       if (m == null) return null;
-      return (V) m.get(key);
+      return m.get(key);
    }
 
    public V get(Fqn fqn, K key, Flag... flags) {
@@ -223,7 +221,7 @@
       // Depth first.  Lets start with getting the node we want.
       startAtomic();
       try {
-         Node nodeToMove = getNode(nodeToMoveFqn, Flag.FORCE_WRITE_LOCK);
+         Node<K, V> nodeToMove = getNode(nodeToMoveFqn, Flag.FORCE_WRITE_LOCK);
          if (nodeToMove == null) {
             if (trace) log.trace("Did not find the node that needs to be moved. Returning...");
             return; // nothing to do here!
@@ -237,8 +235,8 @@
          // create an empty node for this new parent
          Fqn newFqn = Fqn.fromRelativeElements(newParentFqn, nodeToMoveFqn.getLastElement());
          createNodeInCache(newFqn);
-         Node newNode = getNode(newFqn);
-         Map oldData = nodeToMove.getData();
+         Node<K, V> newNode = getNode(newFqn);
+         Map<K, V> oldData = nodeToMove.getData();
          if (oldData != null && !oldData.isEmpty()) newNode.putAll(oldData);
          for (Object child : nodeToMove.getChildrenNames()) {
             // move kids
@@ -329,13 +327,13 @@
       icc.createInvocationContext().setFlags(flags);
    }
 
-   @SuppressWarnings("unchecked")
    public V put(Fqn fqn, K key, V value) {
       if (trace) log.trace("Start: Putting value under key [" + key + "] for node [" + fqn + "]");
       startAtomic();
       try {
          createNodeInCache(fqn);
-         return (V) cache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA)).put(key, value);
+         Map<K, V> m = cache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
+         return m.put(key, value);
       }
       finally {
          endAtomic();
@@ -348,11 +346,11 @@
       return put(fqn, key, value);
    }
 
-   // ------------------ nothing different; just delegate to the cache
-   public Cache getCache() {
+   public Cache<?, ?> getCache() {
       return cache;
    }
 
+   // ------------------ nothing different; just delegate to the cache
    public void start() throws CacheException {
       cache.start();
       createRoot();

Modified: trunk/tree/src/main/java/org/infinispan/tree/TreeStructureSupport.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/TreeStructureSupport.java	2009-09-25 15:05:24 UTC (rev 860)
+++ trunk/tree/src/main/java/org/infinispan/tree/TreeStructureSupport.java	2009-09-25 15:25:03 UTC (rev 861)
@@ -35,11 +35,11 @@
 public class TreeStructureSupport extends AutoBatchSupport {
    private static Log log = LogFactory.getLog(TreeStructureSupport.class);
 
-   AtomicMapCache<NodeKey, Object> cache;
+   AtomicMapCache<NodeKey> cache;
    InvocationContextContainer icc;
 
-   public TreeStructureSupport(Cache cache, BatchContainer batchContainer, InvocationContextContainer icc) {
-      this.cache = (AtomicMapCache) cache;
+   public TreeStructureSupport(Cache<?, ?> cache, BatchContainer batchContainer, InvocationContextContainer icc) {
+      this.cache = (AtomicMapCache<NodeKey>) cache;
       this.batchContainer = batchContainer;
       this.icc = icc;
    }



More information about the infinispan-commits mailing list