[jbosscache-commits] JBoss Cache SVN: r6271 - in core/trunk/src: main/java/org/jboss/cache/config and 3 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jul 15 09:54:35 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-15 09:54:34 -0400 (Tue, 15 Jul 2008)
New Revision: 6271

Modified:
   core/trunk/src/main/java/org/jboss/cache/Fqn.java
   core/trunk/src/main/java/org/jboss/cache/StringFqn.java
   core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
   core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java
   core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
Cleaned up sme TODOs

Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -8,10 +8,7 @@
 
 
 import net.jcip.annotations.Immutable;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
-import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -35,7 +32,7 @@
  * 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:
+ * Alternatively, the same Fqn could be constructed using a List or varargs:
  * <pre>
  * Fqn<String> abc = Fqn.fromElements("people", "Smith", "Joe");
  * </pre>
@@ -43,7 +40,7 @@
  * <p/>
  * Note that<br>
  * <p/>
- * <code>Fqn<String> f = new Fqn<String>("/a/b/c");</code>
+ * <code>Fqn<String> f = Fqn.fromElements("/a/b/c");</code>
  * <p/>
  * is <b>not</b> the same as
  * <p/>
@@ -74,25 +71,17 @@
  * cache.get(f, "key" + i);
  * }
  * </code>
- * <p/>
- * <B>NOTE</B> public constructors of this class are <b>deprectaed</b> and will be removed in JBoss Cache 3.0.0.  The
- * factory methods provided are the correct way get an instance of an Fqn, since these allow for numerous optimisations.
- * <p/>
  *
  * @version $Revision$
  */
 @Immutable
