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

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/optimistic    
                        TransactionWorkspaceImpl.java
                        TransactionWorkspace.java WorkspaceNodeImpl.java
                        WorkspaceNode.java
  Log:
  JBCACHE-1005
  
  Revision  Changes    Path
  1.16      +10 -10    JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspaceImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TransactionWorkspaceImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspaceImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- TransactionWorkspaceImpl.java	12 Dec 2006 14:51:44 -0000	1.15
  +++ TransactionWorkspaceImpl.java	12 Mar 2007 18:13:46 -0000	1.16
  @@ -20,21 +20,21 @@
    * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
    * @author Steve Woodcock (<a href="mailto:stevew at jofti.com">stevew at jofti.com</a>)
    */
  -public class TransactionWorkspaceImpl implements TransactionWorkspace
  +public class TransactionWorkspaceImpl<K, V> implements TransactionWorkspace<K, V>
   {
   
  -   private Map<Fqn, WorkspaceNode> nodes;
  +   private Map<Fqn, WorkspaceNode<K, V>> nodes;
      private boolean versioningImplicit = true;
   
      public TransactionWorkspaceImpl()
      {
  -      nodes = new ConcurrentHashMap<Fqn, WorkspaceNode>();
  +      nodes = new ConcurrentHashMap<Fqn, WorkspaceNode<K, V>>();
      }
   
      /**
       * Returns the nodes.
       */
  -   public Map<Fqn, WorkspaceNode> getNodes()
  +   public Map<Fqn, WorkspaceNode<K, V>> getNodes()
      {
         return nodes;
      }
  @@ -42,29 +42,29 @@
      /**
       * Sets the nodes.
       */
  -   public void setNodes(Map<Fqn, WorkspaceNode> nodes)
  +   public void setNodes(Map<Fqn, WorkspaceNode<K, V>> nodes)
      {
         this.nodes = nodes;
      }
   
  -   public WorkspaceNode getNode(Fqn fqn)
  +   public WorkspaceNode<K, V> getNode(Fqn fqn)
      {
         return nodes.get(fqn);
      }
   
  -   public void addNode(WorkspaceNode node)
  +   public void addNode(WorkspaceNode<K, V> node)
      {
         nodes.put(node.getFqn(), node);
      }
   
  -   public Object removeNode(Fqn fqn)
  +   public WorkspaceNode<K, V> removeNode(Fqn fqn)
      {
         return nodes.remove(fqn);
      }
   
  -   public SortedMap<Fqn, WorkspaceNode> getNodesAfter(Fqn fqn)
  +   public SortedMap<Fqn, WorkspaceNode<K, V>> getNodesAfter(Fqn fqn)
      {
  -      SortedMap<Fqn, WorkspaceNode> sm = new TreeMap<Fqn, WorkspaceNode>();
  +      SortedMap<Fqn, WorkspaceNode<K, V>> sm = new TreeMap<Fqn, WorkspaceNode<K, V>>();
         sm.putAll(nodes);
         return sm.tailMap(fqn);
      }
  
  
  
  1.15      +8 -8      JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspace.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TransactionWorkspace.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspace.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- TransactionWorkspace.java	19 Jan 2007 02:04:32 -0000	1.14
  +++ TransactionWorkspace.java	12 Mar 2007 18:13:46 -0000	1.15
  @@ -15,7 +15,7 @@
    * Used to contain a copy of the tree being worked on within the scope of a given transaction.
    * Maintains {@link WorkspaceNode}s rather than conventional
    * {@see DataNode}s.
  - * Also see {@link OptimisticTransactionEntry}, which creates and maintains
  + * Also see {@link org.jboss.cache.transaction.OptimisticTransactionEntry}, which creates and maintains
    * an instance of TransactionWorkspace for each
    * transaction running.
    *
  @@ -23,36 +23,36 @@
    * @author Steve Woodcock (<a href="mailto:stevew at jofti.com">stevew at jofti.com</a>)
    */
   
  -public interface TransactionWorkspace
  +public interface TransactionWorkspace<K, V>
   {
      /**
       * @return Returns a map of {@link WorkspaceNode}s, keyed on {@link Fqn}
       */
  -   public Map<Fqn, WorkspaceNode> getNodes();
  +   public Map<Fqn, WorkspaceNode<K, V>> getNodes();
   
      /**
       * @param nodes The nodes to set. Takes {@link WorkspaceNode}s.
       */
  -   public void setNodes(Map<Fqn, WorkspaceNode> nodes);
  +   public void setNodes(Map<Fqn, WorkspaceNode<K, V>> nodes);
   
  -   public WorkspaceNode getNode(Fqn fqn);
  +   public WorkspaceNode<K, V> getNode(Fqn fqn);
   
      /**
       * Is thread safe so you dont need to deal with synchronising access to this method.
       *
       * @param node
       */
  -   public void addNode(WorkspaceNode node);
  +   public void addNode(WorkspaceNode<K, V> node);
   
      /**
       * Is thread safe so you dont need to deal with synchronising access to this method.
       */
  -   public Object removeNode(Fqn fqn);
  +   public WorkspaceNode<K, V> removeNode(Fqn fqn);
   
      /**
       * Returns all nodes equal to or after the given node.
       */
  -   public SortedMap<Fqn, WorkspaceNode> getNodesAfter(Fqn fqn);
  +   public SortedMap<Fqn, WorkspaceNode<K, V>> getNodesAfter(Fqn fqn);
   
      /**
       * Tests if versioning is implicit for a given tx.
  
  
  
  1.54      +28 -28    JBossCache/src/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WorkspaceNodeImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/WorkspaceNodeImpl.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -b -r1.53 -r1.54
  --- WorkspaceNodeImpl.java	8 Mar 2007 16:12:49 -0000	1.53
  +++ WorkspaceNodeImpl.java	12 Mar 2007 18:13:46 -0000	1.54
  @@ -30,27 +30,27 @@
    * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
    * @author Steve Woodcock (<a href="mailto:stevew at jofti.com">stevew at jofti.com</a>)
    */
  -public class WorkspaceNodeImpl extends AbstractNode implements WorkspaceNode
  +public class WorkspaceNodeImpl<K, V> extends AbstractNode<K, V> implements WorkspaceNode<K, V>
   {
   
      private static Log log = LogFactory.getLog(WorkspaceNodeImpl.class);
   
  -   private NodeSPI node;
  +   private NodeSPI<K, V> node;
      private TransactionWorkspace workspace;
      private DataVersion version = DefaultDataVersion.ZERO;
      private boolean dirty;
      private boolean created;
      private boolean childrenModified;
  -   private Map<Object, NodeSPI> optimisticChildNodeMap;
  +   private Map<Object, NodeSPI<K, V>> optimisticChildNodeMap;
      private Set<Fqn> childrenAdded = new HashSet<Fqn>();
      private Set<Fqn> childrenRemoved = new HashSet<Fqn>();
  -   private Map<Object, Object> optimisticDataMap;
  +   private Map<K, V> optimisticDataMap;
      private boolean versioningImplicit = true; // default
   
      /**
       * Constructs with a node and workspace.
       */
  -   public WorkspaceNodeImpl(NodeSPI node, TransactionWorkspace workspace)
  +   public WorkspaceNodeImpl(NodeSPI<K, V> node, TransactionWorkspace workspace)
      {
         if (!(node instanceof VersionedNode))
         {
  @@ -58,8 +58,8 @@
         }
         this.node = node;
         this.workspace = workspace;
  -      optimisticDataMap = new HashMap<Object, Object>(node.getDataDirect());
  -      Map<Object, Node> childrenMap = node.getChildrenMapDirect();
  +      optimisticDataMap = new HashMap<K, V>(node.getDataDirect());
  +      Map<Object, Node<K, V>> childrenMap = node.getChildrenMapDirect();
         // we NEED this null check otherwise the ConcurrentHashMap constructor could throw an NPE
         // could this not be a HashMap?  After all, each WNI is only used within a single Workspace, which is only
         // attached to a single transaction entry.
  @@ -90,32 +90,32 @@
         return node.getFqn();
      }
   
  -   public void putAll(Map<Object, Object> data)
  +   public void putAll(Map<K, V> data)
      {
         realPut(data, false);
         dirty = true;
      }
   
  -   public Object put(Object key, Object value)
  +   public V put(K key, V value)
      {
         dirty = true;
         return optimisticDataMap.put(key, value);
   
      }
   
  -   public Object remove(Object key)
  +   public V remove(K key)
      {
         dirty = true;
         return optimisticDataMap.remove(key);
   
      }
   
  -   public Object get(Object key)
  +   public V get(K key)
      {
         return optimisticDataMap.get(key);
      }
   
  -   public Set<Object> getKeys()
  +   public Set<K> getKeys()
      {
         return optimisticDataMap.keySet();
      }
  @@ -126,12 +126,12 @@
         return new HashSet<Object>(optimisticChildNodeMap.keySet());
      }
   
  -   private void realPut(Map<Object, Object> data, boolean eraseData)
  +   private void realPut(Map<K, V> data, boolean eraseData)
      {
         realPut(data, eraseData, true);
      }
   
  -   private void realPut(Map<Object, Object> data, boolean eraseData, boolean forceDirtyFlag)
  +   private void realPut(Map<K, V> data, boolean eraseData, boolean forceDirtyFlag)
      {
         if (forceDirtyFlag) dirty = true;
         if (eraseData)
  @@ -141,12 +141,12 @@
         if (data != null) optimisticDataMap.putAll(data);
      }
   
  -   public Node getParent()
  +   public Node<K, V> getParent()
      {
         return node.getParent();
      }
   
  -   public NodeSPI createChild(Object child_name, NodeSPI parent, CacheSPI cache, DataVersion version)
  +   public NodeSPI<K, V> createChild(Object child_name, NodeSPI<K, V> parent, CacheSPI<K, V> cache, DataVersion version)
      {
         if (child_name == null)
         {
  @@ -178,13 +178,13 @@
         versioningImplicit = b;
      }
   
  -   public NodeSPI getChild(Object childName)
  +   public NodeSPI<K, V> getChild(Object childName)
      {
         //see if in the the transaction map
         return optimisticChildNodeMap.get(childName);
      }
   
  -   public NodeSPI getNode()
  +   public NodeSPI<K, V> getNode()
      {
         return node;
      }
  @@ -208,7 +208,7 @@
         return l;
      }
   
  -   public Map<Object, Object> getMergedData()
  +   public Map<K, V> getMergedData()
      {
         return optimisticDataMap;
      }
  @@ -229,7 +229,7 @@
         dirty = true;
      }
   
  -   public Map<Object, Object> getData()
  +   public Map<K, V> getData()
      {
         return Collections.unmodifiableMap(optimisticDataMap);
      }
  @@ -243,7 +243,7 @@
         return getClass().getSimpleName() + " [ fqn=" + getFqn() + " " + sb + "ver=" + version + " " + (versioningImplicit ? "implicit" : "explicit") + "]";
      }
   
  -   public Node addChild(Fqn f)
  +   public Node<K, V> addChild(Fqn f)
      {
         CacheSPI cache = getCache();
         Node newNode = this;
  @@ -299,7 +299,7 @@
         return optimisticDataMap.size();
      }
   
  -   public NodeSPI getChild(Fqn f)
  +   public NodeSPI<K, V> getChild(Fqn f)
      {
         if (f.size() > 1)
         {
  @@ -308,7 +308,7 @@
         return getChild(f.getLastElement());
      }
   
  -   public Set<Node> getChildren()
  +   public Set<Node<K, V>> getChildren()
      {
         throw new UnsupportedOperationException();
      }
  @@ -318,22 +318,22 @@
         throw new UnsupportedOperationException();
      }
   
  -   public NodeSPI getNodeSPI()
  +   public NodeSPI<K, V> getNodeSPI()
      {
         throw new UnsupportedOperationException("WorkspaceNode has no access to a NodeSPI");
      }
   
  -   public Object putIfAbsent(Object k, Object v)
  +   public V putIfAbsent(K k, V v)
      {
         throw new UnsupportedOperationException();
      }
   
  -   public Object replace(Object key, Object value)
  +   public V replace(K key, V value)
      {
         throw new UnsupportedOperationException();
      }
   
  -   public boolean replace(Object key, Object oldValue, Object newValue)
  +   public boolean replace(K key, V oldValue, V newValue)
      {
         throw new UnsupportedOperationException();
      }
  @@ -361,7 +361,7 @@
         }
      }
   
  -   protected CacheSPI getCache()
  +   protected CacheSPI<K, V> getCache()
      {
         return node.getCache();
      }
  
  
  
  1.26      +6 -6      JBossCache/src/org/jboss/cache/optimistic/WorkspaceNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WorkspaceNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/WorkspaceNode.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -b -r1.25 -r1.26
  --- WorkspaceNode.java	8 Mar 2007 16:12:49 -0000	1.25
  +++ WorkspaceNode.java	12 Mar 2007 18:13:46 -0000	1.26
  @@ -25,7 +25,7 @@
    * @author Steve Woodcock (<a href="mailto:stevew at jofti.com">stevew at jofti.com</a>)
    * @since 1.3.0
    */
  -public interface WorkspaceNode extends Node
  +public interface WorkspaceNode<K, V> extends Node<K, V>
   {
      /**
       * Returns 2 Sets - a set of children added (first set) and a set of children removed.
  @@ -62,14 +62,14 @@
       *
       * @return a merged map of key/value pairs.
       */
  -   Map<Object, Object> getMergedData();
  +   Map<K, V> getMergedData();
   
      /**
       * Retrieves a reference to the underlying {@link NodeSPI} instance.
       *
       * @return a node
       */
  -   NodeSPI getNode();
  +   NodeSPI<K, V> getNode();
   
      /**
       * Retrieves a TransactionWorkspace instance associated with the current transaction, which the current WorkspaceNode instance
  @@ -98,7 +98,7 @@
       * @param version    DataVersion to apply to the child.  If null, {@link DefaultDataVersion#ZERO} will be used.
       * @return a NodeSPI pointing to the newly created child.
       */
  -   NodeSPI createChild(Object child_name, NodeSPI parent, CacheSPI cache, DataVersion version);
  +   NodeSPI createChild(Object child_name, NodeSPI<K, V> parent, CacheSPI<K, V> cache, DataVersion version);
   
      /**
       * Tests whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using {@link org.jboss.cache.optimistic.DefaultDataVersion}
  @@ -142,7 +142,7 @@
       * @param o node name
       * @return a child node
       */
  -   NodeSPI getChild(Object o);
  +   NodeSPI<K, V> getChild(Object o);
   
      /**
       * Overrides {@link Node#getChild(Fqn)} to return a {@link org.jboss.cache.NodeSPI} rather than a {@link org.jboss.cache.Node}
  @@ -150,7 +150,7 @@
       * @param f node fqn
       * @return a child node
       */
  -   NodeSPI getChild(Fqn f);
  +   NodeSPI<K, V> getChild(Fqn f);
   
      /**
       * Adds a given WorkspaceNode to the current node's child map
  
  
  



More information about the jboss-cvs-commits mailing list