[jboss-cvs] JBossCache/src/org/jboss/cache ...

Manik Surtani manik at jboss.org
Mon Mar 12 14:13:46 EDT 2007


  User: msurtani
  Date: 07/03/12 14:13:46

  Modified:    src/org/jboss/cache             CacheImpl.java
                        UnversionedNode.java CacheSPI.java
                        CacheFactory.java Fqn.java Node.java
                        DefaultCacheFactory.java Cache.java
                        VersionedNode.java RegionManager.java NodeSPI.java
                        AbstractNode.java
  Log:
  JBCACHE-1005
  
  Revision  Changes    Path
  1.52      +125 -97   JBossCache/src/org/jboss/cache/CacheImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -b -r1.51 -r1.52
  --- CacheImpl.java	6 Mar 2007 19:18:19 -0000	1.51
  +++ CacheImpl.java	12 Mar 2007 18:13:46 -0000	1.52
  @@ -49,6 +49,7 @@
   import org.jgroups.Address;
   import org.jgroups.Channel;
   import org.jgroups.ChannelClosedException;
  +import org.jgroups.ChannelException;
   import org.jgroups.ChannelNotConnectedException;
   import org.jgroups.ExtendedMembershipListener;
   import org.jgroups.ExtendedMessageListener;
  @@ -102,7 +103,7 @@
    * @author Daniel Huang (dhuang at jboss.org)
    * @see org.jboss.cache.Cache
    */
  -public class CacheImpl implements CacheSPI
  +public class CacheImpl<K, V> implements CacheSPI<K, V>
   {
   
      /**
  @@ -117,7 +118,7 @@
      /**
       * Root node.
       */
  -   private NodeSPI root;
  +   private NodeSPI<K, V> root;
   
      /**
       * Cache's region manager.
  @@ -363,7 +364,7 @@
      }
   
      /**
  -    * Returns the list of interceptors.
  +    * @return the list of interceptors.
       */
      public List<Interceptor> getInterceptors()
      {
  @@ -546,7 +547,7 @@
       *
       * @throws Exception
       */
  -   public void create() throws Exception
  +   public void create() throws CacheException
      {
         // Include our clusterName in our log category
         configureLogCategory();
  @@ -583,9 +584,16 @@
            // Nope. See if we can look it up from JNDI
            if (this.tm_lookup == null && configuration.getTransactionManagerLookupClass() != null)
            {
  +            try
  +            {
               Class clazz = Thread.currentThread().getContextClassLoader().loadClass(configuration.getTransactionManagerLookupClass());
               this.tm_lookup = (TransactionManagerLookup) clazz.newInstance();
            }
  +            catch (Exception e)
  +            {
  +               throw new CacheException("Problems creating the cache", e);
  +            }
  +         }
   
            try
            {
  @@ -664,7 +672,14 @@
                     configuration.setClusterConfig(getDefaultProperties());
                     log.debug("setting cluster properties to default value");
                  }
  +               try
  +               {
                  channel = new JChannel(configuration.getClusterConfig());
  +               }
  +               catch (Exception e)
  +               {
  +                  throw new CacheException("Unable to create JGroups channel", e);
  +               }
                  if (log.isTraceEnabled())
                  {
                     log.trace("cache properties: " + configuration.getClusterConfig());
  @@ -698,7 +713,14 @@
         }
   
         // build interceptor chain
  +      try
  +      {
         interceptor_chain = new InterceptorChainFactory().buildInterceptorChain(this);
  +      }
  +      catch (Exception e)
  +      {
  +         throw new CacheException("Unable to build interceptor chain", e);
  +      }
   
         getRegionManager().setDefaultInactive(configuration.isInactiveOnStartup());
   
  @@ -714,9 +736,9 @@
      /**
       * Lifecyle method.
       *
  -    * @throws Exception
  +    * @throws CacheException
       */
  -   public void start() throws Exception
  +   public void start() throws CacheException
      {
   
         // Get around the problem of standalone user forgets to call create.
  @@ -740,7 +762,14 @@
            case REPL_ASYNC:
            case INVALIDATION_ASYNC:
            case INVALIDATION_SYNC:
  +            try
  +            {
               channel.connect(configuration.getClusterName());
  +            }
  +            catch (ChannelException e)
  +            {
  +               throw new CacheException("Unable to connect to JGroups channel", e);
  +            }
   
               if (log.isInfoEnabled())
               {
  @@ -758,7 +787,7 @@
                     // JBCACHE-761
                     channel.disconnect();
                     channel.close();
  -                  throw e;
  +                  throw new CacheException("Unable to fetch state on startup", e);
                  }
               }
               if (buddyManager != null)
  @@ -1010,7 +1039,7 @@
               try
               {
                  child = factory.createDataNode(name,
  -                       subtree.getFqnChild(i + 1),
  +                                              subtree.getAncestor(i + 1),
                          parent, null, true);
                  parent.addChild(name, child);
               }
  @@ -1080,8 +1109,7 @@
   
      }
   
  -   private void removeLocksForDeadMembers(NodeSPI node,
  -                                          List deadMembers)
  +   private void removeLocksForDeadMembers(NodeSPI<K, V> node, List deadMembers)
      {
         Set deadOwners = new HashSet();
         NodeLock lock = node.getLock();
  @@ -1116,7 +1144,7 @@
         }
   
         // Recursively unlock children
  -      for (NodeSPI child : node.getChildrenDirect())
  +      for (NodeSPI<K, V> child : node.getChildrenDirect())
         {
            removeLocksForDeadMembers(child, deadMembers);
         }
  @@ -1230,22 +1258,22 @@
       *
       * @param fqn name of the node
       */
  -   public Set getKeys(Fqn fqn) throws CacheException
  +   public Set<K> getKeys(Fqn fqn) throws CacheException
      {
         MethodCall m = MethodCallFactory.create(MethodDeclarations.getKeysMethodLocal, fqn);
  -      return (Set) invokeMethod(m);
  +      return (Set<K>) invokeMethod(m);
      }
   
   
      public Set _getKeys(Fqn fqn) throws CacheException
      {
  -      NodeSPI n = findNode(fqn);
  +      NodeSPI<K, V> n = findNode(fqn);
         if (n == null)
         {
            return null;
         }
  -      Set keys = n.getKeysDirect();
  -      return new HashSet(keys);
  +      Set<K> keys = n.getKeysDirect();
  +      return new HashSet<K>(keys);
      }
   
      /**
  @@ -1255,7 +1283,7 @@
       * @param fqn The fully qualified name of the node.
       * @param key The key.
       */
  -   public Object get(String fqn, Object key) throws CacheException
  +   public V get(String fqn, K key) throws CacheException
      {
         return get(Fqn.fromString(fqn), key);
      }
  @@ -1268,7 +1296,7 @@
       * @param fqn The fully qualified name of the node.
       * @param key The key.
       */
  -   public Object get(Fqn fqn, Object key) throws CacheException
  +   public V get(Fqn fqn, K key) throws CacheException
      {
         return get(fqn, key, true);
      }
  @@ -1292,10 +1320,10 @@
      }
   
   
  -   protected Object get(Fqn fqn, Object key, boolean sendNodeEvent) throws CacheException
  +   protected V get(Fqn fqn, K key, boolean sendNodeEvent) throws CacheException
      {
         MethodCall m = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, sendNodeEvent);
  -      return invokeMethod(m);
  +      return (V) invokeMethod(m);
      }
   
      /**
  @@ -1333,10 +1361,10 @@
       *
       * @param fqn
       */
  -   public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes)
  +   public NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes)
      {
         if (fqn == null || fqn.size() == 0) return root;
  -      NodeSPI n = root;
  +      NodeSPI<K, V> n = root;
         int fqnSize = fqn.size();
         for (int i = 0; i < fqnSize; i++)
         {
  @@ -1420,7 +1448,7 @@
       * @param value The value
       * @return Object The previous value (if any), if node was present
       */
  -   public Object put(String fqn, Object key, Object value) throws CacheException
  +   public V put(String fqn, K key, V value) throws CacheException
      {
         return put(Fqn.fromString(fqn), key, value);
      }
  @@ -1435,11 +1463,11 @@
       * @param value The value
       * @return Object The previous value (if any), if node was present
       */
  -   public Object put(Fqn fqn, Object key, Object value) throws CacheException
  +   public V put(Fqn fqn, K key, V value) throws CacheException
      {
         GlobalTransaction tx = getCurrentTransaction();
         MethodCall m = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, tx, fqn, key, value, true);
  -      return invokeMethod(m);
  +      return (V) invokeMethod(m);
      }
   
      /**
  @@ -1502,7 +1530,7 @@
       * @param key The key to be removed
       * @return The previous value, or null if none was associated with the given key
       */
  -   public Object remove(String fqn, Object key) throws CacheException
  +   public V remove(String fqn, K key) throws CacheException
      {
         return remove(Fqn.fromString(fqn), key);
      }
  @@ -1514,11 +1542,11 @@
       * @param key The key to be removed
       * @return The previous value, or null if none was associated with the given key
       */
  -   public Object remove(Fqn fqn, Object key) throws CacheException
  +   public V remove(Fqn fqn, K key) throws CacheException
      {
         GlobalTransaction tx = getCurrentTransaction();
         MethodCall m = MethodCallFactory.create(MethodDeclarations.removeKeyMethodLocal, tx, fqn, key, true);
  -      return invokeMethod(m);
  +      return (V) invokeMethod(m);
      }
   
      /**
  @@ -1756,7 +1784,7 @@
         return numLocks(root);
      }
   
  -   private int numLocks(NodeSPI n)
  +   private int numLocks(NodeSPI<K, V> n)
      {
         int num = 0;
         if (n.getLock().isLocked())
  @@ -1781,7 +1809,7 @@
         return numNodes(root) - 1;
      }
   
  -   private int numNodes(NodeSPI n)
  +   private int numNodes(NodeSPI<K, V> n)
      {
         int count = 1;// for n
         for (NodeSPI child : n.getChildrenDirect())
  @@ -1814,7 +1842,7 @@
         return numAttributes(n);
      }
   
  -   private int numAttributes(NodeSPI n)
  +   private int numAttributes(NodeSPI<K, V> n)
      {
         int count = 0;
         for (NodeSPI child : n.getChildrenDirect())
  @@ -2743,7 +2771,7 @@
         return gr;
      }
   
  -   private List<NodeData> getNodeData(List<NodeData> list, NodeSPI node)
  +   private List<NodeData> getNodeData(List<NodeData> list, NodeSPI<K, V> node)
      {
         NodeData data = new NodeData(BuddyManager.getActualFqn(node.getFqn()), node.getDataDirect());
         list.add(data);
  @@ -2848,7 +2876,7 @@
         }
      }
   
  -   private void releaseAll(NodeSPI n)
  +   private void releaseAll(NodeSPI<K, V> n)
      {
         for (NodeSPI child : n.getChildrenDirect())
         {
  @@ -3688,7 +3716,7 @@
       * @param fqn Fully qualified name for the corresponding node.
       * @return DataNode
       */
  -   public NodeSPI findNode(Fqn fqn)
  +   public NodeSPI<K, V> findNode(Fqn fqn)
      {
         try
         {
  @@ -3756,11 +3784,11 @@
      /**
       * Finds a node given a fully qualified name and DataVersion.
       */
  -   private NodeSPI findNode(Fqn fqn, DataVersion version) throws CacheException
  +   private NodeSPI<K, V> findNode(Fqn fqn, DataVersion version) throws CacheException
      {
         if (fqn == null) return null;
   
  -      NodeSPI toReturn = peek(fqn, false);
  +      NodeSPI<K, V> toReturn = peek(fqn, false);
   
         if (version != null && configuration.isNodeLockingOptimistic())
         {
  @@ -3841,7 +3869,7 @@
                 "pbcast.STATE_TRANSFER";
      }
   
  -   private void initialiseCacheLoaderManager() throws Exception
  +   private void initialiseCacheLoaderManager() throws CacheException
      {
         if (cacheLoaderManager == null)
         {
  @@ -4047,7 +4075,7 @@
         return remove(fqn);
      }
   
  -   public void putForExternalRead(Fqn fqn, Object key, Object value)
  +   public void putForExternalRead(Fqn fqn, K key, V value)
      {
         // TODO Implement this method PROPERLY as per JBCACHE-848
         // NOTE: DO NOT disable this method prior to JBCACHE-848 being
  
  
  
  1.26      +47 -47    JBossCache/src/org/jboss/cache/UnversionedNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UnversionedNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/UnversionedNode.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -b -r1.25 -r1.26
  --- UnversionedNode.java	7 Mar 2007 18:01:09 -0000	1.25
  +++ UnversionedNode.java	12 Mar 2007 18:13:46 -0000	1.26
  @@ -33,7 +33,7 @@
    * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
    * @since 2.0.0
    */
  -public class UnversionedNode extends AbstractNode implements NodeSPI
  +public class UnversionedNode<K, V> extends AbstractNode<K, V> implements NodeSPI<K, V>
   {
   
      /**
  @@ -65,12 +65,12 @@
      /**
       * A reference of the CacheImpl instance.
       */
  -   private transient CacheImpl cache;
  +   private transient CacheImpl<K, V> cache;
   
      /**
       * Map of general data keys to values.
       */
  -   private final Map<Object, Object> data = new HashMap<Object, Object>();
  +   private final Map<K, V> data = new HashMap<K, V>();
   
      /**
       * Constructs a new node with an FQN of Root.
  @@ -87,7 +87,7 @@
       *                {@link #data} field; <code>false</code> if param <code>data</code>'s contents should be copied into
       *                this object's {@link #data} field.
       */
  -   protected UnversionedNode(Object child_name, Fqn fqn, Map data, boolean mapSafe, CacheSPI cache)
  +   protected UnversionedNode(Object child_name, Fqn fqn, Map<K, V> data, boolean mapSafe, CacheSPI<K, V> cache)
      {
         init(child_name, fqn, cache);
         if (data != null)
  @@ -99,7 +99,7 @@
      /**
       * Initializes with a name and FQN and cache.
       */
  -   private void init(Object child_name, Fqn fqn, CacheSPI cache)
  +   private void init(Object child_name, Fqn fqn, CacheSPI<K, V> cache)
      {
         if (cache == null)
         {
  @@ -116,7 +116,7 @@
      /**
       * Returns a parent by checking the TreeMap by name.
       */
  -   public NodeSPI getParent()
  +   public NodeSPI<K, V> getParent()
      {
         if (fqn.isRoot())
         {
  @@ -133,24 +133,24 @@
         }
      }
   
  -   private synchronized Map<Object, Node> children()
  +   private synchronized Map<Object, Node<K, V>> children()
      {
         if (children == null)
         {
            if (getFqn().isRoot())
            {
  -            children = new ConcurrentHashMap<Object, Node>(64, .5f, 16);
  +            children = new ConcurrentHashMap<Object, Node<K, V>>(64, .5f, 16);
            }
            else
            {
               // Less segments to save memory
  -            children = new ConcurrentHashMap<Object, Node>(4, .75f, 4);
  +            children = new ConcurrentHashMap<Object, Node<K, V>>(4, .75f, 4);
            }
         }
         return children;
      }
   
  -   public CacheSPI getCache()
  +   public CacheSPI<K, V> getCache()
      {
         return cache;
      }
  @@ -165,12 +165,12 @@
         childrenLoaded = flag;
      }
   
  -   public Object get(Object key)
  +   public V get(K key)
      {
         return cache.get(getFqn(), key);
      }
   
  -   public synchronized Object getDirect(Object key)
  +   public synchronized V getDirect(K key)
      {
         return data == null ? null : data.get(key);
      }
  @@ -192,29 +192,29 @@
         return lock_;
      }
   
  -   public Map<Object, Object> getData()
  +   public Map<K, V> getData()
      {
         if (cache == null) return Collections.emptyMap();
  -      Map<Object, Object> dMap = new HashMap<Object, Object>();
  -      for (Object k : cache.getKeys(getFqn()))
  +      Map<K, V> dMap = new HashMap<K, V>();
  +      for (K k : cache.getKeys(getFqn()))
         {
            dMap.put(k, cache.get(fqn, k));
         }
         return Collections.unmodifiableMap(dMap);
      }
   
  -   public synchronized Map<Object, Object> getDataDirect()
  +   public synchronized Map<K, V> getDataDirect()
      {
  -      return new MapCopy(data);
  +      return new MapCopy<K, V>(data);
      }
   
   
  -   public Object put(Object key, Object value)
  +   public V put(K key, V value)
      {
         return cache.put(getFqn(), key, value);
      }
   
  -   public synchronized Object putDirect(Object key, Object value)
  +   public synchronized V putDirect(K key, V value)
      {
         return data.put(key, value);
      }
  @@ -280,12 +280,12 @@
   
      }
   
  -   public Object remove(Object key)
  +   public V remove(K key)
      {
         return cache.remove(getFqn(), key);
      }
   
  -   public synchronized Object removeDirect(Object key)
  +   public synchronized V removeDirect(K key)
      {
         if (data == null) return null;
         return data.remove(key);
  @@ -338,14 +338,14 @@
         return sb.toString();
      }
   
  -   public Node addChild(Fqn f)
  +   public Node<K, V> addChild(Fqn f)
      {
         Fqn nf = new Fqn(getFqn(), f);
         cache.put(nf, null);
         return getChild(f);
      }
   
  -   public void addChildDirect(NodeSPI child)
  +   public void addChildDirect(NodeSPI<K, V> child)
      {
         if (child.getFqn().getParent().equals(getFqn()))
         {
  @@ -358,7 +358,7 @@
            throw new CacheException("Attempting to add a child [" + child.getFqn() + "] to [" + getFqn() + "].  Can only add direct children.");
      }
   
  -   public NodeSPI addChildDirect(Fqn f)
  +   public NodeSPI<K, V> addChildDirect(Fqn f)
      {
         if (f.size() == 1)
         {
  @@ -382,12 +382,12 @@
         if (data != null) data.clear();
      }
   
  -   public Node getChild(Fqn fqn)
  +   public Node<K, V> getChild(Fqn fqn)
      {
         return cache.get(new Fqn(getFqn(), fqn));
      }
   
  -   public NodeSPI getChildDirect(Fqn fqn)
  +   public NodeSPI<K, V> getChildDirect(Fqn fqn)
      {
         if (fqn.size() == 1)
         {
  @@ -416,19 +416,19 @@
         return Collections.unmodifiableSet(new HashSet(new ChildrenNames()));
      }
   
  -   public Set<Object> getKeys()
  +   public Set<K> getKeys()
      {
  -      Set keys = cache.getKeys(getFqn());
  -      return keys == null ? Collections.emptySet() : Collections.unmodifiableSet(keys);
  +      Set<K> keys = cache.getKeys(getFqn());
  +      return (Set<K>) (keys == null ? Collections.emptySet() : Collections.unmodifiableSet(keys));
      }
   
  -   public synchronized Set<Object> getKeysDirect()
  +   public synchronized Set<K> getKeysDirect()
      {
         if (data == null)
         {
            return Collections.emptySet();
         }
  -      return Collections.unmodifiableSet(new HashSet(data.keySet()));
  +      return Collections.unmodifiableSet(new HashSet<K>(data.keySet()));
      }
   
      public boolean hasChild(Fqn f)
  @@ -436,7 +436,7 @@
         return getChild(f) != null;
      }
   
  -   public Object putIfAbsent(Object k, Object v)
  +   public V putIfAbsent(K k, V v)
      {
         // make sure this is atomic.  Not hugely performant at the moment (should use the locking interceptors) but for now ...
         synchronized (this)
  @@ -448,7 +448,7 @@
         }
      }
   
  -   public Object replace(Object key, Object value)
  +   public V replace(K key, V value)
      {
         // make sure this is atomic.  Not hugely performant at the moment (should use the locking interceptors) but for now ...
         synchronized (this)
  @@ -462,7 +462,7 @@
         }
      }
   
  -   public boolean replace(Object key, Object oldValue, Object newValue)
  +   public boolean replace(K key, V oldValue, V newValue)
      {
         // make sure this is atomic.  Not hugely performant at the moment (should use the locking interceptors) but for now ...
         synchronized (this)
  @@ -517,12 +517,12 @@
         }
      }
   
  -   public synchronized Map<Object, Node> getChildrenMapDirect()
  +   public synchronized Map<Object, Node<K, V>> getChildrenMapDirect()
      {
         return new MapCopy(children());
      }
   
  -   public synchronized void setChildrenMapDirect(Map<Object, Node> children)
  +   public synchronized void setChildrenMapDirect(Map<Object, Node<K, V>> children)
      {
         this.children().clear();
         this.children.putAll(children);
  @@ -533,7 +533,7 @@
         cache.put(fqn, data);
      }
   
  -   public synchronized void putAllDirect(Map<Object, Object> data)
  +   public synchronized void putAllDirect(Map<K, V> data)
      {
         if (data == null) return;
         this.data.putAll(data);
  @@ -585,7 +585,7 @@
         }
      }
   
  -   public void addChild(Object child_name, Node n)
  +   public void addChild(Object child_name, Node<K, V> n)
      {
         if (child_name != null)
         {
  @@ -631,21 +631,21 @@
         }
      }
   
  -   public Node getChild(Object childName)
  +   public Node<K, V> getChild(Object childName)
      {
         return cache.get(new Fqn(getFqn(), childName));
      }
   
  -   public synchronized NodeSPI getChildDirect(Object childName)
  +   public synchronized NodeSPI<K, V> getChildDirect(Object childName)
      {
         if (childName == null) return null;
  -      return (NodeSPI) (children == null ? null : children.get(childName));
  +      return (NodeSPI<K, V>) (children == null ? null : children.get(childName));
      }
   
  -   public Set<Node> getChildren()
  +   public Set<Node<K, V>> getChildren()
      {
         if (cache == null) return Collections.emptySet();
  -      Set<Node> children = new HashSet<Node>();
  +      Set<Node<K, V>> children = new HashSet<Node<K, V>>();
         for (Object c : cache.getChildrenNames(getFqn()))
         {
            Node n = cache.get(new Fqn(getFqn(), c));
  @@ -654,12 +654,12 @@
         return Collections.unmodifiableSet(children);
      }
   
  -   public synchronized Set<NodeSPI> getChildrenDirect()
  +   public synchronized Set<NodeSPI<K, V>> getChildrenDirect()
      {
         // strip out deleted child nodes...
         if (children == null || children.size() == 0) return Collections.emptySet();
   
  -      Set<NodeSPI> exclDeleted = new HashSet<NodeSPI>();
  +      Set<NodeSPI<K, V>> exclDeleted = new HashSet<NodeSPI<K, V>>();
         for (Node n : children.values())
         {
            NodeSPI spi = (NodeSPI) n;
  @@ -668,7 +668,7 @@
         return Collections.unmodifiableSet(exclDeleted);
      }
   
  -   public synchronized Set<NodeSPI> getChildrenDirect(boolean includeMarkedForRemoval)
  +   public synchronized Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
      {
         if (includeMarkedForRemoval)
         {
  
  
  
  1.34      +3 -3      JBossCache/src/org/jboss/cache/CacheSPI.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheSPI.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheSPI.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -b -r1.33 -r1.34
  --- CacheSPI.java	9 Feb 2007 17:23:57 -0000	1.33
  +++ CacheSPI.java	12 Mar 2007 18:13:46 -0000	1.34
  @@ -44,12 +44,12 @@
    * @since 2.0.0
    */
   @ThreadSafe
  -public interface CacheSPI extends Cache
  +public interface CacheSPI<K, V> extends Cache<K, V>
   {
      /**
       * Overrides {@link org.jboss.cache.Cache#getRoot()} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
       */
  -   NodeSPI getRoot();
  +   NodeSPI<K, V> getRoot();
   
      /**
       * Retrieves a reference to a running {@link javax.transaction.TransactionManager}, if one is configured.
  @@ -157,7 +157,7 @@
       * @param includeDeletedNodes if you intend to see nodes marked as deleted within the current tx, set this to true
       * @return a node if one exists or null
       */
  -   NodeSPI peek(Fqn fqn, boolean includeDeletedNodes);
  +   NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes);
   
      /**
       * Used with buddy replication's data gravitation interceptor.  If marshalling is necessary, ensure that the cache is
  
  
  
  1.6       +7 -7      JBossCache/src/org/jboss/cache/CacheFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CacheFactory.java	9 Feb 2007 17:23:57 -0000	1.5
  +++ CacheFactory.java	12 Mar 2007 18:13:46 -0000	1.6
  @@ -35,7 +35,7 @@
    * @since 2.0.0
    */
   @ThreadSafe
  -public interface CacheFactory
  +public interface CacheFactory<K, V>
   {
      /**
       * Creates and starts a {@link Cache} instance using default configuration settings.  See {@link Configuration} for default values.
  @@ -43,7 +43,7 @@
       * @return a cache
       * @throws ConfigurationException if there are problems with the default configuration
       */
  -   Cache createCache() throws ConfigurationException;
  +   Cache<K, V> createCache() throws ConfigurationException;
   
      /**
       * Creates and optionally starts a {@link Cache} instance using default configuration settings.  See {@link Configuration} for default values.
  @@ -52,7 +52,7 @@
       * @return a cache
       * @throws ConfigurationException if there are problems with the default configuration
       */
  -   Cache createCache(boolean start) throws ConfigurationException;
  +   Cache<K, V> createCache(boolean start) throws ConfigurationException;
   
      /**
       * Creates and starts a {@link org.jboss.cache.Cache} instance
  @@ -62,7 +62,7 @@
       * @throws org.jboss.cache.config.ConfigurationException
       *          if there are problems with the configuration
       */
  -   Cache createCache(String configFileName) throws ConfigurationException;
  +   Cache<K, V> createCache(String configFileName) throws ConfigurationException;
   
      /**
       * Creates {@link Cache} instance, and optionally starts it.
  @@ -73,7 +73,7 @@
       * @throws org.jboss.cache.config.ConfigurationException
       *          if there are problems with the configuration
       */
  -   Cache createCache(String configFileName, boolean start) throws ConfigurationException;
  +   Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException;
   
      /**
       * Creates a {@link Cache} instance based on a {@link org.jboss.cache.config.Configuration} passed in.
  @@ -87,7 +87,7 @@
       * @throws org.jboss.cache.config.ConfigurationException
       *          if there are problems with the configuration
       */
  -   Cache createCache(Configuration configuration) throws ConfigurationException;
  +   Cache<K, V> createCache(Configuration configuration) throws ConfigurationException;
   
      /**
       * Creates {@link Cache} instance, and optionally starts it, based on a {@link org.jboss.cache.config.Configuration} passed in.
  @@ -102,5 +102,5 @@
       * @throws org.jboss.cache.config.ConfigurationException
       *          if there are problems with the configuration
       */
  -   Cache createCache(Configuration configuration, boolean start) throws ConfigurationException;
  +   Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException;
   }
  
  
  
  1.50      +139 -193  JBossCache/src/org/jboss/cache/Fqn.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Fqn.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Fqn.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -b -r1.49 -r1.50
  --- Fqn.java	9 Feb 2007 12:52:42 -0000	1.49
  +++ Fqn.java	12 Mar 2007 18:13:46 -0000	1.50
  @@ -15,12 +15,9 @@
   import java.io.IOException;
   import java.io.ObjectInput;
   import java.io.ObjectOutput;
  -import java.security.AccessController;
  -import java.security.PrivilegedAction;
   import java.util.ArrayList;
   import java.util.Arrays;
   import java.util.Collections;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.StringTokenizer;
   
  @@ -36,23 +33,23 @@
    * this.  (Here data on "Joe" is kept under the "Smith" surname node, under
    * the "people" tree.)
    * <pre>
  - * Fqn abc = Fqn.fromString("/people/Smith/Joe/");
  + * Fqn<String> abc = Fqn.fromString("/people/Smith/Joe/");
    * Node joesmith = Cache.getRoot().getChild(abc);
    * </pre>
    * Alternatively, the same Fqn could be constructed using an array:
    * <pre>
  - * Fqn abc = new Fqn(new String[] { "people", "Smith", "Joe" });
  + * Fqn<String> abc = new Fqn<String>(new String[] { "people", "Smith", "Joe" });
    * </pre>
    * This is a bit more efficient to construct.
    * <p/>
    * <p/>
    * Note that<br>
    * <p/>
  - * <code>Fqn f = new Fqn("/a/b/c");</code>
  + * <code>Fqn<String> f = new Fqn<String>("/a/b/c");</code>
    * <p/>
    * is <b>not</b> the same as
    * <p/>
  - * <code>Fqn f = Fqn.fromString("/a/b/c");</code>
  + * <code>Fqn<String> f = Fqn.fromString("/a/b/c");</code>
    * <p/>
    * The former will result in a single Fqn, called "/a/b/c" which hangs directly under Fqn.ROOT.
    * <p/>
  @@ -61,60 +58,19 @@
    * Another way to look at it is that the "/" separarator is only parsed when it forms
    * part of a String passed in to Fqn.fromString() and not otherwise.
    *
  - * @version $Revision: 1.49 $
  + * @version $Revision: 1.50 $
    */
   @Immutable
  -public class Fqn implements Cloneable, Externalizable, Comparable<Fqn>
  +public class Fqn<E> implements Cloneable, Externalizable, Comparable<Fqn>
   {
   
      /**
       * Separator between FQN elements.
       */
      public static final String SEPARATOR = "/";
  -
  -   private List elements;
  -   private transient int hash_code = 0;
  -
  -   /**
  -    * Controls the implementation of read/writeExternal.
  -    * Package protected so CacheImpl can set it when ReplicationVersion is set.
  -    */
  -   static boolean REL_123_COMPATIBLE = false;
  -
  -   static
  -   {
  -      // Check if they set a system property telling us to use 1.2.3 compatibility mode
  -      // Obscure use case for this: Server has multiple caches, only one of which has
  -      // CacheImpl.setReplicationVersion() set to "1.2.3".  If the 1.2.4+ caches start
  -      // first, they will begin exchanging 1.2.4 style fqn's, and then when the 1.2.3
  -      // cache starts the format will change when it changes REL_123_COMPATIBLE.  This
  -      // could cause chaos. The system property allows the 1.2.3 mode to be used by
  -      // the 1.2.4 caches from the start.
  -      try
  -      {
  -         AccessController.doPrivileged(
  -                 new PrivilegedAction()
  -                 {
  -                    public Object run()
  -                    {
  -                       String compatible = System.getProperty("jboss.cache.fqn.123compatible");
  -                       REL_123_COMPATIBLE = Boolean.valueOf(compatible);
  -                       return null;
  -                    }
  -                 });
  -      }
  -      catch (SecurityException ignored)
  -      {
  -         // they just can't use system properties
  -      }
  -      catch (Throwable t)
  -      {
  -         LogFactory.getLog(Fqn.class).error("Caught throwable reading system property " +
  -                 "jboss.cache.fqn.123compatible", t);
  -      }
  -   }
  -
      private static final long serialVersionUID = -5351930616956603651L;
  +   private List<E> elements;
  +   private transient int hash_code = 0;
   
      /**
       * Immutable root FQN.
  @@ -127,43 +83,48 @@
       */
      public Fqn()
      {
  -      elements = Collections.EMPTY_LIST;
  +      elements = Collections.emptyList();
      }
   
      /**
       * Constructs a single element Fqn.  Note that if a String is passed in, separator characters {@link #SEPARATOR} are <b>not</b> parsed.
       * If you wish these to be parsed, use {@link #fromString(String)}.
       *
  +    * @param name the name of the node identified by the Fqn
       * @see #fromString(String)
       */
  -   public Fqn(Object name)
  +   public Fqn(E name)
      {
         elements = Collections.singletonList(name);
      }
   
      /**
       * Constructs a FQN from a list of names.
  +    *
  +    * @param names List of names
       */
  -   public Fqn(List names)
  +   public Fqn(List<E> names)
      {
         if (names != null)
         {
  -         elements = Arrays.asList(names.toArray());
  +         elements = new ArrayList<E>(names);
         }
         else
         {
  -         elements = Collections.EMPTY_LIST;
  +         elements = Collections.emptyList();
         }
      }
   
      /**
  -    * Constructs a FQN from an array of names.
  +    * Constructs a Fqn from an array of names.
  +    *
  +    * @param names Names that comprose this Fqn
       */
  -   public Fqn(Object[] names)
  +   public Fqn(E... names)
      {
         if (names == null)
         {
  -         elements = Collections.EMPTY_LIST;
  +         elements = Collections.emptyList();
         }
         else
         {
  @@ -172,69 +133,55 @@
      }
   
      /**
  -    * Constructs a FQN from a base and relative name.
  -    */
  -   public Fqn(Fqn base, Object relative_name)
  -   {
  -      elements = new ArrayList(base.elements.size() + 1);
  -      elements.addAll(base.elements);
  -      elements.add(relative_name);
  -   }
  -
  -   /**
  -    * Constructs a FQN from a base and relative FQN.
  +    * Constructs a Fqn from a base and relative Fqn.
  +    *
  +    * @param base     parent Fqn
  +    * @param relative Sub-Fqn relative to the parent
       */
  -   public Fqn(Fqn base, Fqn relative)
  +   public Fqn(Fqn<E> base, Fqn<E> relative)
      {
         this(base, relative.elements);
      }
   
      /**
  -    * Constructs a FQN from a base and a list of relative names.
  +    * Constructs a Fqn from a base and a list of relative names.
  +    *
  +    * @param base     parent Fqn
  +    * @param relative List of elements that identify the child Fqn, relative to the parent
       */
  -   public Fqn(Fqn base, List relative)
  +   public Fqn(Fqn<E> base, List<E> relative)
      {
  -      elements = new ArrayList(base.elements.size() + relative.size());
  +      elements = new ArrayList<E>(base.elements.size() + relative.size());
         elements.addAll(base.elements);
         elements.addAll(relative);
      }
   
      /**
  -    * Constructs a FQN from a base and two relative names.
  -    */
  -   public Fqn(Fqn base, Object relative_name1, Object relative_name2)
  -   {
  -      elements = new ArrayList(base.elements.size() + 2);
  -      elements.addAll(base.elements);
  -      elements.add(relative_name1);
  -      elements.add(relative_name2);
  -   }
  -
  -   /**
  -    * Constructs a FQN from a base and three relative names.
  +    * Constructs a Fqn from a base and two relative names.
  +    *
  +    * @param base       parent Fqn
  +    * @param childNames elements that denote the path to the Fqn, under the parent
       */
  -   public Fqn(Fqn base, Object relative_name1, Object relative_name2, Object relative_name3)
  +   public Fqn(Fqn<E> base, E... childNames)
      {
  -      elements = new ArrayList(base.elements.size() + 3);
  +      elements = new ArrayList<E>(base.elements.size() + childNames.length);
         elements.addAll(base.elements);
  -      elements.add(relative_name1);
  -      elements.add(relative_name2);
  -      elements.add(relative_name3);
  +      for (E relative : childNames) elements.add(relative);
      }
   
      /**
       * Construct from an unmodifiable list.
       * For internal use.
       */
  -   private static Fqn createFqn(List list)
  +   private static <T> Fqn<T> createFqn(List<T> list)
      {
  -      Fqn fqn = new Fqn();
  +      Fqn<T> fqn = new Fqn<T>();
         fqn.elements = list;
         return fqn;
      }
   
      /**
  -    * Returns a new FQN from a string, where the elements are deliminated by
  +    * Returns a new Fqn from a string, where the elements are deliminated by
       * one or more separator ({@link #SEPARATOR}) characters.<br><br>
       * Example use:<br>
       * <pre>
  @@ -242,29 +189,30 @@
       * </pre><br>
       * is equivalent to:<br>
       * <pre>
  -    * new Fqn(new Object[] { "a", "b", "c" });
  +    * new Fqn<String>(new String[] { "a", "b", "c" });
       * </pre><br>
       * but not<br>
       * <pre>
  -    * new Fqn("/a/b/c");
  +    * new Fqn<String>("/a/b/c");
       * </pre>
       *
  +    * @param stringRepresentation String representation of the Fqn
  +    * @return an Fqn<String> constructed from the string representation passed in
       * @see #Fqn(Object[])
  -    * @see #Fqn(Object)
       */
  -   public static Fqn fromString(String fqn)
  +   public static Fqn<String> fromString(String stringRepresentation)
      {
  -      if (fqn == null)
  +      if (stringRepresentation == null)
         {
            return ROOT;
         }
  -      return createFqn(parse(fqn));
  +      return createFqn(parse(stringRepresentation));
      }
   
  -   private static List parse(String fqn)
  +   private static List<String> parse(String stringRepresentation)
      {
  -      List list = new ArrayList();
  -      StringTokenizer tok = new StringTokenizer(fqn, SEPARATOR);
  +      List<String> list = new ArrayList<String>();
  +      StringTokenizer tok = new StringTokenizer(stringRepresentation, SEPARATOR);
         while (tok.hasMoreTokens())
         {
            list.add(tok.nextToken());
  @@ -273,36 +221,44 @@
      }
   
      /**
  -    * Obtains a sub-Fqn from the given Fqn.  Literally performs <code>elements.subList(0, index)</code>
  +    * Obtains an ancestor of the current Fqn.  Literally performs <code>elements.subList(0, generation)</code>
       * such that if
       * <code>
  -    * index == fqn.size()
  +    * generation == Fqn.size()
       * </code>
  -    * then the return value is the fqn itself, and if
  +    * then the return value is the Fqn itself (current generation), and if
       * <code>
  -    * index == fqn.size() - 1
  +    * generation == Fqn.size() - 1
       * </code>
       * then the return value is the same as
       * <code>
  -    * fqn.getParent()
  +    * Fqn.getParent()
  +    * </code>
  +    * i.e., just one generation behind the current generation.
  +    * <code>
  +    * generation == 0
       * </code>
  +    * would return Fqn.ROOT.
  +    *
  +    * @param generation the generation of the ancestor to retrieve
  +    * @return an ancestor of the current Fqn
       */
  -   public Fqn getFqnChild(int index)
  +   public Fqn<E> getAncestor(int generation)
      {
  -      return getFqnChild(0, index);
  +      if (generation == 0) return Fqn.ROOT;
  +      return getSubFqn(0, generation);
      }
   
      /**
       * Obtains a sub-Fqn from the given Fqn.  Literally performs <code>elements.subList(startIndex, endIndex)</code>
       */
  -   public Fqn getFqnChild(int startIndex, int endIndex)
  +   public Fqn<E> getSubFqn(int startIndex, int endIndex)
      {
         return createFqn(elements.subList(startIndex, endIndex));
      }
   
      /**
  -    * Returns the number of elements in the FQN.
  -    * The root node contains zero.
  +    * @return the number of elements in the Fqn.  The root node contains zero.
       */
      public int size()
      {
  @@ -310,40 +266,41 @@
      }
   
      /**
  -    * Returns the Nth element in the FQN.
  +    * @param n index of the element to return
  +    * @return Returns the nth element in the Fqn.
       */
  -   public Object get(int index)
  +   public E get(int n)
      {
  -      return elements.get(index);
  +      return elements.get(n);
      }
   
      /**
  -    * Returns the last element in the FQN.
  -    *
  +    * @return the last element in the Fqn.
       * @see #getLastElementAsString
       */
  -   public Object getLastElement()
  +   public E getLastElement()
      {
  -      if (isRoot()) return SEPARATOR;
  +      if (isRoot()) return null;
         return elements.get(elements.size() - 1);
      }
   
      /**
  -    * Returns true if the FQN contains this element.
  +    * @param element element to find
  +    * @return true if the Fqn contains this element, false otherwise.
       */
  -   public boolean hasElement(Object o)
  +   public boolean hasElement(E element)
      {
  -      return elements.lastIndexOf(o) != -1;
  +      return elements.lastIndexOf(element) != -1;
      }
   
      /**
  -    * Clones the FQN.
  +    * Clones the Fqn.
       */
  -   public Fqn clone()
  +   public Fqn<E> clone() throws CloneNotSupportedException
      {
         try
         {
  -         return (Fqn) super.clone();
  +         return (Fqn<E>) super.clone();
         }
         catch (CloneNotSupportedException e)
         {
  @@ -353,7 +310,7 @@
      }
   
      /**
  -    * Returns true if obj is a FQN with the same elements.
  +    * Returns true if obj is a Fqn with the same elements.
       */
      public boolean equals(Object obj)
      {
  @@ -370,7 +327,7 @@
      }
   
      /**
  -    * Returns a hash code with FQN elements.
  +    * Returns a hash code with Fqn elements.
       */
      public int hashCode()
      {
  @@ -382,9 +339,9 @@
      }
   
      /**
  -    * Returns this FQN as a string, prefixing the first element with a / and
  -    * joining each subsequent element with a /.
  -    * If this is the root FQN, returns {@link Fqn#SEPARATOR}.
  +    * Returns this Fqn as a string, prefixing the first element with a {@link Fqn#SEPARATOR} and
  +    * joining each subsequent element with a {@link Fqn#SEPARATOR}.
  +    * If this is the root Fqn, returns {@link Fqn#SEPARATOR}.
       * Example:
       * <pre>
       * new Fqn(new Object[] { "a", "b", "c" }).toString(); // "/a/b/c"
  @@ -395,87 +352,69 @@
      {
         if (isRoot()) return SEPARATOR;
         StringBuffer sb = new StringBuffer();
  -      for (Iterator it = elements.iterator(); it.hasNext();)
  +      for (E element : elements)
         {
  -         sb.append(SEPARATOR).append(it.next());
  +         sb.append(SEPARATOR).append(element);
         }
         return sb.toString();
      }
   
      public void writeExternal(ObjectOutput out) throws IOException
      {
  -      if (REL_123_COMPATIBLE)
  -      {
  -         out.writeObject(elements);
  -      }
  -      else
  -      {
            out.writeShort(elements.size());
  -         Object element;
  -         for (Iterator it = elements.iterator(); it.hasNext();)
  +      for (E element : elements)
            {
  -            element = it.next();
               out.writeObject(element);
            }
         }
  -   }
   
      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      {
  -
  -      if (REL_123_COMPATIBLE)
  -      {
  -         elements = (List) in.readObject();
  -      }
  -      else
  -      {
            short length = in.readShort();
  -         this.elements = new ArrayList(length);
  +      this.elements = new ArrayList<E>(length);
            for (int i = 0; i < length; i++)
            {
  -            elements.add(in.readObject());
  -         }
  +         elements.add((E) in.readObject());
         }
      }
   
   
      /**
  -    * Returns true if this fqn is child of parentFqn.
  +    * Returns true if this Fqn is child of parentFqn.
       * Example usage:
       * <pre>
  -    * Fqn f1 = Fqn.fromString("/a/b");
  -    * Fqn f2 = Fqn.fromString("/a/b/c");
  -    * // f1.isChildOf(f2) == true
  -    * // f1.isChildOf(f1) == false
  -    * // f2.isChildOf(f1) == false
  +    * Fqn<String> f1 = Fqn.fromString("/a/b");
  +    * Fqn<String> f2 = Fqn.fromString("/a/b/c");
  +    * assertTrue(f1.isChildOf(f2));
  +    * assertFalse(f1.isChildOf(f1));
  +    * assertFalse(f2.isChildOf(f1));
       * </pre>
       *
  -    * @param parentFqn
  +    * @param parentFqn candidate parent to test against
       * @return true if the target is a child of parentFqn
       */
  -   public boolean isChildOf(Fqn parentFqn)
  -   {
  -      if (parentFqn.elements.size() == elements.size())
  +   public boolean isChildOf(Fqn<E> parentFqn)
         {
  -         return false;
  -      }
  -      return isChildOrEquals(parentFqn);
  +      return parentFqn.elements.size() != elements.size() && isChildOrEquals(parentFqn);
      }
   
      /**
  -    * Returns true if this fqn is equals or the child of parentFqn.
  +    * Returns true if this Fqn is equals or the child of parentFqn.
       * Example usage:
       * <pre>
  -    * Fqn f1 = Fqn.fromString("/a/b");
  -    * Fqn f2 = Fqn.fromString("/a/b/c");
  -    * // f1.isChildOrEquals(f2) == true
  -    * // f1.isChildOrEquals(f1) == true
  -    * // f2.isChildOrEquals(f1) == false
  +    * Fqn<String> f1 = Fqn.fromString("/a/b");
  +    * Fqn<String> f2 = Fqn.fromString("/a/b/c");
  +    * assertTrue(f1.isChildOrEquals(f2));
  +    * assertTrue(f1.isChildOrEquals(f1));
  +    * assertFalse(f2.isChildOrEquals(f1));
       * </pre>
  +    *
  +    * @param parentFqn candidate parent to test against
  +    * @return true if this Fqn is equals or the child of parentFqn.
       */
  -   public boolean isChildOrEquals(Fqn parentFqn)
  +   public boolean isChildOrEquals(Fqn<E> parentFqn)
      {
  -      List parentList = parentFqn.elements;
  +      List<E> parentList = parentFqn.elements;
         if (parentList.size() > elements.size())
         {
            return false;
  @@ -492,15 +431,17 @@
   
      /**
       * Calculates a hash code by summing the hash code of all elements.
  +    *
  +    * @return a cached hashcode
       */
      private int _hashCode()
      {
         int hashCode = 0;
         int count = 1;
         Object o;
  -      for (Iterator it = elements.iterator(); it.hasNext();)
  +      for (E element : elements)
         {
  -         o = it.next();
  +         o = element;
            hashCode += (o == null) ? 0 : o.hashCode() * count++;
         }
         if (hashCode == 0)// fix degenerate case
  @@ -511,18 +452,20 @@
      }
   
      /**
  -    * Returns the parent of this FQN.
  +    * Returns the parent of this Fqn.
       * The parent of the root node is {@link #ROOT}.
       * Examples:
       * <pre>
  -    * Fqn f1 = Fqn.fromString("/a");
  -    * Fqn f2 = Fqn.fromString("/a/b");
  -    * // f1.equals( f2.getParent() ) == true
  -    * // f1.getParent().getParent().equals(Fqn.ROOT) == true
  -    * // Fqn.ROOT.equals( Fqn.ROOT.getParent() ) == true
  +    * Fqn<String> f1 = Fqn.fromString("/a");
  +    * Fqn<String> f2 = Fqn.fromString("/a/b");
  +    * assertEquals(f1, f2.getParent());
  +    * assertEquals(Fqn.ROOT, f1.getParent().getParent());
  +    * assertEquals(Fqn.ROOT, Fqn.ROOT.getParent());
       * </pre>
  +    *
  +    * @return the parent Fqn
       */
  -   public Fqn getParent()
  +   public Fqn<E> getParent()
      {
         switch (elements.size())
         {
  @@ -535,7 +478,9 @@
      }
   
      /**
  -    * Returns true if this is a root FQN.
  +    * Returns true if this is a root Fqn.
  +    *
  +    * @return true if the Fqn is Fqn.ROOT.
       */
      public boolean isRoot()
      {
  @@ -543,8 +488,9 @@
      }
   
      /**
  -    * Returns a String representation of the last element that makes up this Fqn.
       * If this is the root, returns {@link Fqn#SEPARATOR}.
  +    *
  +    * @return a String representation of the last element that makes up this Fqn.
       */
      public String getLastElementAsString()
      {
  @@ -564,7 +510,7 @@
       *
       * @return an unmodifiable list
       */
  -   public List peekElements()
  +   public List<E> peekElements()
      {
         return Collections.unmodifiableList(elements);
      }
  @@ -572,8 +518,8 @@
      /**
       * Compares this Fqn to another using {@link FqnComparator}.
       */
  -   public int compareTo(Fqn fqn)
  +   public int compareTo(Fqn Fqn)
      {
  -      return FqnComparator.INSTANCE.compare(this, fqn);
  +      return FqnComparator.INSTANCE.compare(this, Fqn);
      }
   }
  \ No newline at end of file
  
  
  
  1.62      +18 -17    JBossCache/src/org/jboss/cache/Node.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Node.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Node.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -b -r1.61 -r1.62
  --- Node.java	9 Feb 2007 17:23:57 -0000	1.61
  +++ Node.java	12 Mar 2007 18:13:46 -0000	1.62
  @@ -34,7 +34,7 @@
    * @since 2.0.0
    */
   @ThreadSafe
  -public interface Node
  +public interface Node<K, V>
   {
      /**
       * Returns the parent node.
  @@ -42,14 +42,14 @@
       *
       * @return the parent node, or null if this is the root node
       */
  -   Node getParent();
  +   Node<K, V> getParent();
   
      /**
       * Returns an immutable set of children nodes.
       *
       * @return an immutable {@link Set} of child nodes.  Empty {@link Set} if there aren't any children.
       */
  -   Set<Node> getChildren();
  +   Set<Node<K, V>> getChildren();
   
      /**
       * Returns an immutable set of children node names.
  @@ -63,14 +63,14 @@
       *
       * @return a {@link Map} containing the data in this {@link Node}.  If there is no data, an empty {@link Map} is returned.  The {@link Map} returned is always immutable.
       */
  -   Map<Object, Object> getData();
  +   Map<K, V> getData();
   
      /**
       * Returns a {@link Set} containing the data in this {@link Node}.
       *
       * @return a {@link Set} containing the data in this {@link Node}.  If there is no data, an empty {@link Set} is returned.  The {@link Set} returned is always immutable.
       */
  -   Set<Object> getKeys();
  +   Set<K> getKeys();
   
      /**
       * Returns the {@link Fqn} which represents the location of this {@link Node} in the cache structure.  The {@link Fqn} returned is absolute.
  @@ -90,7 +90,7 @@
       * @param f {@link Fqn} of the child node, relative to the current node.
       * @return the newly created node, or the existing node if one already exists.
       */
  -   Node addChild(Fqn f);
  +   Node<K, V> addChild(Fqn f);
   
      /**
       * Removes a child node specified by the given relative {@link Fqn}.
  @@ -117,12 +117,13 @@
       * @param f {@link Fqn} of the child node
       * @return null if the child does not exist.
       */
  -   Node getChild(Fqn f);
  +   Node<K, V> getChild(Fqn f);
   
      /**
  -    * Returns a direct child of the current node.
  +    * @param name name of the child
  +    * @return a direct child of the current node.
       */
  -   Node getChild(Object name);
  +   Node<K, V> getChild(Object name);
   
      /**
       * Associates the specified value with the specified key for this node.
  @@ -132,7 +133,7 @@
       * @param value value to be associated with the specified key.
       * @return Returns the old value contained under this key.  Null if key doesn't exist.
       */
  -   Object put(Object key, Object value);
  +   V put(K key, V value);
   
      /**
       * If the specified key is not already associated with a value, associate it with the given value, and returns the
  @@ -152,7 +153,7 @@
       * @param value value to be associated with the specified key.
       * @return previous value associated with specified key, or null if there was no mapping for key.
       */
  -   Object putIfAbsent(Object key, Object value);
  +   V putIfAbsent(K key, V value);
   
      /**
       * Replace entry for key only if currently mapped to some value.
  @@ -173,7 +174,7 @@
       * @return previous value associated with specified key, or <tt>null</tt>
       *         if there was no mapping for key.
       */
  -   Object replace(Object key, Object value);
  +   V replace(K key, V value);
   
      /**
       * Replace entry for key only if currently mapped to given value.
  @@ -195,7 +196,7 @@
       * @param newValue value to be associated with the specified key.
       * @return true if the value was replaced
       */
  -   boolean replace(Object key, Object oldValue, Object newValue);
  +   boolean replace(K key, V oldValue, V newValue);
   
   
      /**
  @@ -210,16 +211,16 @@
       *
       * @param map map to copy from
       */
  -   void putAll(Map<Object, Object> map);
  +   void putAll(Map<K, V> map);
   
      /**
       * Returns the value to which this node maps the specified key.
       * Returns <code>null</code> if the node contains no mapping for this key.
       *
  -    * @param k key of the data to return
  +    * @param key key of the data to return
       * @return the value to which this node maps the specified key, or <code>null</code> if the map contains no mapping for this key
       */
  -   Object get(Object k);
  +   V get(K key);
   
      /**
       * Removes the mapping for this key from this node if it is present.
  @@ -230,7 +231,7 @@
       * @return previous value associated with specified key, or <code>null</code>
       *         if there was no mapping for key
       */
  -   Object remove(Object key);
  +   V remove(K key);
   
      /**
       * Removes all mappings from the node's data map.
  
  
  
  1.6       +10 -13    JBossCache/src/org/jboss/cache/DefaultCacheFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DefaultCacheFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/DefaultCacheFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- DefaultCacheFactory.java	28 Feb 2007 18:22:55 -0000	1.5
  +++ DefaultCacheFactory.java	12 Mar 2007 18:13:46 -0000	1.6
  @@ -6,8 +6,6 @@
    */
   package org.jboss.cache;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.config.Configuration;
   import org.jboss.cache.config.ConfigurationException;
   import org.jboss.cache.factories.XmlConfigurationParser;
  @@ -18,10 +16,9 @@
    *
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    */
  -public class DefaultCacheFactory implements CacheFactory
  +public class DefaultCacheFactory<K, V> implements CacheFactory<K, V>
   {
      private static CacheFactory singleton = new DefaultCacheFactory();
  -   private Log log = LogFactory.getLog(DefaultCacheFactory.class);
   
      /**
       * Protected constructor to prevent instantiation by user code
  @@ -32,29 +29,29 @@
      }
   
      /**
  -    * Returns a singleton instance of this class.
  +    * @return a singleton instance of this class.
       */
  -   public static CacheFactory getInstance()
  +   public static <K, V> CacheFactory<K, V> getInstance()
      {
         return singleton;
      }
   
  -   public Cache createCache() throws ConfigurationException
  +   public Cache<K, V> createCache() throws ConfigurationException
      {
         return createCache(true);
      }
   
  -   public Cache createCache(boolean start) throws ConfigurationException
  +   public Cache<K, V> createCache(boolean start) throws ConfigurationException
      {
         return createCache(new Configuration(), start);
      }
   
  -   public Cache createCache(String configFileName) throws ConfigurationException
  +   public Cache<K, V> createCache(String configFileName) throws ConfigurationException
      {
         return createCache(configFileName, true);
      }
   
  -   public Cache createCache(String configFileName, boolean start) throws ConfigurationException
  +   public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
      {
         XmlConfigurationParser parser = new XmlConfigurationParser();
         Configuration c = parser.parseFile(configFileName);
  @@ -68,7 +65,7 @@
       * @return a cache
       * @throws ConfigurationException if there are problems with the cfg
       */
  -   public Cache createCache(Configuration configuration) throws ConfigurationException
  +   public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException
      {
         return createCache(configuration, true);
      }
  @@ -81,11 +78,11 @@
       * @return a cache
       * @throws ConfigurationException if there are problems with the cfg
       */
  -   public Cache createCache(Configuration configuration, boolean start) throws ConfigurationException
  +   public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
      {
         try
         {
  -         CacheImpl cache = new CacheImpl();
  +         CacheImpl<K, V> cache = new CacheImpl<K, V>();
            cache.setConfiguration(configuration);
            if (start) cache.start();
            return cache;
  
  
  
  1.26      +16 -12    JBossCache/src/org/jboss/cache/Cache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Cache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Cache.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -b -r1.25 -r1.26
  --- Cache.java	9 Feb 2007 17:23:57 -0000	1.25
  +++ Cache.java	12 Mar 2007 18:13:46 -0000	1.26
  @@ -78,7 +78,7 @@
    * @since 2.0.0
    */
   @ThreadSafe
  -public interface Cache
  +public interface Cache<K, V>
   {
      /**
       * Retrieves the configuration of this cache.
  @@ -92,7 +92,7 @@
       *
       * @return the root node
       */
  -   Node getRoot();
  +   Node<K, V> getRoot();
   
      /**
       * Adds a {@link CacheListener} to the entire cache.
  @@ -148,7 +148,7 @@
       * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
       *         A <code>null</code> return can also indicate that the Node previously associated <code>null</code> with the specified key, if the implementation supports null values.
       */
  -   Object put(Fqn fqn, Object key, Object value);
  +   V put(Fqn fqn, K key, V value);
   
      /**
       * Under special operating behavior, associates the value with the specified key for a node identified by the Fqn passed in.
  @@ -171,7 +171,7 @@
       * @param key   key with which the specified value is to be associated.
       * @param value value to be associated with the specified key.
       */
  -   void putForExternalRead(Fqn fqn, Object key, Object value);
  +   void putForExternalRead(Fqn fqn, K key, V value);
   
      /**
       * Copies all of the mappings from the specified map to a {@link Node}.
  @@ -179,7 +179,7 @@
       * @param fqn  <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to copy the data to
       * @param data mappings to copy
       */
  -   void put(Fqn fqn, Map data);
  +   void put(Fqn fqn, Map<K, V> data);
   
      /**
       * Removes the mapping for this key from a Node.
  @@ -190,7 +190,7 @@
       * @param key key whose mapping is to be removed from the Node
       * @return previous value associated with specified Node's key
       */
  -   Object remove(Fqn fqn, Object key);
  +   V remove(Fqn fqn, K key);
   
      /**
       * Removes a {@link Node} indicated by absolute {@link Fqn}.
  @@ -204,9 +204,10 @@
       * Convenience method that allows for direct access to the data in a {@link Node}.
       *
       * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
  -    * @param key
  +    * @param key key under which value is to be retrieved.
  +    * @return returns data held under specified key in {@link Node} denoted by specified Fqn.
       */
  -   Object get(Fqn fqn, Object key);
  +   V get(Fqn fqn, K key);
   
      /**
       * Eviction call that evicts the specified {@link Node} from memory.
  @@ -241,14 +242,18 @@
   
      /**
       * Lifecycle method that initializes configuration state, the root node, etc.
  +    *
  +    * @throws CacheException if there are creation problems
       */
  -   void create() throws Exception;
  +   void create() throws CacheException;
   
      /**
       * Lifecycle method that starts the cache loader,
       * starts cache replication, starts the region manager, etc.
  +    *
  +    * @throws CacheException if there are startup problems
       */
  -   void start() throws Exception;
  +   void start() throws CacheException;
   
      /**
       * Lifecycle method that stops the cache, including replication,
  @@ -263,8 +268,7 @@
      void destroy();
   
      /**
  -    * Retrieves the current invocation context for the current invocation and cache instance.
  -    *
  +    * @return the current invocation context for the current invocation and cache instance.
       * @see org.jboss.cache.InvocationContext
       */
      InvocationContext getInvocationContext();
  
  
  
  1.11      +4 -4      JBossCache/src/org/jboss/cache/VersionedNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: VersionedNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/VersionedNode.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- VersionedNode.java	19 Jan 2007 14:47:40 -0000	1.10
  +++ VersionedNode.java	12 Mar 2007 18:13:46 -0000	1.11
  @@ -22,7 +22,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @since 2.0.0
    */
  -public class VersionedNode extends UnversionedNode
  +public class VersionedNode<K, V> extends UnversionedNode<K, V>
   {
      private DataVersion version;
      /**
  @@ -30,9 +30,9 @@
       * node is actually disconnected from the CacheImpl itself.
       * The parent could be looked up from the TransactionWorkspace.
       */
  -   private NodeSPI parent;
  +   private NodeSPI<K, V> parent;
   
  -   protected VersionedNode(Fqn fqn, NodeSPI parent, Map data, CacheSPI cache)
  +   protected VersionedNode(Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, CacheSPI<K, V> cache)
      {
         super(fqn.getLastElement(), fqn, data, false, cache);
         if (parent == null && !fqn.isRoot()) throw new NullPointerException("parent");
  @@ -55,7 +55,7 @@
       * Returns the parent.
       */
      @Override
  -   public NodeSPI getParent()
  +   public NodeSPI<K, V> getParent()
      {
         return parent;
      }
  
  
  
  1.33      +7 -7      JBossCache/src/org/jboss/cache/RegionManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RegionManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionManager.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -b -r1.32 -r1.33
  --- RegionManager.java	8 Mar 2007 12:53:54 -0000	1.32
  +++ RegionManager.java	12 Mar 2007 18:13:46 -0000	1.33
  @@ -108,7 +108,7 @@
            }
            else
            {
  -            fqn = fqn.getFqnChild(2, fqn.size());
  +            fqn = fqn.getSubFqn(2, fqn.size());
            }
         }
         Region region = getRegion(fqn, false);
  
  
  
  1.18      +30 -24    JBossCache/src/org/jboss/cache/NodeSPI.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeSPI.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeSPI.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- NodeSPI.java	7 Mar 2007 18:01:09 -0000	1.17
  +++ NodeSPI.java	12 Mar 2007 18:13:46 -0000	1.18
  @@ -6,7 +6,7 @@
    */
   package org.jboss.cache;
   
  -import net.jcip.annotations.ThreadSafe;
  +import net.jcip.annotations.NotThreadSafe;
   import org.jboss.cache.lock.NodeLock;
   import org.jboss.cache.optimistic.DataVersion;
   import org.jboss.cache.transaction.GlobalTransaction;
  @@ -46,8 +46,8 @@
    * @see org.jboss.cache.CacheSPI
    * @since 2.0.0
    */
  - at ThreadSafe
  -public interface NodeSPI extends Node
  + at NotThreadSafe
  +public interface NodeSPI<K, V> extends Node<K, V>
   {
      /**
       * Returns true if the children of this node were loaded from a cache loader.
  @@ -83,7 +83,7 @@
       *
       * @return Map, keyed by child name, values Nodes.
       */
  -   Map<Object, Node> getChildrenMapDirect();
  +   Map<Object, Node<K, V>> getChildrenMapDirect();
   
      /**
       * Sets the node's children explictly.
  @@ -91,14 +91,16 @@
       *
       * @param children cannot be null
       */
  -   void setChildrenMapDirect(Map<Object, Node> children);
  +   void setChildrenMapDirect(Map<Object, Node<K, V>> children);
   
      /**
       * Returns an existing child or creates a new one using a global transaction.
       *
  +    * @param name name of child to create
  +    * @param tx   transaction under which to create child
       * @return newly created node
       */
  -   NodeSPI getOrCreateChild(Object name, GlobalTransaction tx);
  +   NodeSPI<K, V> getOrCreateChild(Object name, GlobalTransaction tx);
   
      /**
       * Returns a lock for this node.
  @@ -109,6 +111,8 @@
   
      /**
       * Sets the FQN of this node and resets the names of all children as well.
  +    *
  +    * @param f fqn to set
       */
      void setFqn(Fqn f);
   
  @@ -140,7 +144,7 @@
       * @param nodeName  child node name (not an FQN)
       * @param nodeToAdd child node
       */
  -   void addChild(Object nodeName, Node nodeToAdd);
  +   void addChild(Object nodeName, Node<K, V> nodeToAdd);
   
      /**
       * Prints details of this node to the StringBuffer passed in.
  @@ -189,7 +193,7 @@
       * @return set of child nodes.
       * @see #getChildren()
       */
  -   Set<NodeSPI> getChildrenDirect();
  +   Set<NodeSPI<K, V>> getChildrenDirect();
   
      /**
       * Directly removes all children for this node.
  @@ -207,7 +211,7 @@
       * @throws org.jboss.cache.lock.LockingException
       *          if locking was not obtained
       */
  -   Set<NodeSPI> getChildrenDirect(boolean includeMarkedAsDeleted);
  +   Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedAsDeleted);
   
      /**
       * Retrives a child directly by name.
  @@ -216,13 +220,13 @@
       * <p/>
       * The caller needs to ensure a proper lock has been obtained prior to calling this method.
       *
  -    * @param childName
  +    * @param childName name of child
       * @return child node
       * @throws org.jboss.cache.lock.LockingException
       *          if locking was not obtained
       * @see #getChild(Object)
       */
  -   NodeSPI getChildDirect(Object childName);
  +   NodeSPI<K, V> getChildDirect(Object childName);
   
      /**
       * Adds a child directly to a Node.
  @@ -231,13 +235,13 @@
       * <p/>
       * The caller needs to ensure a proper lock has been obtained prior to calling this method.
       *
  -    * @param childName
  +    * @param childName name of child
       * @return child node
       * @throws org.jboss.cache.lock.LockingException
       *          if locking was not obtained
       * @see #addChild(Fqn)
       */
  -   NodeSPI addChildDirect(Fqn childName);
  +   NodeSPI<K, V> addChildDirect(Fqn childName);
   
      /**
       * Directly adds the node passed in to the children map of the current node.  Will throw a CacheException if
  @@ -245,7 +249,7 @@
       *
       * @param child child to add
       */
  -   void addChildDirect(NodeSPI child);
  +   void addChildDirect(NodeSPI<K, V> child);
   
      /**
       * Retrives a child directly by fully qualified name.
  @@ -254,13 +258,13 @@
       * <p/>
       * The caller needs to ensure a proper lock has been obtained prior to calling this method.
       *
  -    * @param childName
  +    * @param childName name of child
       * @return child node
       * @throws org.jboss.cache.lock.LockingException
       *          if locking was not obtained
       * @see #getChild(Fqn)
       */
  -   NodeSPI getChildDirect(Fqn childName);
  +   NodeSPI<K, V> getChildDirect(Fqn childName);
   
      /**
       * Removes a child directly from a node.
  @@ -306,7 +310,7 @@
       *          if locking was not obtained
       * @see #remove(Object)
       */
  -   Object removeDirect(Object key);
  +   V removeDirect(K key);
   
      /**
       * Functionally the same as {@link #put(Object,Object)} except that it operates directly on the node and bypasses the
  @@ -321,7 +325,7 @@
       * @return the previous value under the key passed in, or <tt>null</tt>
       * @see #put(Object,Object)
       */
  -   Object putDirect(Object key, Object value);
  +   V putDirect(K key, V value);
   
      /**
       * Functionally the same as {@link #putAll(Map)} except that it operates directly on the node and bypasses the
  @@ -334,7 +338,7 @@
       * @param data to put
       * @see #putAll(Map)
       */
  -   void putAllDirect(Map<Object, Object> data);
  +   void putAllDirect(Map<K, V> data);
   
      /**
       * Functionally the same as {@link #getData()}  except that it operates directly on the node and bypasses the
  @@ -348,9 +352,10 @@
       * {@link org.jboss.cache.lock.LockingException} will be thrown.
       * <p/>
       *
  +    * @return map contaiing data
       * @see #getData()
       */
  -   Map<Object, Object> getDataDirect();
  +   Map<K, V> getDataDirect();
   
      /**
       * Functionally the same as {@link #get(Object)}   except that it operates directly on the node and bypasses the
  @@ -361,9 +366,10 @@
       * <p/>
       *
       * @param key data to get
  +    * @return value under key
       * @see #get(Object)
       */
  -   Object getDirect(Object key);
  +   V getDirect(K key);
   
   
      /**
  @@ -390,7 +396,7 @@
       * @return set of keys
       * @see #getKeys()
       */
  -   Set<Object> getKeysDirect();
  +   Set<K> getKeysDirect();
   
      /**
       * Functionally the same as {@link #getChildrenNames()}  except that it operates directly on the node and bypasses the
  @@ -410,7 +416,7 @@
       *
       * @return a cache
       */
  -   CacheSPI getCache();
  +   CacheSPI<K, V> getCache();
   
      // ----------- these methods override their corresponding methods in Node, so that the return types are NodeSPI rather than Node.
   
  @@ -421,5 +427,5 @@
       * @return parent node
       * @see Node#getParent()
       */
  -   NodeSPI getParent();
  +   NodeSPI<K, V> getParent();
   }
  
  
  
  1.29      +2 -2      JBossCache/src/org/jboss/cache/AbstractNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/AbstractNode.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -b -r1.28 -r1.29
  --- AbstractNode.java	4 Jan 2007 17:03:54 -0000	1.28
  +++ AbstractNode.java	12 Mar 2007 18:13:46 -0000	1.29
  @@ -10,10 +10,10 @@
    *
    * @author manik
    */
  -public abstract class AbstractNode implements Node
  +public abstract class AbstractNode<K, V> implements Node<K, V>
   {
      protected boolean deleted;
  -   protected Map<Object, Node> children;
  +   protected Map<Object, Node<K, V>> children;
      protected Fqn fqn;
   
      public boolean isDeleted()
  
  
  



More information about the jboss-cvs-commits mailing list