-public class Fqn<E> implements Externalizable, Comparable<Fqn<?>>
+public class Fqn<E> implements Comparable<Fqn<?>>
 {
    /**
     * Separator between FQN elements.
     */
    public static final String SEPARATOR = "/";
 
-   private static final long serialVersionUID = -5351930616956603651L;
-
-   private static final Log log = LogFactory.getLog(Fqn.class);
-
    protected List<E> elements;
    private transient int hash_code = 0;
    protected int size = 0;
@@ -101,7 +90,7 @@
     * Immutable root FQN.
     */
    @SuppressWarnings("unchecked")
-   public static final Fqn ROOT = new Fqn(true);
+   public static final Fqn<Object> ROOT = new Fqn<Object>();
 
    /**
     * A cached string representation of this Fqn, used by toString to it isn't calculated again every time.
@@ -110,21 +99,18 @@
 
    // ----------------- START: Private constructors for use by factory methods only. ----------------------
 
-   // TODO: 3.0.0: Remove the unnecessary internalMarker boolean parameters to these methods once the deprecated public constructors are removed in 3.0.0.
-
-   protected Fqn(boolean internalMarker)
+   protected Fqn()
    {
       elements = Collections.emptyList();
       size = 0;
    }
 
-   @SuppressWarnings("unchecked")
-   protected Fqn(boolean internalMarker, List<?> names, boolean safe)
+   protected Fqn(List<E> names, boolean safe)
    {
       if (names != null)
       {
          // if not safe make a defensive copy
-         elements = safe ? names : new ArrayList(names);
+         elements = safe ? names : new ArrayList<E>(names);
          if (elements.size() > 0)
          {
             if (SEPARATOR.equals(elements.get(0))) elements.remove(0);
@@ -139,10 +125,9 @@
       }
    }
 
-   @SuppressWarnings("unchecked")
-   protected Fqn(boolean internalMarker, Fqn<?> base, List<?> relative)
+   protected Fqn(Fqn<E> base, List<E> relative)
    {
-      List elements = new ArrayList(base.elements.size() + relative.size());
+      List<E> elements = new ArrayList<E>(base.elements.size() + relative.size());
       elements.addAll(base.elements);
       elements.addAll(relative);
       this.elements = elements;
@@ -152,30 +137,6 @@
    // ----------------- END: Private constructors for use by factory methods only. ----------------------
 
    /**
-    * Constructs a root Fqn
-    *
-    * @deprecated use {@link #ROOT} instead.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn()
-   {
-      this(true);
-   }
-
-   /**
-    * Constructs a FQN from a list of names.
-    *
-    * @param names List of names
-    * @deprecated use {@link #fromList(java.util.List)} instead.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn(List<E> names)
-   {
-      // the list is unsafe - may be referenced externally
-      this(true, names, false);
-   }
-
-   /**
     * Retrieves an Fqn that represents the list of elements passed in.
     *
     * @param names list of elements that comprise the Fqn
@@ -184,39 +145,10 @@
     */
    public static <E> Fqn<E> fromList(List<E> names)
    {
-      return new Fqn<E>(true, names, false);
+      return new Fqn<E>(names, false);
    }
 
    /**
-    * If safe is false, Collections.unmodifiableList() is used to wrap the list passed in.  This is an optimisation so
-    * Fqn.fromString(), probably the most frequently used factory method, doesn't end up needing to use the unmodifiableList()
-    * since it creates the list internally.
-    *
-    * @param names List of names
-    * @param safe  whether this list is referenced externally (safe = false) or not (safe = true).
-    * @deprecated use {@link #fromList(java.util.List)} instead.  The boolean "safety" hint is calculated internally.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn(List<E> names, boolean safe)
-   {
-      this(true, names, safe);
-   }
-
-
-   /**
-    * Constructs a Fqn from an array of names.
-    *
-    * @param names Names that comprose this Fqn
-    * @deprecated use {@link #fromElements(Object[])} instead.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn(E... names)
-   {
-      // safe - the list is created here.
-      this(true, Arrays.asList(names), true);
-   }
-
-   /**
     * Retrieves an Fqn that represents the array of elements passed in.
     *
     * @param elements array of elements that comprise the Fqn
@@ -225,23 +157,10 @@
     */
    public static <E> Fqn<E> fromElements(E... elements)
    {
-      return new Fqn<E>(true, Arrays.asList(elements), true);
+      return new Fqn<E>(Arrays.asList(elements), true);
    }
 
    /**
-    * Constructs a Fqn from a base and relative Fqn.
-    *
-    * @param base     parent Fqn
-    * @param relative Sub-Fqn relative to the parent
-    * @deprecated use {@link #fromRelativeFqn(Fqn, Fqn)} instead.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn(Fqn<E> base, Fqn<E> relative)
-   {
-      this(true, base, relative.elements);
-   }
-
-   /**
     * Retrieves an Fqn that represents the absolute Fqn of the relative Fqn passed in.
     *
     * @param base     base Fqn
@@ -249,25 +168,12 @@
     * @return an Fqn
     * @since 2.2.0
     */
-   public static Fqn<Object> fromRelativeFqn(Fqn<?> base, Fqn<?> relative)
+   public static <E> Fqn<E> fromRelativeFqn(Fqn<E> base, Fqn<E> relative)
    {
-      return new Fqn<Object>(true, base, relative.elements);
+      return new Fqn<E>(base, relative.elements);
    }
 
    /**
-    * 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
-    * @deprecated use {@link #fromRelativeList(Fqn, java.util.List)}  instead.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn(Fqn<E> base, List<E> relative)
-   {
-      this(true, base, relative);
-   }
-
-   /**
     * Retrieves an Fqn that represents the List of elements passed in, relative to the base Fqn.
     *
     * @param base             base Fqn
@@ -275,25 +181,12 @@
     * @return an Fqn
     * @since 2.2.0
     */
-   public static Fqn<Object> fromRelativeList(Fqn<?> base, List<?> relativeElements)
+   public static <E> Fqn<E> fromRelativeList(Fqn<E> base, List<E> relativeElements)
    {
-      return new Fqn<Object>(true, base, relativeElements);
+      return new Fqn<E>(base, relativeElements);
    }
 
    /**
-    * 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
-    * @deprecated use {@link #fromRelativeElements(Fqn, Object[])} instead.  This constructor will be removed in 3.0.0.
-    */
-   @Deprecated
-   public Fqn(Fqn<E> base, E... childNames)
-   {
-      this(true, base, Arrays.asList(childNames));
-   }
-
-   /**
     * Retrieves an Fqn that represents the array of elements passed in, relative to the base Fqn.
     *
     * @param base             base Fqn
@@ -301,9 +194,9 @@
     * @return an Fqn
     * @since 2.2.0
     */
-   public static Fqn<Object> fromRelativeElements(Fqn<?> base, Object... relativeElements)
+   public static <E> Fqn<E> fromRelativeElements(Fqn<E> base, E... relativeElements)
    {
-      return new Fqn<Object>(true, base, Arrays.asList(relativeElements));
+      return new Fqn<E>(base, Arrays.asList(relativeElements));
    }
 
    /**
@@ -315,26 +208,20 @@
     * </pre><br>
     * is equivalent to:<br>
     * <pre>
-    * new Fqn("a", "b", "c");
-    * </pre><br>
-    * but not<br>
-    * <pre>
-    * new Fqn("/a/b/c");
+    * Fqn.fromElements("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[])
     */
-   @SuppressWarnings("unchecked")
    public static Fqn<String> fromString(String stringRepresentation)
    {
       if (stringRepresentation == null || stringRepresentation.equals(SEPARATOR))
       {
-         return ROOT;
+         return root();
       }
       List<String> elements = Arrays.asList(stringRepresentation.split("/"));
-      return new Fqn(true, elements, false);
+      return new Fqn<String>(elements, false);
    }
 
    /**
@@ -346,9 +233,9 @@
     * @throws ClassNotFoundException in the event of classes that comprise the element list of this Fqn not being found
     * @since 2.2.0
     */
-   public static Fqn<Object> fromExternalStream(ObjectInput in) throws IOException, ClassNotFoundException
+   public static Fqn<?> fromExternalStream(ObjectInput in) throws IOException, ClassNotFoundException
    {
-      Fqn<Object> f = new Fqn<Object>(true);
+      Fqn<Object> f = new Fqn<Object>();
       f.readExternal(in);
       return f;
    }
@@ -385,11 +272,15 @@
 
    /**
     * Obtains a sub-Fqn from the given Fqn.  Literally performs <code>elements.subList(startIndex, endIndex)</code>
+    *
+    * @param startIndex starting index
+    * @param endIndex   end index
+    * @return a subFqn
     */
    public Fqn<E> getSubFqn(int startIndex, int endIndex)
    {
-      List el = elements.subList(startIndex, endIndex);
-      return new Fqn<E>(true, el, true);
+      List<E> el = elements.subList(startIndex, endIndex);
+      return new Fqn<E>(el, true);
    }
 
    /**
@@ -611,14 +502,14 @@
          case 1:
             return root();
          default:
-            return new Fqn<E>(true, elements.subList(0, size - 1), true);
+            return new Fqn<E>(elements.subList(0, size - 1), true);
       }
    }
 
    @SuppressWarnings("unchecked")
-   public static <T> Fqn<T> root()
+   public static final <T> Fqn<T> root()  // declared final so compilers can optimise and in-line.
    {
-      return ROOT;
+      return (Fqn<T>) ROOT;
    }
 
    /**
@@ -674,14 +565,15 @@
    /**
     * Creates a new Fqn whose ancestor has been replaced with the new ancestor passed in.
     *
-    * @param newAncestor
-    * @return a new Fqn
+    * @param oldAncestor old ancestor to replace
+    * @param newAncestor nw ancestor to replace with
+    * @return a new Fqn with ancestors replaced.
     */
-   public Fqn replaceAncestor(Fqn oldAncestor, Fqn newAncestor)
+   public Fqn<E> replaceAncestor(Fqn<E> oldAncestor, Fqn<E> newAncestor)
    {
       if (!isChildOf(oldAncestor))
          throw new IllegalArgumentException("Old ancestor must be an ancestor of the current Fqn!");
-      Fqn subFqn = this.getSubFqn(oldAncestor.size(), size());
+      Fqn<E> subFqn = this.getSubFqn(oldAncestor.size(), size());
       return Fqn.fromRelativeFqn(newAncestor, subFqn);
    }
 }
