[Jboss-cvs] JBossAS SVN: r56186 - trunk/cluster/src/main/org/jboss/ha/framework/interfaces

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 23 13:27:27 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-08-23 13:27:26 -0400 (Wed, 23 Aug 2006)
New Revision: 56186

Removed:
   trunk/cluster/src/main/org/jboss/ha/framework/interfaces/ImmutableArrayList.java
Modified:
   trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
   trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
Log:
[JBAS-3427] FamilyClusterInfo methods should return List, not ArrayList

Modified: trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java	2006-08-23 17:22:34 UTC (rev 56185)
+++ trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java	2006-08-23 17:27:26 UTC (rev 56186)
@@ -22,6 +22,7 @@
 package org.jboss.ha.framework.interfaces;
 
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Maintain information for a given proxy family. Proxies can statically reference
@@ -56,7 +57,7 @@
     * <strong>NOTE:</strong> Implementations should synchronize on themselves 
     * when executing this method (see JBAS-2071).
     */
-   public ArrayList getTargets ();
+   public List getTargets ();
    public long getCurrentViewId ();
    
    /**
@@ -68,7 +69,7 @@
     * @param target the target
     * @return the updated list of targets
     */
-   public ArrayList removeDeadTarget(Object target);
+   public List removeDeadTarget(Object target);
    
    /**
     * Updates the targets and the view id.
@@ -76,7 +77,7 @@
     * <strong>NOTE:</strong> Implementations should synchronize on themselves 
     * when executing this method (see JBAS-2071).
     */
-   public ArrayList updateClusterInfo (ArrayList targets, long viewId);
+   public List updateClusterInfo (ArrayList targets, long viewId);
    
    public boolean currentMembershipInSyncWithViewId();
    

Modified: trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java	2006-08-23 17:22:34 UTC (rev 56185)
+++ trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java	2006-08-23 17:27:26 UTC (rev 56186)
@@ -22,12 +22,9 @@
 package org.jboss.ha.framework.interfaces;
 
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ListIterator;
+import java.util.Collections;
+import java.util.List;
 
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
 /**
  * Default implementation of FamilyClusterInfo
  *
@@ -74,11 +71,13 @@
    public String getFamilyName () { return this.familyName; }
    
    /**
-    * Returns an immutable subclass of ArrayList.
+    * Returns an unmodifiable view of the target list.
+    * 
+    * @see Collections#unmodifiableList(List)
     */
-   public synchronized ArrayList getTargets () 
+   public synchronized List getTargets () 
    { 
-      return new ImmutableArrayList(this.targets); 
+      return Collections.unmodifiableList(this.targets); 
    }
    public long getCurrentViewId () { return this.currentViewId; }
    public int getCursor () { return this.cursor; }
@@ -86,7 +85,7 @@
    public Object getObject () { return this.arbitraryObject; }
    public Object setObject (Object whatever) { this.arbitraryObject = whatever; return this.arbitraryObject; }
    
-   public ArrayList removeDeadTarget(Object target)
+   public List removeDeadTarget(Object target)
    {
       synchronized (this)
       {
@@ -94,18 +93,18 @@
          tmp.remove (target);
          this.targets = tmp;
          this.isViewMembersInSyncWithViewId = false;
-         return new ImmutableArrayList(this.targets);
+         return Collections.unmodifiableList(this.targets);
       }      
    }
    
-   public ArrayList updateClusterInfo (ArrayList targets, long viewId)
+   public List updateClusterInfo (ArrayList targets, long viewId)
    {
       synchronized (this)
       {
          this.targets = (ArrayList) targets.clone();
          this.currentViewId = viewId;
          this.isViewMembersInSyncWithViewId = true;
-         return new ImmutableArrayList(this.targets);
+         return Collections.unmodifiableList(this.targets);
       }
    }
       
@@ -166,5 +165,5 @@
    // Private -------------------------------------------------------
    
    // Inner classes -------------------------------------------------
-   
+
 }

