You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2015/09/10 08:59:30 UTC

svn commit: r1702174 [1/5] - in /river/jtsk/skunk/qa-refactor-namespace/trunk: ./ qa/src/org/apache/river/test/impl/outrigger/javaspace05/ src/manifest/ src/net/jini/core/entry/ src/net/jini/core/lookup/ src/net/jini/entry/ src/net/jini/loader/ src/net...

Author: peter_firmstone
Date: Thu Sep 10 06:59:28 2015
New Revision: 1702174

URL: http://svn.apache.org/r1702174
Log:
Donate custard apple code to River as requested.

Make Entry's Clonable to implement expected user behaviour in SDM and LookupCache - very simple quick fix, thanks to AbstractEntry, feel free to review.

Added:
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/entry/CloneableEntry.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferenceComparator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferrerDecorator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/CollectionDecorator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ComparableReferrerDecorator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryFacadeConverter.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryIteratorFacade.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntrySetFacade.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/NullIterator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RC.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReadResolveFixCollectionCircularReferences.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReadResolveFixForMapCircularReferences.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/Ref.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RefQueue.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RefReferenceQueue.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceBlockingDeque.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceBlockingQueue.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceCollection.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceCollectionRefreshAfterSerialization.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceCollectionSerialData.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceComparator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceConcurrentMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceConcurrentNavigableMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceDeque.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceEntryFacade.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceFactory.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceIterator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceList.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceMapSerialData.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceNavigableMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceNavigableSet.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceProcessor.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceQueuingFactory.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceSerializationFactory.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceSerializedForm.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceSet.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceSortedMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferenceSortedSet.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferencedQueue.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/Referrer.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ReferrerDecorator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/SerializationOfReferenceCollection.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/SerializationOfReferenceMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/SoftEqualityReference.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/SoftIdentityReference.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/StrongReference.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TempComparableReferrer.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TempEqualReferrer.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TempIdentityReferrer.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TimeBomb.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TimedComparableReferrerDecorator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TimedRefQueue.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TimedReferrer.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/TimedReferrerDecorator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/UntouchableReferrer.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/WeakEqualityReference.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/WeakIdentityReference.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/package.html
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/MutableMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceBlockingQueueTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceCollectionTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceConcurrentMapConcurrencyTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceConcurrentNavigableMapTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceDequeTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceListTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceMapTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableMapTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableSetTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSetTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedMapTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedSetTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferencedQueueTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferrerTimeTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/StringComparator.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/TimedReferrerTest.java
Removed:
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/lib/custard-apple-1.0.2.jar
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/api/io/PortableFactoryTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/api/io/PortableObjectOutputStreamTest.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/tests/support/PortableObject.java
Modified:
    river/jtsk/skunk/qa-refactor-namespace/trunk/build.xml
    river/jtsk/skunk/qa-refactor-namespace/trunk/common.xml
    river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/A0.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/B0.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/C0.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/manifest/jsk-platform.mf
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceItem.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceTemplate.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/entry/AbstractEntry.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/LoadClass.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/pref/PreferredClassProvider.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/CombinerSecurityManager.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/DelegatePermission.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/impl/lease/AbstractLeaseMap.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/outrigger/OutriggerServerImpl.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/reggie/RegistrarEvent.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/start/AggregatePolicyProvider.java
    river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/start/LoaderSplitPolicyProvider.java

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/build.xml
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/build.xml?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/build.xml (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/build.xml Thu Sep 10 06:59:28 2015
@@ -558,7 +558,6 @@
         <copy todir="lib">
             <fileset refid="asm.jars"/>
             <fileset refid="high-scale-lib.jars"/>
-            <fileset refid="reference-collections.jar"/>
         </copy>
         <copy todir="lib-ext">
             <fileset refid="dnsjava.jar"/>
@@ -2246,14 +2245,12 @@
         <mkdir dir="${test.classes.dir}"/>
         <mkdir dir="${test.results.dir}"/>
         <copy file="dep-libs/high-scale-lib/high-scale-lib.jar" todir="test/lib"/>
-        <copy file="dep-libs/rc-libs/custard-apple-1.0.3.jar" todir="test/lib"/>
     </target>
 
     <target name="clean-tests" depends="">
         <delete dir="${test.classes.dir}" quiet="true"/>
         <delete dir="${test.results.dir}" quiet="true"/>
         <delete file="test/lib/high-scale-lib.jar" quiet="true"/>
-        <delete file="test/lib/custard-apple-1.0.3.jar" quiet="true"/>
     </target> 
     
     <target name="compile-tests" depends="compile,prep-tests">

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/common.xml
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/common.xml?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/common.xml (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/common.xml Thu Sep 10 06:59:28 2015
@@ -158,10 +158,6 @@
         <include name="high-scale-lib.jar" />
     </fileset>
     
-    <fileset id="reference-collections.jar" dir="${root}/dep-libs/rc-libs">
-        <include name="custard-apple-1.0.3.jar" />
-    </fileset>
-    
     <fileset id="dnsjava.jar" dir="${root}/dep-libs/dnsjava">
         <include name="dnsjava-2.1.3.jar" />
     </fileset>
@@ -171,7 +167,6 @@
         <fileset refid="asm.jars" />
         <fileset refid="velocity.jars" />
         <fileset refid="high-scale-lib.jars" />
-        <fileset refid="reference-collections.jar" />
     </path>
 
 

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/A0.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/A0.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/A0.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/A0.java Thu Sep 10 06:59:28 2015
@@ -54,11 +54,7 @@ public class A0 extends AbstractEntry im
     }
 
     public TestEntry dup() {
-	try {
-	    return (TestEntry)super.clone();
-	} catch (CloneNotSupportedException e) {
-	    throw new AssertionError(e);
-	}
+	return (TestEntry)super.clone();
     }
 }
 

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/B0.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/B0.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/B0.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/B0.java Thu Sep 10 06:59:28 2015
@@ -54,11 +54,7 @@ public class B0 extends AbstractEntry im
     }
 
     public TestEntry dup() {
-	try {
-	    return (TestEntry)super.clone();
-	} catch (CloneNotSupportedException e) {
-	    throw new AssertionError(e);
-	}
+	return (TestEntry)super.clone();
     }
 }
 

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/C0.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/C0.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/C0.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/impl/outrigger/javaspace05/C0.java Thu Sep 10 06:59:28 2015
@@ -54,11 +54,7 @@ public class C0 extends AbstractEntry im
     }
 
     public TestEntry dup() {
-	try {
-	    return (TestEntry)super.clone();
-	} catch (CloneNotSupportedException e) {
-	    throw new AssertionError(e);
-	}
+	return (TestEntry)super.clone();
     }
 }
 

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/manifest/jsk-platform.mf
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/manifest/jsk-platform.mf?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/manifest/jsk-platform.mf (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/manifest/jsk-platform.mf Thu Sep 10 06:59:28 2015
@@ -1,4 +1,4 @@
 Manifest-Version: 1.0
-Class-Path: jsk-resources.jar high-scale-lib.jar custard-apple-1.0.3.jar
+Class-Path: jsk-resources.jar high-scale-lib.jar
 Implementation-Vendor: Apache Software Foundation
-Implementation-Version: 2.2.0
+Implementation-Version: 3.0

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/entry/CloneableEntry.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/entry/CloneableEntry.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/entry/CloneableEntry.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/entry/CloneableEntry.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.jini.core.entry;
+
+/**
+ * Required because Cloneable is only a marker interface.
+ * @author peter
+ */
+public interface CloneableEntry extends Entry, Cloneable {
+
+    public Entry clone();
+    
+}

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceItem.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceItem.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceItem.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceItem.java Thu Sep 10 06:59:28 2015
@@ -20,6 +20,7 @@ package net.jini.core.lookup;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamField;
+import net.jini.core.entry.CloneableEntry;
 import net.jini.core.entry.Entry;
 
 /**
@@ -97,6 +98,8 @@ public class ServiceItem implements java
      * {@link net.jini.lookup.ServiceDiscoveryManager} to avoid sharing 
      * internally stored instances with client code.
      * 
+     * A deep copy clone is made
+     * 
      * @return a clone of the original ServiceItem
      */
     @Override
@@ -104,7 +107,16 @@ public class ServiceItem implements java
     {
         try {
             ServiceItem clone = (ServiceItem) super.clone();
-            clone.attributeSets = clone.attributeSets.clone();
+	    if (clone.attributeSets != null){
+		clone.attributeSets = clone.attributeSets.clone();
+		for (int i = 0, l = clone.attributeSets.length; i < l; i++){
+		    Entry e = clone.attributeSets[i];
+		    if (e instanceof CloneableEntry){
+			clone.attributeSets[i] = ((CloneableEntry) e).clone();
+		    }
+
+		}
+	    }
             return clone;
         } catch (CloneNotSupportedException ex) {
             throw new AssertionError();

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceTemplate.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceTemplate.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceTemplate.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/core/lookup/ServiceTemplate.java Thu Sep 10 06:59:28 2015
@@ -17,6 +17,7 @@
  */
 package net.jini.core.lookup;
 
+import net.jini.core.entry.CloneableEntry;
 import net.jini.core.entry.Entry;
 
 /**
@@ -39,7 +40,7 @@ import net.jini.core.entry.Entry;
  *
  * @since 1.0
  */
-public class ServiceTemplate implements java.io.Serializable {
+public class ServiceTemplate implements java.io.Serializable, Cloneable {
 
     private static final long serialVersionUID = 7854483807886483216L;
 
@@ -78,6 +79,36 @@ public class ServiceTemplate implements
     }
     
     /**
+     * Clone has been implemented to allow utilities such as
+     * {@link net.jini.lookup.ServiceDiscoveryManager} to avoid sharing 
+     * internally stored instances with client code.
+     * 
+     * @return a clone of the original ServiceTemplate
+     */
+    @Override
+    public ServiceTemplate clone() 
+    {
+        try {
+            ServiceTemplate clone = (ServiceTemplate) super.clone();
+	    if (clone.serviceTypes != null){
+		clone.serviceTypes = clone.serviceTypes.clone();
+	    }
+	    if (clone.attributeSetTemplates != null){
+		clone.attributeSetTemplates = clone.attributeSetTemplates.clone();
+		for (int i = 0, l = clone.attributeSetTemplates.length; i < l; i++){
+		    Entry e = clone.attributeSetTemplates[i];
+		    if (e instanceof CloneableEntry){
+			clone.attributeSetTemplates[i] = ((CloneableEntry) e).clone();
+		    }
+		}
+	    }
+            return clone;
+        } catch (CloneNotSupportedException ex) {
+            throw new AssertionError();
+        }
+    }
+    
+    /**
      * Returns a <code>String</code> representation of this 
      * <code>ServiceTemplate</code>.
      * @return <code>String</code> representation of this 

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/entry/AbstractEntry.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/entry/AbstractEntry.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/entry/AbstractEntry.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/entry/AbstractEntry.java Thu Sep 10 06:59:28 2015
@@ -17,11 +17,12 @@
  */
 package net.jini.entry;
 
-import net.jini.core.entry.Entry;
 import java.lang.reflect.*;
 
-import java.util.WeakHashMap;
 import java.util.ArrayList;
+import java.util.WeakHashMap;
+import net.jini.core.entry.CloneableEntry;
+import net.jini.core.entry.Entry;
 
 /**
  * An abstract implementation of {@link Entry} that provides useful
@@ -37,14 +38,31 @@ import java.util.ArrayList;
  * @author Sun Microsystems, Inc.
  * @see Entry 
  */
-public abstract class AbstractEntry implements Entry {
+public abstract class AbstractEntry implements CloneableEntry {
     static final long serialVersionUID = 5071868345060424804L;
 
     /**
      * Creates an instance of this class.
      */
     protected AbstractEntry() { }
-
+    
+    /**
+     * Clone has been implemented to allow utilities such as
+     * {@link net.jini.lookup.ServiceDiscoveryManager} to avoid sharing 
+     * internally stored instances with client code.
+     * 
+     * @return a clone of the original Entry
+     */
+    public Entry clone() 
+    {
+        try {
+            Entry clone = (Entry) super.clone();
+            return clone;
+        } catch (CloneNotSupportedException ex) {
+            throw new AssertionError();
+        }
+    }
+    
     /**
      * Compares this <code>AbstractEntry</code> to the specified
      * object. If <code>other</code> is <code>null</code> or not an

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/LoadClass.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/LoadClass.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/LoadClass.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/LoadClass.java Thu Sep 10 06:59:28 2015
@@ -18,9 +18,9 @@
 
 package net.jini.loader;
 
-import au.net.zeus.collection.RC;
-import au.net.zeus.collection.Ref;
-import au.net.zeus.collection.Referrer;
+import org.apache.river.concurrent.RC;
+import org.apache.river.concurrent.Ref;
+import org.apache.river.concurrent.Referrer;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/pref/PreferredClassProvider.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/pref/PreferredClassProvider.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/pref/PreferredClassProvider.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/loader/pref/PreferredClassProvider.java Thu Sep 10 06:59:28 2015
@@ -18,9 +18,9 @@
 
 package net.jini.loader.pref;
 
-import au.net.zeus.collection.RC;
-import au.net.zeus.collection.Ref;
-import au.net.zeus.collection.Referrer;
+import org.apache.river.concurrent.RC;
+import org.apache.river.concurrent.Ref;
+import org.apache.river.concurrent.Referrer;
 import org.apache.river.action.GetPropertyAction;
 import org.apache.river.logging.Levels;
 import org.apache.river.logging.LogUtil;

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java Thu Sep 10 06:59:28 2015
@@ -17,9 +17,9 @@
  */
 package net.jini.lookup;
 
-import au.net.zeus.collection.RC;
-import au.net.zeus.collection.Ref;
-import au.net.zeus.collection.Referrer;
+import org.apache.river.concurrent.RC;
+import org.apache.river.concurrent.Ref;
+import org.apache.river.concurrent.Referrer;
 import org.apache.river.logging.Levels;
 import org.apache.river.lookup.entry.LookupAttributes;
 import org.apache.river.proxy.BasicProxyTrustVerifier;
@@ -1465,7 +1465,7 @@ public class ServiceDiscoveryManager {
             this.serviceIdMap = new ConcurrentHashMap<ServiceID, ServiceItemReg>();
             this.sItemListeners = new HashSet<ServiceDiscoveryListener>();
             this.serviceDiscardFutures = RC.concurrentMap(new ConcurrentHashMap<Referrer<ServiceID>, Referrer<Future>>(), Ref.WEAK_IDENTITY, Ref.STRONG, 60000, 60000);
-            this.tmpl = copyServiceTemplate(tmpl);
+            this.tmpl = tmpl.clone();
             this.leaseDuration = leaseDuration;
             this.filter = filter;
             lookupListener = new LookupListener();
@@ -3879,28 +3879,6 @@ public class ServiceDiscoveryManager {
     }//end checkTerminated
 
     /**
-     * Returns a "non-shallow" (not just a clone) copy of the given template.
-     */
-    static private ServiceTemplate copyServiceTemplate(ServiceTemplate tmpl) {
-        Class[] serviceTypes = null;
-        Entry[] attributeSetTemplates = null;
-        if (tmpl.serviceTypes != null) {
-            int len = tmpl.serviceTypes.length;
-            serviceTypes = new Class[len];
-            System.arraycopy(tmpl.serviceTypes, 0, serviceTypes, 0, len);
-        }
-        if (tmpl.attributeSetTemplates != null) {
-            int len = tmpl.attributeSetTemplates.length;
-            attributeSetTemplates = new Entry[len];
-            System.arraycopy(tmpl.attributeSetTemplates, 0,
-                    attributeSetTemplates, 0, len);
-        }
-        return new ServiceTemplate(tmpl.serviceID,
-                serviceTypes,
-                attributeSetTemplates);
-    }//end copyServiceTemplate
-
-    /**
      * Determines if the given ServiceItem is an element of the given array.
      */
     static private boolean isArrayContainsServiceItem(List<ServiceItem> a,

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/CombinerSecurityManager.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/CombinerSecurityManager.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/CombinerSecurityManager.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/CombinerSecurityManager.java Thu Sep 10 06:59:28 2015
@@ -47,9 +47,9 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import net.jini.security.Security;
 import net.jini.security.SecurityContext;
-import au.net.zeus.collection.RC;
-import au.net.zeus.collection.Ref;
-import au.net.zeus.collection.Referrer;
+import org.apache.river.concurrent.RC;
+import org.apache.river.concurrent.Ref;
+import org.apache.river.concurrent.Referrer;
 import org.apache.river.impl.thread.NamedThreadFactory;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 

Modified: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/DelegatePermission.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/DelegatePermission.java?rev=1702174&r1=1702173&r2=1702174&view=diff
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/DelegatePermission.java (original)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/api/security/DelegatePermission.java Thu Sep 10 06:59:28 2015
@@ -33,9 +33,9 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentSkipListMap;
-import au.net.zeus.collection.RC;
-import au.net.zeus.collection.Ref;
-import au.net.zeus.collection.Referrer;
+import org.apache.river.concurrent.RC;
+import org.apache.river.concurrent.Ref;
+import org.apache.river.concurrent.Referrer;
 import java.io.StreamTokenizer;
 import java.io.StringReader;
 import java.util.ArrayList;

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferenceComparator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferenceComparator.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferenceComparator.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferenceComparator.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,97 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.Comparator;
+
+/**
+ * Implements equals and hashCode, subclass ReferenceComparator implements 
+ * Serializable and contains serial data.
+ * 
+ * @author Peter Firmstone.
+ */
+abstract class AbstractReferenceComparator<T> implements Comparator<Referrer<T>> {
+
+    AbstractReferenceComparator() {
+    }
+
+    /**
+     * This is implemented such that if either Referrer contains a null
+     * referent, the comparison is only made using Referrer's, this may
+     * have a different natural order, than the comparator provided, however
+     * equals will always return 0, this is important to correctly remove
+     * a Referrer once its referent has been collected.
+     * 
+     * The following tests give this a good workout:
+     * 
+     * com/sun/jini/test/impl/joinmanager/ZRegisterStorm.td
+     * com/sun/jini/test/spec/renewalmanager/EventTest.td
+     * 
+     * @param o1
+     * @param o2
+     * @return 
+     */
+    public int compare(Referrer<T> o1, Referrer<T> o2) {
+        if (o1 == o2) return 0;
+        T t1 = null;
+        if (o1 instanceof UntouchableReferrer){
+            t1 = ((UntouchableReferrer<T>)o1).lookDontTouch();
+        } else {
+            t1 = o1.get();
+        }
+        T t2 = null;
+        if (o2 instanceof UntouchableReferrer){
+            t2 = ((UntouchableReferrer<T>)o2).lookDontTouch();
+        } else {
+            t2 = o2.get();
+        }
+        if ( t1 != null && t2 != null){
+            int c = get().compare(t1, t2);
+            if ( c == 0 ){// If untouchable this is a hit.
+                o1.get();
+                o2.get();
+            }
+            return c;
+        }
+        int hash1 = o1.hashCode();
+        int hash2 = o2.hashCode();
+        if (hash1 < hash2) return -1;
+        if (hash1 > hash2) return 1;
+        if (o1.equals(o2)) return 0;
+        return -1;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        }
+        if (o instanceof AbstractReferenceComparator) {
+            return get().equals(((AbstractReferenceComparator) o).get());
+        }
+        return false;
+    }
+
+    abstract Comparator<? super T> get();
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 61 * hash + (this.get() != null ? this.get().hashCode() : 0);
+        return hash;
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferrerDecorator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferrerDecorator.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferrerDecorator.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/AbstractReferrerDecorator.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,104 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.Serializable;
+
+/**
+ * This class exists purely for allowing a client with their own Collection
+ * implementation or Collection wrapper to perform custom serialisation of the 
+ * References by replacing the standard Referrer's with their own implementation.
+ * 
+ * During de-serialisation the client's Referrer can 
+ * perform any required de-serialisation defensive copying or integrity checks.
+ * 
+ * The client Referrer will be replaced after de-serialisation is complete.
+ * 
+ * The client doesn't need to implement this class, just Referrer.
+ * 
+ * @param <T> - the referent.
+ * @author peter
+ */
+abstract class AbstractReferrerDecorator<T> implements UntouchableReferrer<T> {
+
+     AbstractReferrerDecorator() {
+    }
+
+    final void refresh(ReferenceQueuingFactory<T, Referrer<T>> rqf){
+        T object = get();
+        if (object != null){
+            refresh(rqf.referenced(object, true, false));
+        }
+    }
+    
+    /**
+     * This method is called after de-serialisation, to update the Referrer,
+     * the Ref type will be governed by the ReferenceCollection, the queue will 
+     * have also been defined.  
+     * 
+     * The object will be retrieved and encapsulated in the Referrer
+     * using the get() method.
+     * 
+     * @param r 
+     */
+    abstract void refresh(Referrer<T> r);
+
+    public String toString() {
+        return get().toString();
+    }
+
+    public void clear() {
+        getReference().clear();
+    }
+
+    public boolean enqueue() {
+        return getReference().enqueue();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o)  return true; // Same reference.
+        if (!(o instanceof Referrer))  return false;
+        return getReference().equals(o);
+    }
+
+    public final T get() {
+        return getReference().get();
+    }
+    
+    public T lookDontTouch(){
+        Referrer<T> r = getReference();
+        if (r instanceof UntouchableReferrer){
+            return ((UntouchableReferrer<T>)r).lookDontTouch();
+        }
+        return r.get(); // Oh well, at least we tried.
+    }
+
+    /**
+     * @return the Referrer.
+     */
+    abstract Referrer<T> getReference();
+
+    @Override
+    public int hashCode() {
+        return getReference().hashCode();
+    }
+
+    public boolean isEnqueued() {
+        return getReference().isEnqueued();
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/CollectionDecorator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/CollectionDecorator.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/CollectionDecorator.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/CollectionDecorator.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,78 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ *
+ * @author peter
+ */
+class CollectionDecorator<T> extends AbstractCollection<Referrer<T>> implements Collection<Referrer<T>> {
+    private final Collection<T> col;
+    private final ReferenceQueuingFactory<T, Referrer<T>> rqf;
+    private final boolean enque;
+    private final boolean temporary;
+    
+    CollectionDecorator(Collection<T> col, ReferenceQueuingFactory<T, Referrer<T>> rqf, boolean enque, boolean temporary){
+        this.col = col;
+        this.rqf = rqf;
+        this.enque = enque;
+        this.temporary = temporary;
+    }
+
+    @Override
+    public Iterator<Referrer<T>> iterator() {
+        return new Iter<T>(col.iterator(), rqf);
+    }
+
+    @Override
+    public int size() {
+        return col.size();
+    }
+    
+    public boolean add(Referrer<T> t) {
+	return col.add( t != null ? t.get() : null );
+    }
+    
+    private class Iter<T> implements Iterator<Referrer<T>> {
+        Iterator<T> iterator;
+        private final ReferenceQueuingFactory<T, Referrer<T>> rqf;
+        Iter(Iterator<T> it, ReferenceQueuingFactory<T, Referrer<T>> rqf){
+            iterator = it;
+            this.rqf = rqf;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return iterator.hasNext();
+        }
+
+        @Override
+        public Referrer<T> next() {
+            return rqf.referenced( iterator.next(), enque, temporary);
+        }
+
+        @Override
+        public void remove() {
+            iterator.remove();
+        }
+        
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ComparableReferrerDecorator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ComparableReferrerDecorator.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ComparableReferrerDecorator.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/ComparableReferrerDecorator.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,66 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+/**
+ *
+ * @author peter
+ */
+class ComparableReferrerDecorator<T> extends ReferrerDecorator<T> implements Comparable<Referrer<T>>  {
+    private static final long serialVersionUID = 1L;
+
+    ComparableReferrerDecorator(Referrer<T> ref){
+        super(ref);
+    }
+    
+   public int compareTo(Referrer<T> o) {
+//        T t = get();
+//        T r = o.get();
+//        if ( t != null && r != null) {
+//            if ( t instanceof Comparable){
+//                return ((Comparable) t).compareTo(r);
+//            }
+//        }
+        T t = null;
+        Referrer<T> ref = getReference();
+        if (ref instanceof UntouchableReferrer){
+            t = ((UntouchableReferrer<T>)ref).lookDontTouch();
+        } else {
+            t = ref.get();
+        }
+        T r = null;
+        if (o instanceof UntouchableReferrer){
+            r = ((UntouchableReferrer<T>)o).lookDontTouch();
+        } else {
+                o.get();
+        }
+        if ( t != null && r != null) {
+            if ( t instanceof Comparable){
+                int c = ((Comparable) t).compareTo(r);
+                if (c == 0){ // If they were untouchable, this is a hit.
+                    ref.get();
+                    o.get();
+                }
+                return c;
+            }
+        }
+        if ( hashCode() < o.hashCode()) return -1;
+        if ( hashCode() > o.hashCode()) return 1;
+        if ( ref.equals(o)) return 0;
+        return -1;
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryFacadeConverter.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryFacadeConverter.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryFacadeConverter.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryFacadeConverter.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,53 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.lang.ref.Reference;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Map.Entry;
+
+/**
+ *
+ * @author Peter Firmstone.
+ */
+class EntryFacadeConverter<K,V> implements ReferenceQueuingFactory<Entry<K,V>, Entry<Referrer<K>, Referrer<V>>> {
+    private final ReferenceQueuingFactory<K, Referrer<K>> krqf;
+    private final ReferenceQueuingFactory<V, Referrer<V>> vrqf;
+
+
+    EntryFacadeConverter(ReferenceQueuingFactory<K, Referrer<K>> krqf, ReferenceQueuingFactory<V, Referrer<V>> vrqf) {
+        this.krqf = krqf;
+        this.vrqf = vrqf;
+    }
+
+    public Entry<K,V> pseudoReferent(Entry<Referrer<K>, Referrer<V>> u) {
+        return new ReferenceEntryFacade<K, V>(u, vrqf);
+    }
+
+    public Entry<Referrer<K>, Referrer<V>> referenced(Entry<K,V> w, boolean enque, boolean temporary) {
+        // The entry could alread by a Referrer based Entry obscured by a facade.
+        return new SimpleEntry<Referrer<K>, Referrer<V>>(
+            krqf.referenced(w.getKey(), enque, false), vrqf.referenced(w.getValue(), enque, false)
+        );
+        }
+
+    public void processQueue() {
+//        krqf.processQueue();
+//        vrqf.processQueue();
+    }
+
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryIteratorFacade.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryIteratorFacade.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryIteratorFacade.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntryIteratorFacade.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,45 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.Iterator;
+
+/**
+ *
+ * @author Peter Firmstone.
+ */
+class EntryIteratorFacade<O, R> implements Iterator<O> {
+    private Iterator<R> iterator;
+    private ReferenceQueuingFactory<O, R> wf;
+
+    EntryIteratorFacade(Iterator<R> iterator, ReferenceQueuingFactory<O, R> wf) {
+        this.iterator = iterator;
+        this.wf = wf;
+    }
+
+    public boolean hasNext() {
+        return iterator.hasNext();
+    }
+
+    public O next() {
+        return wf.pseudoReferent(iterator.next());
+    }
+
+    public void remove() {
+        iterator.remove();
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntrySetFacade.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntrySetFacade.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntrySetFacade.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/EntrySetFacade.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,67 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * EntrySetFacade disguises the contained set's reference from the
+ * caller with a Facade, or exposes the underlying references to the set, when
+ * returned by the caller.
+ *
+ * @param <O>
+ * @param <R>
+ */
+/**
+ *
+ * @author peter
+ */
+class EntrySetFacade<O, R> extends AbstractSet<O> implements Set<O> {
+    private Set<R> set;
+    private ReferenceQueuingFactory<O, R> factory;
+
+    EntrySetFacade(Set<R> set, ReferenceQueuingFactory<O, R> wf) {
+        this.set = set;
+        this.factory = wf;
+    }
+
+    public int size() {
+        factory.processQueue();
+        return set.size();
+    }
+
+    public boolean isEmpty() {
+        factory.processQueue();
+        return set.isEmpty();
+    }
+
+    public Iterator<O> iterator() {
+        factory.processQueue();
+        return new EntryIteratorFacade<O, R>(set.iterator(), factory);
+    }
+
+    public void clear() {
+        set.clear();
+    }
+
+    public boolean add(O e) {
+        factory.processQueue();
+        if ( e == null ) return false;
+        return set.add(factory.referenced(e, true, false));
+    }
+    }

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/NullIterator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/NullIterator.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/NullIterator.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/NullIterator.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,40 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ *
+ * @author peter
+ */
+class NullIterator<T> implements Iterator<T> {
+    @Override
+    public boolean hasNext() {
+        return false;
+    }
+
+    @Override
+    public T next() {
+        throw new NoSuchElementException("Null Iterator");
+    }
+
+    @Override
+    public void remove() {
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RC.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RC.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RC.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/src/org/apache/river/concurrent/RC.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,380 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.lang.ref.Reference;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Deque;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.ListIterator;
+import java.util.NavigableMap;
+import java.util.NavigableSet;
+import java.util.Queue;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.concurrent.BlockingDeque;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentNavigableMap;
+import java.util.Iterator;
+
+/**
+ * <p>
+ * This class contains static methods for decorating collections
+ * with reference capability. Classes implementing Interfaces from the Java Collections Framework
+ * are supported.  Freshly constructed empty collections are passed to these
+ * static methods as parameters and returned decorated with the desired 
+ * reference capability.  {@link Referrer} is an interface equivalent to 
+ * {@link Reference}, as terms they are used interchangeably.
+ * </p><p>
+ * Referents in these collections may implement {@link Comparable} or
+ * a {@link Comparator} may be used for sorting.  When Comparator's are utilised,
+ * they must first be encapsulated {@link RC#comparator(java.util.Comparator) },
+ * before passing to a constructor for your preferred underlying Collection
+ * implementation.
+ * </p><p>
+ * {@link Comparable} is not supported for IDENTITY == referenced Collections, 
+ * in this case a Comparator must be used.  
+ * </p><p>
+ * All other references support {@link Comparable}, if the referent Object
+ * doesn't implement {@link Comparable}, then {@link Reference#hashCode()} is used
+ * for sorting.  If two referent Objects have identical hashCodes,
+ * but are unequal and do not implement {@link Comparable}, their references
+ * will also have identical hashCodes, so only one of the referents can
+ * be added to a {@link SortedSet} or {@link SortedMap}.  This can be fixed by using a
+ * {@link Comparator}.
+ * </p><p>
+ * For all intents and purposes these utilities behave the same as your preferred
+ * underlying {@link Collection} implementation, with the exception of 
+ * {@link Reference} reachability.  An Object or Key,Value entry is removed 
+ * from a {@link Collection} or {@link Map}, upon becoming eligible for 
+ * garbage collection. The parameter gcCycle controls how often the underlying
+ * collection is cleaned of enqueued references.  TIME references are collected
+ * after one gcCycle of no access, shorter cycle times will cause increased 
+ * collection and removal of TIME based references, but have no effect on 
+ * collection of soft or weak references, only the rate of removal of enqueued
+ * references.
+ * </p><p>
+ * Note that TIME based references with rapid gcCycle's will not scale well.
+ * Longer gcCycle's will scale. 
+ * </p><p>
+ * Synchronisation must be implemented by the encapsulated {@link Collection},
+ * removal of enqued references is performed by background Executor threads.
+ * Your chosen encapsulated {@link Collection} must also be mutable.  
+ * Objects will be removed automatically from encapsulated Collections when 
+ * they are eligible for garbage collection, external synchronisation of 
+ * decorated collections is not supported.
+ * </p><p>
+ * If you're using Iterators, you must synchronise on the underlying Collection
+ * or Map, if iterating through keys or values, this doesn't apply to 
+ * concurrent collections that are guaranteed not to throw a 
+ * ConcurrentModificationException.
+ * </p><p>  
+ * An Unmodifiable wrapper {@link Collections#unmodifiableCollection(java.util.Collection)}
+ * may be used externally to prevent additions to the underlying Collections,
+ * referents will still be removed as they become unreachable however.
+ * </p><p>
+ * Note that any Sub List, Sub Set or Sub Map obtained by any of the Java
+ * Collections Framework interfaces, must be views of the underlying
+ * Collection, if the Collection uses defensive copies instead of views, 
+ * References could potentially remain in one copy after garbage collection, 
+ * causing null returns.  If using standard Java Collections Framework 
+ * implementations, these problems don't occur as all Sub Lists, 
+ * Sub Sets or Sub Maps are views only.
+ * </p><p>
+ * {@link Map#entrySet() } view instances returned preserve your chosen reference
+ * behaviour, they even support {@link Set#add(java.lang.Object)} or 
+ * {@link Set#addAll(java.util.Collection)} methods, although you'll be hard
+ * pressed to find a standard java implementation that does.  If you have a
+ * Map with a Set of Entry's implementing add, the implementation will need a 
+ * Comparator, that compares Entry's only by their keys, to avoid duplicating
+ * keys, primarily because an Entry hashCode includes the both key and value in its 
+ * calculation. {@link Entry#hashCode() }
+ * </p><p>
+ * All other {@link Map#entrySet() } methods are fully implemented and supported.
+ * </p><p>
+ * {@link Entry} view instances returned by these methods preserve reference
+ * behaviour, all methods are fully implemented and supported.
+ * </p><p>
+ * {@link Set} and it's sub interfaces {@link SortedSet} and 
+ * {@link NavigableSet}, return views that preserve reference behaviour, 
+ * all methods are fully implemented and supported.
+ * </p><p>
+ * {@link Map} and it's sub interfaces {@link SortedMap}, {@link NavigableMap},
+ * {@link ConcurrentMap} and {@link ConcurrentNavigableMap} return
+ * views that preserve reference behaviour, all methods are fully implemented 
+ * and supported.
+ * </p><p>      
+ * {@link List} returns views that preserve reference behaviour, all methods are 
+ * fully implemented and supported.
+ * </p><p>
+ * {@link Queue} and it's sub interfaces {@link Deque}, {@link BlockingQueue} and
+ * {@link BlockingDeque} return views that preserve reference behaviour, 
+ * all methods are fully implemented and supported.
+ * </p><p>
+ * {@link Iterator} and {@link ListIterator} views preserve reference behaviour, all methods
+ * are fully implemented and supported.
+ * </p><p>
+ * Serialisation is supported, provided it is also supported by underlying
+ * collections.  Collections are not defensively copied during de-serialisation,
+ * due in part to an inability of determining whether a Comparator is
+ * used and in part, that if it is, it prevents Class.newInstance() construction.
+ * </p><p>
+ * Note that when a collection is first de-serialised, it's contents are
+ * strongly referenced, then changed to the correct reference type.  This
+ * will still occur, even if the Collection is immutable.
+ * </p><p>
+ * Map's don't currently support Serialization.
+ * </p><p>
+ * RC stands for Referrer Collection and is abbreviated due to the length of
+ * generic parameter arguments typically required.
+ * </p>
+ * @see Ref
+ * @see Referrer
+ * @see Reference
+ * @author Peter Firmstone.
+ */
+public class RC {
+    private RC(){} // Non instantiable
+    
+    /**
+     * When using a Comparator in SortedSet's and SortedMap's, the Comparator
+     * must be encapsulated using this method, to order the Set or Map 
+     * by referents and not References.
+     * 
+     * @param <T> referent type.
+     * @param comparator for referents.
+     * @return Decorated Comparator for Referrers
+     */
+    public static <T> Comparator<Referrer<T>> comparator(Comparator<? super T> comparator){
+        return new ReferenceComparator<T>(comparator);
+    }
+    
+    /**
+     * Decorate a Collection for holding references so it appears as a Collection
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal Collection for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated Collection.
+     */
+    public static <T> Collection<T> collection(Collection<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceCollection<T>(internal, type, true, gcCycle);
+    }
+            
+    /**
+     * Decorate a List for holding references so it appears as a List
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal List for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated List.
+     */
+    public static <T> List<T> list(List<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceList<T>(internal, type, true, gcCycle);
+    }   
+    
+    /** 
+     * Decorate a Set for holding references so it appears as a Set
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal Set for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated Set.
+     */
+    public static <T> Set<T> set(Set<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceSet<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a SortedSet for holding references so it appears as a SortedSet
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal SortedSet for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated SortedSet
+     */
+    public static <T> SortedSet<T> sortedSet(
+            SortedSet<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceSortedSet<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a NavigableSet for holding references so it appears as a NavigableSet
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal NavigableSet for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return NavigableSet<Referrer<T>> decorated as NavigableSet<T>
+     */
+    public static <T> NavigableSet<T> navigableSet(
+            NavigableSet<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceNavigableSet<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a Queue for holding references so it appears as a Queue
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal Queue for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated Queue.
+     */
+    public static <T> Queue<T> queue(Queue<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferencedQueue<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a Deque for holding references so it appears as a Deque
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal Deque for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Deque<Referrer<T>> decorated as Deque<T>
+     */
+    public static <T> Deque<T> deque(Deque<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceDeque<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a BlockingQueue for holding references so it appears as a BlockingQueue
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal BlockingQueue for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated BlockingQueue
+     */
+    public static <T> BlockingQueue<T> blockingQueue(
+            BlockingQueue<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceBlockingQueue<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a BlockingDeque for holding references so it appears as a BlockingDeque
+     * containing referents.
+     * 
+     * @param <T> referent type.
+     * @param internal BlockingDeque for holding Referrer objects.
+     * @param type Referrer implementation required.
+     * @param gcCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated BlockingDeque
+     */
+    public static <T> BlockingDeque<T> blockingDeque(
+            BlockingDeque<Referrer<T>> internal, Ref type, long gcCycle){
+        return new ReferenceBlockingDeque<T>(internal, type, true, gcCycle);
+    }
+    /**
+     * Decorate a Map for holding references so it appears as a Map
+     * containing referents.
+     * 
+     * @param <K> key referent type
+     * @param <V> value referent type
+     * @param internal Map for holding Referrer objects
+     * @param key Referrer implementation required, as defined by Ref
+     * @param value Referrer implementation required, as defined by Ref
+     * @param gcKeyCycle scheduled cleaning task interval in milliseconds.
+     * @param gcValCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated Map
+     */
+    public static <K, V> Map<K, V> map(
+            Map<Referrer<K>, Referrer<V>> internal, Ref key, Ref value, long gcKeyCycle, long gcValCycle){
+        return new ReferenceMap<K, V>(internal, key, value, true, gcKeyCycle, gcValCycle);
+    }
+    /**
+     * Decorate a SortedMap for holding references so it appears as a SortedMap
+     * containing referents.
+     * 
+     * @param <K> key referent type
+     * @param <V> value referent type
+     * @param internal SortedMap for holding Referrer objects
+     * @param key Referrer implementation required, as defined by Ref
+     * @param value Referrer implementation required, as defined by Ref
+     * @param gcKeyCycle scheduled cleaning task interval in milliseconds.
+     * @param gcValCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated SortedMap
+     */
+    public static <K, V> SortedMap<K, V> sortedMap(
+            SortedMap<Referrer<K>, Referrer<V>> internal, Ref key, Ref value, long gcKeyCycle, long gcValCycle){
+        return new ReferenceSortedMap<K, V>(internal, key, value, true, gcKeyCycle, gcValCycle);
+    }
+    /**
+     * Decorate a NavigableMap for holding Referrers so it appears as a NavigableMap
+     * containing referents.
+     * 
+     * @param <K> key referent type
+     * @param <V> value referent type
+     * @param internal NavigableMap for holding Referrer objects
+     * @param key Referrer implementation required, as defined by Ref
+     * @param value Referrer implementation required, as defined by Ref
+     * @param gcKeyCycle scheduled cleaning task interval in milliseconds.
+     * @param gcValCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated NavigableMap
+     */
+    public static <K, V> NavigableMap<K, V> navigableMap(
+            NavigableMap<Referrer<K>, Referrer<V>> internal, Ref key, Ref value, long gcKeyCycle, long gcValCycle){
+        return new ReferenceNavigableMap<K, V>(internal, key, value, true, gcKeyCycle, gcValCycle);
+    }
+    /**
+     * Decorate a ConcurrentMap for holding references so it appears as a ConcurrentMap
+     * containing referents.
+     * 
+     * @param <K> - key type.
+     * @param <V> - value type.
+     * @param internal - for holding references.
+     * @param key - key reference type.
+     * @param value - value reference type.
+     * @param gcKeyCycle scheduled cleaning task interval in milliseconds.
+     * @param gcValCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated ConcurrentMap
+     */
+    public static <K, V> ConcurrentMap<K, V> concurrentMap(
+            ConcurrentMap<Referrer<K>, Referrer<V>> internal, Ref key, Ref value, long gcKeyCycle, long gcValCycle){
+        return new ReferenceConcurrentMap<K, V>(internal, key, value, true, gcKeyCycle, gcValCycle);
+    }
+    
+    /**
+     * Decorate a ConcurrentNavigableMap for holding references so it appears as a 
+     * ConcurrentNavigableMap containing referents.
+     * 
+     * @param <K> key referent type
+     * @param <V> value referent type
+     * @param internal NavigableMap for holding Referrer objects
+     * @param key Referrer implementation required, as defined by Ref
+     * @param value Referrer implementation required, as defined by Ref
+     * @param gcKeyCycle scheduled cleaning task interval in milliseconds.
+     * @param gcValCycle scheduled cleaning task interval in milliseconds.
+     * @return Decorated ConcurrentNavigableMap
+     */
+    public static <K, V> ConcurrentNavigableMap<K, V> concurrentNavigableMap(
+            ConcurrentNavigableMap<Referrer<K>, Referrer<V>> internal, Ref key, Ref value, long gcKeyCycle, long gcValCycle){
+        return new ReferenceConcurrentNavigableMap<K, V>(internal, key, value, true, gcKeyCycle, gcValCycle);
+    }
+}