\ No newline at end of file

Modified: core/trunk/src/main/java/org/jboss/cache/StringFqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/StringFqn.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/main/java/org/jboss/cache/StringFqn.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -19,26 +19,24 @@
  */
 // TODO: 3.0.0: Implement proper String escaping.
 @Experimental
-public final class StringFqn extends Fqn
+public final class StringFqn extends Fqn<String>
 {
-   // Needs to be public because of NodeData serialization.
-   // TODO: Remove in 3.0.0 once we refactor NodeData to go through a cache marshaller instead of it's current serialization.
-   public StringFqn()
+   protected StringFqn()
    {
-      super(true);
+      super();
       stringRepresentation = SEPARATOR;
    }
 
    protected StringFqn(StringFqn base, List<String> elements)
    {
-      super(true, base, elements);
+      super(base, elements);
       String elementStringRep = getStringRepresentation(elements);
       stringRepresentation = base.isRoot() ? elementStringRep : base.stringRepresentation + elementStringRep;
    }
 
    protected StringFqn(StringFqn base, StringFqn relative)
    {
-      super(true, base, relative.elements);
+      super(base, relative.elements);
       if (base.isRoot())
       {
          if (relative.isRoot())
@@ -57,7 +55,7 @@
 
    protected StringFqn(List<String> stringElements)
    {
-      super(true, stringElements, false);
+      super(stringElements, false);
       stringRepresentation = getStringRepresentation(elements);
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -177,8 +177,7 @@
    }
 
    /**
-    * Use {@link #getWakeupIntervalSeconds()}.
-    * todo mmarkus remove all the references of this method from the code
+    * @deprecated Use {@link #getWakeupIntervalSeconds()}.
     */
    @Deprecated
    public int getWakeupIntervalSeconds()
@@ -187,7 +186,7 @@
    }
 
    /**
-    * Use {@link #setWakeupInterval(long)}.
+    * @deprecated Use {@link #setWakeupInterval(long)}.
     */
    @Deprecated
    public void setWakeupIntervalSeconds(int wakeupIntervalSeconds)

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -47,14 +47,6 @@
 import java.util.ListIterator;
 import java.util.Map;
 
-/*
-* // TODO: 2.2.0: refactorings ideas
-*      - thre are many places in code that handles that coputes the lock owners: either GTX or Thread.local. The
-*      lockOwner can be abstractised  as a LockOwner that can be extended by CurrentThreadLock owner and
-       GlobalTransaction owner. This would make the code nicer.
-*/
-
-
 /**
  * An interceptor that handles locking. When a TX is associated, we register
  * for TX completion and unlock the locks acquired within the scope of the TX.
@@ -277,13 +269,11 @@
 
       Object retVal = invokeNextInterceptor(ctx, command);
       // and make sure we remove all nodes we've created for the sake of later removal.
-      //TODO: 2.2.0: [mmarkus] this logic should be moved within moveNodeCommand, as it is plain removal logic
       if (ctx.getGlobalTransaction() == null)
       {
          for (NodeSPI nodeSPI : createdNodes) dataContainer.removeFromDataStructure(nodeSPI.getFqn(), true);
          dataContainer.removeFromDataStructure(command.getFqn(), true);
 
-         //TODO: 2.2.0: end of the logic that needs to be moved
          NodeSPI n = dataContainer.peek(command.getFqn(), true, false);
          if (n != null) lockManager.unlockAll(n, Thread.currentThread());
       }

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -6,10 +6,9 @@
  */
 package org.jboss.cache.eviction;
 
-import static org.testng.AssertJUnit.fail;
-
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import static org.testng.AssertJUnit.fail;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -22,10 +21,10 @@
 @Test(groups = {"functional"})
 public class NullEvictionConfigTest
 {
-   /** 
+   /**
     * Creates a bunch of region elements with LRU configs and confirms
     * that NullEvictionPolicyConfig doesn't barf.
-    * 
+    *
     * @throws Exception
     */
    public void testXMLParsing() throws Exception
@@ -33,20 +32,14 @@
       String xml =
             "<region name=\"/org/jboss/data\">\n" +
                   "</region>";
-      
+
       testConfigBlock(xml);
-      
+
       xml = "<region name=\"/maxAgeTest/\"/>\n";
-      
+
       testConfigBlock(xml);
    }
 
-   /**
-    * FIXME Comment this
-    * 
-    * @param xml
-    * @throws Exception
-    */
    private void testConfigBlock(String xml) throws Exception
    {
       Element element = XmlConfigHelper.stringToElement(xml);

Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -85,25 +85,21 @@
 
    public void testStateTransfer() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 
    public void testStartup() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 
    public void testCacheLoading() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 
    public void testPassivation() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java	2008-07-15 13:34:09 UTC (rev 6270)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java	2008-07-15 13:54:34 UTC (rev 6271)
@@ -3,10 +3,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.util.TestingUtil;
 import org.testng.annotations.Test;
 
 import java.util.ArrayList;
@@ -334,25 +334,21 @@
 
    public void testStateTransfer() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 
    public void testStartup() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 
    public void testCacheLoading() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 
    public void testPassivation() throws Exception
    {
-      // TODO implement me
       throw new Exception("Implement me");
    }
 }




More information about the jbosscache-commits mailing list