Deleted: trunk/cluster/src/main/org/jboss/ha/framework/interfaces/ImmutableArrayList.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/interfaces/ImmutableArrayList.java	2006-08-23 17:22:34 UTC (rev 56185)
+++ trunk/cluster/src/main/org/jboss/ha/framework/interfaces/ImmutableArrayList.java	2006-08-23 17:27:26 UTC (rev 56186)
@@ -1,256 +0,0 @@
-package org.jboss.ha.framework.interfaces;
-
-import java.io.ObjectStreamException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * Subclasses ArrayList but throws an UnsupportedOperationException from
- * any method that would change the internal data members.  Any iterators
- * that are returned do the same.
- * 
- * All other methods are delegated to the ArrayList that is passed to the 
- * constructor, so creating an instance of this class does not result in
- * making a copy of the internal element array of the source array list.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class ImmutableArrayList extends ArrayList
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -7080841600873898901L;
-   
-   private ArrayList delegate;
-
-   ImmutableArrayList(ArrayList source)
-   {
-      this.delegate = source;
-   }
-   
-   // Delegated Methods
-   
-   public Object clone()
-   {
-      return delegate.clone();
-   }
-   
-   public boolean contains(Object elem)
-   {
-      return delegate.contains(elem);
-   }
-   
-   public Object get(int index)
-   {
-      return delegate.get(index);
-   }
-   
-   public int indexOf(Object elem)
-   {
-      return delegate.indexOf(elem);
-   }
-   
-   public boolean isEmpty()
-   {
-      return delegate.isEmpty();
-   }
-   
-   public int lastIndexOf(Object elem)
-   {
-      return delegate.lastIndexOf(elem);
-   }
-   
-   public int size()
-   {
-      return delegate.size();
-   }
-   
-   public Object[] toArray()
-   {
-      return delegate.toArray();
-   }
-   
-   public Object[] toArray(Object[] a)
-   {
-      return delegate.toArray(a);
-   }
-   
-   public boolean equals(Object o)
-   {
-      return delegate.equals(o);
-   }
-   
-   public int hashCode()
-   {
-      return delegate.hashCode();
-   }
-   
-   public List subList(int fromIndex, int toIndex)
-   {
-      return delegate.subList(fromIndex, toIndex);
-   }
-   
-   public boolean containsAll(Collection c)
-   {
-      return delegate.containsAll(c);
-   }
-   
-   public String toString()
-   {
-      return delegate.toString();
-   }
-   
-   // Immutable Methods
-
-   public void add(int arg0, Object arg1)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public boolean add(Object arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public boolean addAll(Collection arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public boolean addAll(int arg0, Collection arg1)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public void clear()
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public void ensureCapacity(int arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public Object remove(int arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public boolean remove(Object arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   protected void removeRange(int arg0, int arg1)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public Object set(int arg0, Object arg1)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public void trimToSize()
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public Iterator iterator()
-   {
-      return new ImmutableArrayListIterator(super.listIterator());
-   }
-   
-   public ListIterator listIterator()
-   {
-      return new ImmutableArrayListIterator(super.listIterator());
-   }
-   
-   public ListIterator listIterator(int index)
-   {
-      return new ImmutableArrayListIterator(super.listIterator(index));
-   }
-   
-   public boolean removeAll(Collection arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   public boolean retainAll(Collection arg0)
-   {
-      throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-   }
-   
-   // Serialization
-   
-   private Object writeReplace() throws ObjectStreamException
-   {
-      return delegate;
-   }   
-   
-   // Inner Classes
-
-   private class ImmutableArrayListIterator implements ListIterator
-   {
-      
-
-      private ListIterator delegate;
-      
-      ImmutableArrayListIterator(ListIterator delegate)
-      {
-         this.delegate = delegate;
-      }
-   
-      public boolean hasNext()
-      {
-         return delegate.hasNext();
-      }
-   
-      public Object next()
-      {
-         return delegate.next();
-      }
-   
-      public void remove()
-      {
-         throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");
-         
-      }
-   
-      public void add(Object o)
-      {
-         throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported"); 
-      }
-   
-      public boolean hasPrevious()
-      {
-         return delegate.hasPrevious();
-      }
-   
-      public int nextIndex()
-      {
-         return delegate.nextIndex();
-      }
-   
-      public Object previous()
-      {
-         return delegate.previous();
-      }
-   
-      public int previousIndex()
-      {
-         return delegate.previousIndex();
-      }
-   
-      public void set(Object o)
-      {
-         throw new UnsupportedOperationException("Target list is immutable; mutator methods are not supported");         
-      }
-      
-   }
-
-}




More information about the jboss-cvs-commits mailing list