You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/05/19 08:00:56 UTC

svn commit: r407724 [2/11] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/rmi/make/ modules/rmi/src/main/java/java/rmi/ modules/rmi/src/main/java/java/rmi/registry/ modules/rmi/src/main/java/java/rmi/server/ modules/rmi/src/main/java/or...

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/server/UnicastRemoteObject.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/server/UnicastRemoteObject.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/server/UnicastRemoteObject.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/java/rmi/server/UnicastRemoteObject.java Thu May 18 23:00:52 2006
@@ -1,225 +1,225 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  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 java.rmi.server;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.NoSuchObjectException;
-
-import ar.org.fitc.rmi.runtime.RemoteReferenceManager;
-import ar.org.fitc.rmi.server.UnicastRemoteRef2Impl;
-import ar.org.fitc.rmi.server.UnicastRemoteRefImpl;
-import ar.org.fitc.rmi.server.UnicastServerRef2Impl;
-import ar.org.fitc.rmi.server.UnicastServerRefImpl;
-import ar.org.fitc.rmi.transport.Endpoint;
-import ar.org.fitc.rmi.transport.TransportManager;
-
-/**
- * @ar.org.fitc.spec_ref
- * 
- */
-public class UnicastRemoteObject extends RemoteServer {
-
-    private static final long serialVersionUID = 4974527148936298033L;
-
-    private transient int port;
-
-    private transient RMIClientSocketFactory csf;
-
-    private transient RMIServerSocketFactory ssf;
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    protected UnicastRemoteObject() throws RemoteException {
-        this(0);
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    protected UnicastRemoteObject(int port) throws RemoteException {
-        this.port = port;
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        Endpoint ep = tm.export(objID, port, null, null);
-        UnicastServerRefImpl sref = new UnicastServerRefImpl(this, objID, ep);
-        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
-        this.ref = sref;
-        rrm.storeExportData(this, objID, sref, stub);
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    protected UnicastRemoteObject(int port, RMIClientSocketFactory csf,
-            RMIServerSocketFactory ssf) throws RemoteException {
-        this.port = port;
-        this.csf = csf;
-        this.ssf = ssf;
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        Endpoint ep = tm.export(objID, port, ssf, csf);
-        UnicastServerRef2Impl sref = new UnicastServerRef2Impl(this, objID, ep);
-        Remote stub = rrm
-                .createStub(new UnicastRemoteRef2Impl(objID, ep), this);
-        this.ref = sref;
-        rrm.storeExportData(this, objID, sref, stub);
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    @Override
-	public Object clone() throws CloneNotSupportedException {
-        UnicastRemoteObject clon = (UnicastRemoteObject) super.clone();
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        try {
-            Endpoint ep = tm.export(objID, this.port, this.ssf, this.csf);
-            UnicastServerRef2Impl sref = new UnicastServerRef2Impl(clon, objID,
-                    ep);
-            Remote stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep),
-                    clon);
-            clon.ref = sref;
-            rrm.storeExportData(clon, objID, sref, stub);
-        } catch (RemoteException e) {
-            throw new CloneNotSupportedException(
-                    "Error during clon exportation");
-        }
-        return clon;
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    public static RemoteStub exportObject(Remote obj) throws RemoteException {
-        if (obj == null) {
-            throw new RemoteException("Invalid (null) Remote server object.");
-        }
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        if (rrm.isExported(obj)) {
-            throw new RemoteException("Object already exported.");
-        }
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        Endpoint ep = tm.export(objID, 0, null, null);
-        UnicastServerRefImpl sref = new UnicastServerRefImpl(obj, objID, ep);
-        RemoteStub stub = rrm.createRegularStub(new UnicastRemoteRefImpl(objID,
-                ep), obj);
-        rrm.storeExportData(obj, objID, sref, stub);
-        return stub;
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    public static Remote exportObject(Remote obj, int port)
-            throws RemoteException {
-        if (obj == null) {
-            throw new RemoteException("Invalid (null) Remote server object.");
-        }
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        if (rrm.isExported(obj)) {
-            throw new RemoteException("Object already exported.");
-        }
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        Endpoint ep = tm.export(objID, port, null, null);
-        UnicastServerRefImpl sref = new UnicastServerRefImpl(obj, objID, ep);
-        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), obj);
-        rrm.storeExportData(obj, objID, sref, stub);
-        return stub;
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    public static Remote exportObject(Remote obj, int port,
-            RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
-            throws RemoteException {
-        if (obj == null) {
-            throw new RemoteException("Invalid (null) Remote server object.");
-        }
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        if (rrm.isExported(obj)) {
-            throw new RemoteException("Object already exported.");
-        }
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        Endpoint ep = tm.export(objID, port, ssf, csf);
-        UnicastServerRef2Impl sref = new UnicastServerRef2Impl(obj, objID, ep);
-        Remote stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep), obj);
-        rrm.storeExportData(obj, objID, sref, stub);
-        return stub;
-    }
-
-    /**
-     * @ar.org.fitc.spec_ref
-     * 
-     */
-    public static boolean unexportObject(Remote obj, boolean force)
-            throws NoSuchObjectException {
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        return rrm.unexportObject(obj, force);
-    }
-
-    /**
-     * 
-     * 
-     */
-    private void writeObject(ObjectOutputStream out) throws IOException {
-        out.defaultWriteObject();
-    }
-
-    /**
-     * 
-     * 
-     */
-    private void readObject(ObjectInputStream in) throws IOException,
-            ClassNotFoundException {
-        in.defaultReadObject();
-        RemoteReferenceManager rrm = RemoteReferenceManager
-                .getRemoteReferenceManager();
-        TransportManager tm = TransportManager.getTransportManager();
-        ObjID objID = new ObjID();
-        Endpoint ep = tm.export(objID, 0, null, null);
-        UnicastServerRefImpl sref = new UnicastServerRefImpl(this, objID, ep);
-        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
-        this.ref = sref;
-        rrm.storeExportData(this, objID, sref, stub);
-    }
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+
+import org.apache.harmony.rmi.internal.runtime.RemoteReferenceManager;
+import org.apache.harmony.rmi.internal.server.UnicastRemoteRef2Impl;
+import org.apache.harmony.rmi.internal.server.UnicastRemoteRefImpl;
+import org.apache.harmony.rmi.internal.server.UnicastServerRef2Impl;
+import org.apache.harmony.rmi.internal.server.UnicastServerRefImpl;
+import org.apache.harmony.rmi.internal.transport.Endpoint;
+import org.apache.harmony.rmi.internal.transport.TransportManager;
+
+/**
+ * @ar.org.fitc.spec_ref
+ * 
+ */
+public class UnicastRemoteObject extends RemoteServer {
+
+    private static final long serialVersionUID = 4974527148936298033L;
+
+    private transient int port;
+
+    private transient RMIClientSocketFactory csf;
+
+    private transient RMIServerSocketFactory ssf;
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    protected UnicastRemoteObject() throws RemoteException {
+        this(0);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    protected UnicastRemoteObject(int port) throws RemoteException {
+        this.port = port;
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(this, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
+        this.ref = sref;
+        rrm.storeExportData(this, objID, sref, stub);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    protected UnicastRemoteObject(int port, RMIClientSocketFactory csf,
+            RMIServerSocketFactory ssf) throws RemoteException {
+        this.port = port;
+        this.csf = csf;
+        this.ssf = ssf;
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, ssf, csf);
+        UnicastServerRef2Impl sref = new UnicastServerRef2Impl(this, objID, ep);
+        Remote stub = rrm
+                .createStub(new UnicastRemoteRef2Impl(objID, ep), this);
+        this.ref = sref;
+        rrm.storeExportData(this, objID, sref, stub);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    @Override
+	public Object clone() throws CloneNotSupportedException {
+        UnicastRemoteObject clon = (UnicastRemoteObject) super.clone();
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        try {
+            Endpoint ep = tm.export(objID, this.port, this.ssf, this.csf);
+            UnicastServerRef2Impl sref = new UnicastServerRef2Impl(clon, objID,
+                    ep);
+            Remote stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep),
+                    clon);
+            clon.ref = sref;
+            rrm.storeExportData(clon, objID, sref, stub);
+        } catch (RemoteException e) {
+            throw new CloneNotSupportedException(
+                    "Error during clon exportation");
+        }
+        return clon;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static RemoteStub exportObject(Remote obj) throws RemoteException {
+        if (obj == null) {
+            throw new RemoteException("Invalid (null) Remote server object.");
+        }
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        if (rrm.isExported(obj)) {
+            throw new RemoteException("Object already exported.");
+        }
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, 0, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(obj, objID, ep);
+        RemoteStub stub = rrm.createRegularStub(new UnicastRemoteRefImpl(objID,
+                ep), obj);
+        rrm.storeExportData(obj, objID, sref, stub);
+        return stub;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static Remote exportObject(Remote obj, int port)
+            throws RemoteException {
+        if (obj == null) {
+            throw new RemoteException("Invalid (null) Remote server object.");
+        }
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        if (rrm.isExported(obj)) {
+            throw new RemoteException("Object already exported.");
+        }
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(obj, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), obj);
+        rrm.storeExportData(obj, objID, sref, stub);
+        return stub;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static Remote exportObject(Remote obj, int port,
+            RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
+            throws RemoteException {
+        if (obj == null) {
+            throw new RemoteException("Invalid (null) Remote server object.");
+        }
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        if (rrm.isExported(obj)) {
+            throw new RemoteException("Object already exported.");
+        }
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, ssf, csf);
+        UnicastServerRef2Impl sref = new UnicastServerRef2Impl(obj, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep), obj);
+        rrm.storeExportData(obj, objID, sref, stub);
+        return stub;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static boolean unexportObject(Remote obj, boolean force)
+            throws NoSuchObjectException {
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        return rrm.unexportObject(obj, force);
+    }
+
+    /**
+     * 
+     * 
+     */
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        out.defaultWriteObject();
+    }
+
+    /**
+     * 
+     * 
+     */
+    private void readObject(ObjectInputStream in) throws IOException,
+            ClassNotFoundException {
+        in.defaultReadObject();
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, 0, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(this, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
+        this.ref = sref;
+        rrm.storeExportData(this, objID, sref, stub);
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/DGCScheduledGC.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/DGCScheduledGC.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/DGCScheduledGC.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/DGCScheduledGC.java Thu May 18 23:00:52 2006
@@ -1,101 +1,101 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  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 ar.org.fitc.rmi.dgc;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import ar.org.fitc.rmi.utils.PropertiesReader;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This class schedules calls to the <code>java.lang.System.gc()</code>
- * method.
- * 
- * @author Gustavo Petri
- */
-public class DGCScheduledGC {
-
-    /**
-     * Timer to schedule the calls
-     */
-    private Timer timer;
-
-    /**
-     * The interval used by the Timer
-     */
-    private static long gcInterval;
-
-    /**
-     * Flag to indicate the termination of the Thread
-     */
-    private static boolean running = false;
-
-    static {
-        gcInterval = PropertiesReader.readLong(
-                "ar.org.fitc.rmi.dgc.gcInterval", 60000);
-    }
-
-    /**
-     * Schedules the calls to <code>java.lang.System.gc()</code>
-     * 
-     * @see <a
-     *      href="http://archives.java.sun.com/cgi-bin/wa?A2=ind9911&L=rmi-users&F=&S=&P=20099">
-     *      Reference </a>
-     */
-
-    private DGCScheduledGC() {
-        timer = new Timer(true);
-        try {
-            timer.schedule(new RunGCTask(), gcInterval, gcInterval);
-        } catch (Exception e) {
-            // There is no chance that this try will fail unless the runGC
-            // method be errased.
-            throw new AssertionError();
-        }
-        running = true;
-    }
-
-    /**
-     * Schedules and starts the calls to <code>java.lang.System.gc()</code>
-     * 
-     * @see <a
-     *      href="http://archives.java.sun.com/cgi-bin/wa?A2=ind9911&L=rmi-users&F=&S=&P=20099">
-     *      Reference </a>
-     */
-    public static synchronized final void startGC() {
-        if (!running) {
-            new DGCScheduledGC();
-        }
-    }
-
-    /**
-     * Runs the <code>java.lang.System.gc()</code> method.
-     */
-    private class RunGCTask extends TimerTask {
-
-        @Override
-        public void run() {
-            System.gc();
-        }
-    }
-   
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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.harmony.rmi.internal.dgc;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.harmony.rmi.internal.utils.PropertiesReader;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This class schedules calls to the <code>java.lang.System.gc()</code>
+ * method.
+ * 
+ * @author Gustavo Petri
+ */
+public class DGCScheduledGC {
+
+    /**
+     * Timer to schedule the calls
+     */
+    private Timer timer;
+
+    /**
+     * The interval used by the Timer
+     */
+    private static long gcInterval;
+
+    /**
+     * Flag to indicate the termination of the Thread
+     */
+    private static boolean running = false;
+
+    static {
+        gcInterval = PropertiesReader.readLong(
+                "org.apache.harmony.rmi.internal.dgc.gcInterval", 60000);
+    }
+
+    /**
+     * Schedules the calls to <code>java.lang.System.gc()</code>
+     * 
+     * @see <a
+     *      href="http://archives.java.sun.com/cgi-bin/wa?A2=ind9911&L=rmi-users&F=&S=&P=20099">
+     *      Reference </a>
+     */
+
+    private DGCScheduledGC() {
+        timer = new Timer(true);
+        try {
+            timer.schedule(new RunGCTask(), gcInterval, gcInterval);
+        } catch (Exception e) {
+            // There is no chance that this try will fail unless the runGC
+            // method be errased.
+            throw new AssertionError();
+        }
+        running = true;
+    }
+
+    /**
+     * Schedules and starts the calls to <code>java.lang.System.gc()</code>
+     * 
+     * @see <a
+     *      href="http://archives.java.sun.com/cgi-bin/wa?A2=ind9911&L=rmi-users&F=&S=&P=20099">
+     *      Reference </a>
+     */
+    public static synchronized final void startGC() {
+        if (!running) {
+            new DGCScheduledGC();
+        }
+    }
+
+    /**
+     * Runs the <code>java.lang.System.gc()</code> method.
+     */
+    private class RunGCTask extends TimerTask {
+
+        @Override
+        public void run() {
+            System.gc();
+        }
+    }
+   
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCClient.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCClient.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCClient.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCClient.java Thu May 18 23:00:52 2006
@@ -1,410 +1,410 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  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 ar.org.fitc.rmi.dgc.client;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.rmi.Remote;
-import java.rmi.UnmarshalException;
-import java.rmi.dgc.Lease;
-import java.rmi.dgc.VMID;
-import java.rmi.server.ObjID;
-import java.rmi.server.RemoteObjectInvocationHandler;
-import java.rmi.server.RemoteRef;
-import java.rmi.server.RemoteStub;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Timer;
-import java.util.WeakHashMap;
-
-import ar.org.fitc.rmi.dgc.DGCScheduledGC;
-import ar.org.fitc.rmi.transport.Endpoint;
-import ar.org.fitc.rmi.transport.TransportManager;
-import ar.org.fitc.rmi.utils.Pair;
-import ar.org.fitc.rmi.utils.PropertiesReader;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * Implements the client's side of the RMI Garbage Collector. This class takes
- * care of scheduling and sending the dirty and clean calls to the server side
- * of RMI DGC, when stubs of remote objects are received.
- * 
- * @author Gonzalo Ortega
- * 
- */
-public final class DGCClient {
-
-	private static DGCClient dgcClient;
-
-    private VMID vmID;
-
-    private long sequenceNumber;
-
-    private long leaseValue;
-
-    private ObjID dgcObjID;
-
-    private Map<Remote, WeakReference<Remote>> stubsCacheTable;
-
-    private Map<RemoteRef, Pair<Endpoint, ObjID>> deserializedRemoteRefTable;
-
-    private Map<Pair<Endpoint, ObjID>, Long> liveReferences;
-
-    private Map<Long, DirtyTask> dirtyTaskTable;
-
-    private Timer taskScheduler;
-
-    private DGCQueuePoll unreferencedPoll;
-    
-    /** The method hash for the "clean" method in the DGC */
-    private static final long SEND_CLEAN_OP_NUM = -5803803475088455571L;
-    
-    /** The method hash for the "dirty" method in the DGC */
-    private static final long SEND_DIRTY_OP_NUM = -8139341527526761862L;
-
-    /**
-     * Implements the singleton behavior. If there is an instance of
-     * <code>DGCClient</code> is returned, else a new instance is created and
-     * returned.
-     * 
-     * @return the only <code>DGCClient</code> instance
-     */
-    public static synchronized final DGCClient getDGCClient() {
-        if (dgcClient == null) {
-            dgcClient = new DGCClient();
-        }
-        return dgcClient;
-    }
-
-    /**
-     * Creates a new instance of DGCClient. Launches the scheduler (as a daemon)
-     * that sends the dirty calls, and starts the monitor (as a daemon) that
-     * will look for unreferenced stubs.
-     */
-    @Deprecated
-    private DGCClient() {
-        stubsCacheTable = new WeakHashMap<Remote, WeakReference<Remote>>();
-        deserializedRemoteRefTable = new WeakHashMap<RemoteRef, Pair<Endpoint, ObjID>>();
-        dirtyTaskTable = new HashMap<Long, DirtyTask>();
-        liveReferences = new Hashtable<Pair<Endpoint, ObjID>, Long>();
-
-        /*
-         * RMI API states that a client should use a null value if it is unable
-         * to generate a VMID. The only way to know if the generated VMID is
-         * somehow "unique" is calling the deprecated VMID.isUnique() method, as
-         * long the VMID constructor doesn't throw any exception. (it always
-         * success)
-         */
-        if (VMID.isUnique()) {
-            vmID = new VMID();
-        }
-        sequenceNumber = 0;
-        leaseValue = 600000L;
-        dgcObjID = new ObjID(ObjID.DGC_ID);
-
-        
-        
-        String propertyValue = 
-            PropertiesReader.readString("java.rmi.dgc.leaseValue");
-        if (propertyValue != null) {
-            try {
-                leaseValue = Long.parseLong(propertyValue);
-            } catch (NumberFormatException e) {
-            }
-        }
-
-        taskScheduler = new Timer(true);
-
-        unreferencedPoll = new DGCQueuePoll(this);
-        unreferencedPoll.setDaemon(true);
-        unreferencedPoll.setName("rmi.dgc.client.unreferencedStubPoll");
-        unreferencedPoll.start();
-
-        DGCScheduledGC.startGC();
-    }
-
-    /**
-     * Stores the data received during the deserialization of a stub. The
-     * <code>Endpoint</code> and <code>ObjID</code> from the remote
-     * reference are stored in order to be used to send dirty and clean calls
-     * grouped by Endpoint.
-     * 
-     * @param ref
-     *            The reference received from the stream.
-     * @param ep
-     *            The <code>Endpoint</code> that corresponds to the reference.
-     * @param objID
-     *            The <code>ObjID</code> that corresponds to the reference.
-     */
-    public synchronized final void registerRemoteRef(RemoteRef ref, Endpoint ep,
-            ObjID objID) {
-        if (!deserializedRemoteRefTable.containsKey(ref)) {
-            deserializedRemoteRefTable.put(ref, new Pair<Endpoint, ObjID>(ep,
-                    objID));
-        }
-        return;
-    }
-
-    /**
-     * If the received stub is the first instance of that stub in the client’s
-     * system, it is cached and returned. The method
-     * <code>activateReference</code> is called in order to start the lease
-     * renewal process. If there is a previous instance of this stub in the
-     * system, the received stub is discarded and the cached instance is
-     * returned.
-     * 
-     * @param stub
-     *            The stub received during deserialization process.
-     * @return The unique instance of this stub in the client's system.
-     * @throws UnmarshalException
-     *             If there is missing information or the dirty call for the
-     *             received stub fails.
-     */
-    public synchronized Remote getStubInstance(Remote stub)
-            throws UnmarshalException {
-        // Get internal RemoteRef from stub
-        RemoteRef ref = null;
-        if (stub instanceof RemoteStub) {
-            ref = ((RemoteStub) stub).getRef();
-        }
-        if (Proxy.isProxyClass(stub.getClass())) {
-            InvocationHandler ih = Proxy.getInvocationHandler(stub);
-            if (ih instanceof RemoteObjectInvocationHandler) {
-                ref = ((RemoteObjectInvocationHandler) ih).getRef();
-            }
-        }
-        // Check whether there is a stub already registered in the DGC
-        WeakReference<Remote> weakStub;
-        if ((weakStub = stubsCacheTable.get(stub)) != null) {
-            Remote cachedStub = weakStub.get();
-            if (cachedStub != null) {
-                checkLiveness(ref);
-                return cachedStub;
-            }
-        }
-        Pair<Endpoint, ObjID> data = activateReference(ref);
-        weakStub = unreferencedPoll.addToReferenceQueue(stub, data);
-        stubsCacheTable.put(stub, weakStub);
-        return stub;
-    }
-
-    /**
-     * Sends the first dirty for a received reference in order to get the
-     * appropiate lease time from the server, and then schedules the dirty call
-     * for lease renewal. If the first dirty message fails, a clean "strong"
-     * message is sent for that remote object. If the first dirty call
-     * succeeded, the reference becomes a "live" reference for the client DGC.
-     * 
-     * @param ref
-     *            The reference received inside the stub
-     * @return The <code>Endpoint / ObjID</code> pair contained inside the
-     *         reference
-     * @throws UnmarshalException
-     *             If the first dirty call fails
-     */
-    private final Pair<Endpoint, ObjID> activateReference(RemoteRef ref)
-            throws UnmarshalException {
-        // Get necessary data previously stored during RemoteRef
-        // deserialization.
-        Pair<Endpoint, ObjID> data = deserializedRemoteRefTable.get(ref);
-        if (data == null) {
-            throw new UnmarshalException(
-                    "Impossible to get a stub for this object.");
-        }
-        Lease lease = sendDirty(data.getFirst(),
-                new ObjID[] { data.getSecond() });
-
-        if (lease != null) {
-            enqueueDirtyCall(data, lease.getValue());
-            liveReferences.put(data, new Long(lease.getValue()));
-            return data;
-        } else {
-            sendClean(data.getFirst(), new ObjID[] { data.getSecond() }, true);
-            throw new UnmarshalException(
-                    "Impossible to get a stub for this object.");
-        }
-    }
-
-    /**
-     * Checks whether the received reference is a "live" reference for the
-     * client garbage collector. The client DGC sends dirties for all "live"
-     * references in order to renew the lease with the remote server. If the DGC
-     * is not sending dirties for a reference (because of persistent network
-     * problems, for instance) that reference is no longer considered "live". If
-     * the received reference is not "live", the method
-     * <code>activateReference</code> will be called in order to restart the
-     * lease renewal process.
-     * 
-     * @param ref
-     *            The reference to be tested
-     */
-    public synchronized final void checkLiveness(RemoteRef ref) {
-        Pair<Endpoint, ObjID> dataRef = deserializedRemoteRefTable.get(ref);
-        if (liveReferences.containsKey(dataRef)) {
-            return;
-        }
-        try {
-            activateReference(ref);
-        } catch (UnmarshalException e) {
-            // An Exception was thrown trying to bring the reference back to
-            // life
-        }
-    }
-
-    /**
-     * Schedules a dirty call to be sent periodically. The dirty call will be
-     * sent every <code>period</code> / 2 milliseconds.
-     * 
-     * @param data
-     *            An <code>Endpoint / ObjID</code> pair representing a
-     *            reference.
-     * @param period
-     *            The lease period granted by the server.
-     */
-    void enqueueDirtyCall(Pair<Endpoint, ObjID> data, long period) {
-        synchronized (dirtyTaskTable) {
-            DirtyTask task = dirtyTaskTable.get(new Long(period));
-            if (task != null) {
-                task.scheduleDirty(data);
-            } else {
-                task = new DirtyTask(this, period, taskScheduler,
-                        dirtyTaskTable);
-                task.scheduleDirty(data);
-                taskScheduler.schedule(task, period / 2, period / 2);
-                dirtyTaskTable.put(new Long(period), task);
-            }
-        }
-    }
-
-    /**
-     * Removes the reference represented by the <code>Endpoint / ObjID</code>
-     * pair from the dirty calls scheduler. No more dirties will be sent for
-     * that reference, and the reference is erased from the "live" references
-     * internal table.
-     * 
-     * @param ep
-     *            The <code>Endpoint</code> of the remote reference.
-     * @param objID
-     *            The <code>ObjID</code> of the remote reference.
-     */
-    void cancelDirtyCall(Endpoint ep, ObjID objID) {
-        synchronized (dirtyTaskTable) {
-            Pair<Endpoint, ObjID> dataRef = new Pair<Endpoint, ObjID>(ep, objID);
-            Long period = liveReferences.get(dataRef);
-            DirtyTask task = dirtyTaskTable.get(period);
-            if (task != null) {
-                task.cancelDirty(ep, objID);
-                if (task.isEmpty()) {
-                    task.cancel();
-                    dirtyTaskTable.remove(period);
-                    /* SEE DISCLAIMER */
-                    //taskScheduler.purge();
-                }
-            }
-            liveReferences.remove(dataRef);
-        }
-    }
-
-    /**
-     * Removes the reference represented by the <code>Endpoint / ObjID</code>
-     * pair from the "live" references internal table.
-     * 
-     * @param dataRef
-     *            The <code>Endpoint / ObjID</code> pair representing the
-     *            reference
-     */
-    void removeFromLiveReferences(Pair<Endpoint, ObjID> dataRef) {
-        liveReferences.remove(dataRef);
-    }
-
-    /**
-     * Checks whether the reference represented by the
-     * <code>Endpoint / ObjID</code> pair is a "live" reference. The client
-     * DGC sends dirties for all "live" references in order to renew the lease
-     * with the remote server.
-     * 
-     * @param dataRef
-     *            An <code>Endpoint / ObjID</code> pair representing a
-     *            reference
-     * @return true if the received pair is a "live" reference
-     */
-    boolean isLiveReference(Pair<Endpoint, ObjID> dataRef) {
-        return liveReferences.containsKey(dataRef);
-    }
-
-    /**
-     * Sends a clean call to the DGC of the remote server.
-     * 
-     * @param ep
-     *            The <code>Endpoint</code> where the clean call will be sent.
-     * @param obj
-     *            An array containing the object identifiers that will be sent
-     *            in the clean call.
-     * @param strong
-     *            The flag that indicates a 'strong' clean call
-     */
-    void sendClean(Endpoint ep, ObjID[] obj, boolean strong) {
-    	synchronized(dgcObjID) { 
-	        Object[] args = new Object[] { obj, ++sequenceNumber, vmID, strong };
-	        TransportManager tm = TransportManager.getTransportManager();
-	        try {
-	            tm.invoke(dgcObjID, ep, args, SEND_CLEAN_OP_NUM, false);
-	        } catch (Exception e) {
-	            // The clean call has failed.
-	        }
-    	}
-    }
-
-    /**
-     * Sends a dirty call to the DGC of the remote server, and returns the
-     * <code>Lease</code> granted by that DGC.
-     * 
-     * @param ep
-     *            The <code>Endpoint</code> where the dirty call will be sent.
-     * @param obj
-     *            An array containing the object identifiers that will be sent
-     *            in the dirty call.
-     * @return The <code>Lease</code> returned from the server DGC, or
-     *         <code>null</code> if the call has failed.
-     */
-    Lease sendDirty(Endpoint ep, ObjID[] obj) {
-    	synchronized(dgcObjID) { 
-	        Lease lease = new Lease(vmID, leaseValue);
-	        Object[] args = new Object[] { obj, ++sequenceNumber, lease };
-	        TransportManager tm = TransportManager.getTransportManager();
-	        Object response;
-	        try {
-	            response = tm.invoke(dgcObjID, ep, args, SEND_DIRTY_OP_NUM, true);
-	            if (response instanceof Lease) {
-	                if (vmID == null) {
-	                    vmID = ((Lease) response).getVMID();
-	                }
-	                return (Lease) response;
-	            }
-	            return null;
-	        } catch (Exception e) {
-	            return null;
-	        }
-    	}
-    }
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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.harmony.rmi.internal.dgc.client;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.UnmarshalException;
+import java.rmi.dgc.Lease;
+import java.rmi.dgc.VMID;
+import java.rmi.server.ObjID;
+import java.rmi.server.RemoteObjectInvocationHandler;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Timer;
+import java.util.WeakHashMap;
+
+import org.apache.harmony.rmi.internal.dgc.DGCScheduledGC;
+import org.apache.harmony.rmi.internal.transport.Endpoint;
+import org.apache.harmony.rmi.internal.transport.TransportManager;
+import org.apache.harmony.rmi.internal.utils.Pair;
+import org.apache.harmony.rmi.internal.utils.PropertiesReader;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * Implements the client's side of the RMI Garbage Collector. This class takes
+ * care of scheduling and sending the dirty and clean calls to the server side
+ * of RMI DGC, when stubs of remote objects are received.
+ * 
+ * @author Gonzalo Ortega
+ * 
+ */
+public final class DGCClient {
+
+	private static DGCClient dgcClient;
+
+    private VMID vmID;
+
+    private long sequenceNumber;
+
+    private long leaseValue;
+
+    private ObjID dgcObjID;
+
+    private Map<Remote, WeakReference<Remote>> stubsCacheTable;
+
+    private Map<RemoteRef, Pair<Endpoint, ObjID>> deserializedRemoteRefTable;
+
+    private Map<Pair<Endpoint, ObjID>, Long> liveReferences;
+
+    private Map<Long, DirtyTask> dirtyTaskTable;
+
+    private Timer taskScheduler;
+
+    private DGCQueuePoll unreferencedPoll;
+    
+    /** The method hash for the "clean" method in the DGC */
+    private static final long SEND_CLEAN_OP_NUM = -5803803475088455571L;
+    
+    /** The method hash for the "dirty" method in the DGC */
+    private static final long SEND_DIRTY_OP_NUM = -8139341527526761862L;
+
+    /**
+     * Implements the singleton behavior. If there is an instance of
+     * <code>DGCClient</code> is returned, else a new instance is created and
+     * returned.
+     * 
+     * @return the only <code>DGCClient</code> instance
+     */
+    public static synchronized final DGCClient getDGCClient() {
+        if (dgcClient == null) {
+            dgcClient = new DGCClient();
+        }
+        return dgcClient;
+    }
+
+    /**
+     * Creates a new instance of DGCClient. Launches the scheduler (as a daemon)
+     * that sends the dirty calls, and starts the monitor (as a daemon) that
+     * will look for unreferenced stubs.
+     */
+    @Deprecated
+    private DGCClient() {
+        stubsCacheTable = new WeakHashMap<Remote, WeakReference<Remote>>();
+        deserializedRemoteRefTable = new WeakHashMap<RemoteRef, Pair<Endpoint, ObjID>>();
+        dirtyTaskTable = new HashMap<Long, DirtyTask>();
+        liveReferences = new Hashtable<Pair<Endpoint, ObjID>, Long>();
+
+        /*
+         * RMI API states that a client should use a null value if it is unable
+         * to generate a VMID. The only way to know if the generated VMID is
+         * somehow "unique" is calling the deprecated VMID.isUnique() method, as
+         * long the VMID constructor doesn't throw any exception. (it always
+         * success)
+         */
+        if (VMID.isUnique()) {
+            vmID = new VMID();
+        }
+        sequenceNumber = 0;
+        leaseValue = 600000L;
+        dgcObjID = new ObjID(ObjID.DGC_ID);
+
+        
+        
+        String propertyValue = 
+            PropertiesReader.readString("java.rmi.dgc.leaseValue");
+        if (propertyValue != null) {
+            try {
+                leaseValue = Long.parseLong(propertyValue);
+            } catch (NumberFormatException e) {
+            }
+        }
+
+        taskScheduler = new Timer(true);
+
+        unreferencedPoll = new DGCQueuePoll(this);
+        unreferencedPoll.setDaemon(true);
+        unreferencedPoll.setName("rmi.dgc.client.unreferencedStubPoll");
+        unreferencedPoll.start();
+
+        DGCScheduledGC.startGC();
+    }
+
+    /**
+     * Stores the data received during the deserialization of a stub. The
+     * <code>Endpoint</code> and <code>ObjID</code> from the remote
+     * reference are stored in order to be used to send dirty and clean calls
+     * grouped by Endpoint.
+     * 
+     * @param ref
+     *            The reference received from the stream.
+     * @param ep
+     *            The <code>Endpoint</code> that corresponds to the reference.
+     * @param objID
+     *            The <code>ObjID</code> that corresponds to the reference.
+     */
+    public synchronized final void registerRemoteRef(RemoteRef ref, Endpoint ep,
+            ObjID objID) {
+        if (!deserializedRemoteRefTable.containsKey(ref)) {
+            deserializedRemoteRefTable.put(ref, new Pair<Endpoint, ObjID>(ep,
+                    objID));
+        }
+        return;
+    }
+
+    /**
+     * If the received stub is the first instance of that stub in the client’s
+     * system, it is cached and returned. The method
+     * <code>activateReference</code> is called in order to start the lease
+     * renewal process. If there is a previous instance of this stub in the
+     * system, the received stub is discarded and the cached instance is
+     * returned.
+     * 
+     * @param stub
+     *            The stub received during deserialization process.
+     * @return The unique instance of this stub in the client's system.
+     * @throws UnmarshalException
+     *             If there is missing information or the dirty call for the
+     *             received stub fails.
+     */
+    public synchronized Remote getStubInstance(Remote stub)
+            throws UnmarshalException {
+        // Get internal RemoteRef from stub
+        RemoteRef ref = null;
+        if (stub instanceof RemoteStub) {
+            ref = ((RemoteStub) stub).getRef();
+        }
+        if (Proxy.isProxyClass(stub.getClass())) {
+            InvocationHandler ih = Proxy.getInvocationHandler(stub);
+            if (ih instanceof RemoteObjectInvocationHandler) {
+                ref = ((RemoteObjectInvocationHandler) ih).getRef();
+            }
+        }
+        // Check whether there is a stub already registered in the DGC
+        WeakReference<Remote> weakStub;
+        if ((weakStub = stubsCacheTable.get(stub)) != null) {
+            Remote cachedStub = weakStub.get();
+            if (cachedStub != null) {
+                checkLiveness(ref);
+                return cachedStub;
+            }
+        }
+        Pair<Endpoint, ObjID> data = activateReference(ref);
+        weakStub = unreferencedPoll.addToReferenceQueue(stub, data);
+        stubsCacheTable.put(stub, weakStub);
+        return stub;
+    }
+
+    /**
+     * Sends the first dirty for a received reference in order to get the
+     * appropiate lease time from the server, and then schedules the dirty call
+     * for lease renewal. If the first dirty message fails, a clean "strong"
+     * message is sent for that remote object. If the first dirty call
+     * succeeded, the reference becomes a "live" reference for the client DGC.
+     * 
+     * @param ref
+     *            The reference received inside the stub
+     * @return The <code>Endpoint / ObjID</code> pair contained inside the
+     *         reference
+     * @throws UnmarshalException
+     *             If the first dirty call fails
+     */
+    private final Pair<Endpoint, ObjID> activateReference(RemoteRef ref)
+            throws UnmarshalException {
+        // Get necessary data previously stored during RemoteRef
+        // deserialization.
+        Pair<Endpoint, ObjID> data = deserializedRemoteRefTable.get(ref);
+        if (data == null) {
+            throw new UnmarshalException(
+                    "Impossible to get a stub for this object.");
+        }
+        Lease lease = sendDirty(data.getFirst(),
+                new ObjID[] { data.getSecond() });
+
+        if (lease != null) {
+            enqueueDirtyCall(data, lease.getValue());
+            liveReferences.put(data, new Long(lease.getValue()));
+            return data;
+        } else {
+            sendClean(data.getFirst(), new ObjID[] { data.getSecond() }, true);
+            throw new UnmarshalException(
+                    "Impossible to get a stub for this object.");
+        }
+    }
+
+    /**
+     * Checks whether the received reference is a "live" reference for the
+     * client garbage collector. The client DGC sends dirties for all "live"
+     * references in order to renew the lease with the remote server. If the DGC
+     * is not sending dirties for a reference (because of persistent network
+     * problems, for instance) that reference is no longer considered "live". If
+     * the received reference is not "live", the method
+     * <code>activateReference</code> will be called in order to restart the
+     * lease renewal process.
+     * 
+     * @param ref
+     *            The reference to be tested
+     */
+    public synchronized final void checkLiveness(RemoteRef ref) {
+        Pair<Endpoint, ObjID> dataRef = deserializedRemoteRefTable.get(ref);
+        if (liveReferences.containsKey(dataRef)) {
+            return;
+        }
+        try {
+            activateReference(ref);
+        } catch (UnmarshalException e) {
+            // An Exception was thrown trying to bring the reference back to
+            // life
+        }
+    }
+
+    /**
+     * Schedules a dirty call to be sent periodically. The dirty call will be
+     * sent every <code>period</code> / 2 milliseconds.
+     * 
+     * @param data
+     *            An <code>Endpoint / ObjID</code> pair representing a
+     *            reference.
+     * @param period
+     *            The lease period granted by the server.
+     */
+    void enqueueDirtyCall(Pair<Endpoint, ObjID> data, long period) {
+        synchronized (dirtyTaskTable) {
+            DirtyTask task = dirtyTaskTable.get(new Long(period));
+            if (task != null) {
+                task.scheduleDirty(data);
+            } else {
+                task = new DirtyTask(this, period, taskScheduler,
+                        dirtyTaskTable);
+                task.scheduleDirty(data);
+                taskScheduler.schedule(task, period / 2, period / 2);
+                dirtyTaskTable.put(new Long(period), task);
+            }
+        }
+    }
+
+    /**
+     * Removes the reference represented by the <code>Endpoint / ObjID</code>
+     * pair from the dirty calls scheduler. No more dirties will be sent for
+     * that reference, and the reference is erased from the "live" references
+     * internal table.
+     * 
+     * @param ep
+     *            The <code>Endpoint</code> of the remote reference.
+     * @param objID
+     *            The <code>ObjID</code> of the remote reference.
+     */
+    void cancelDirtyCall(Endpoint ep, ObjID objID) {
+        synchronized (dirtyTaskTable) {
+            Pair<Endpoint, ObjID> dataRef = new Pair<Endpoint, ObjID>(ep, objID);
+            Long period = liveReferences.get(dataRef);
+            DirtyTask task = dirtyTaskTable.get(period);
+            if (task != null) {
+                task.cancelDirty(ep, objID);
+                if (task.isEmpty()) {
+                    task.cancel();
+                    dirtyTaskTable.remove(period);
+                    /* SEE DISCLAIMER */
+                    //taskScheduler.purge();
+                }
+            }
+            liveReferences.remove(dataRef);
+        }
+    }
+
+    /**
+     * Removes the reference represented by the <code>Endpoint / ObjID</code>
+     * pair from the "live" references internal table.
+     * 
+     * @param dataRef
+     *            The <code>Endpoint / ObjID</code> pair representing the
+     *            reference
+     */
+    void removeFromLiveReferences(Pair<Endpoint, ObjID> dataRef) {
+        liveReferences.remove(dataRef);
+    }
+
+    /**
+     * Checks whether the reference represented by the
+     * <code>Endpoint / ObjID</code> pair is a "live" reference. The client
+     * DGC sends dirties for all "live" references in order to renew the lease
+     * with the remote server.
+     * 
+     * @param dataRef
+     *            An <code>Endpoint / ObjID</code> pair representing a
+     *            reference
+     * @return true if the received pair is a "live" reference
+     */
+    boolean isLiveReference(Pair<Endpoint, ObjID> dataRef) {
+        return liveReferences.containsKey(dataRef);
+    }
+
+    /**
+     * Sends a clean call to the DGC of the remote server.
+     * 
+     * @param ep
+     *            The <code>Endpoint</code> where the clean call will be sent.
+     * @param obj
+     *            An array containing the object identifiers that will be sent
+     *            in the clean call.
+     * @param strong
+     *            The flag that indicates a 'strong' clean call
+     */
+    void sendClean(Endpoint ep, ObjID[] obj, boolean strong) {
+    	synchronized(dgcObjID) { 
+	        Object[] args = new Object[] { obj, ++sequenceNumber, vmID, strong };
+	        TransportManager tm = TransportManager.getTransportManager();
+	        try {
+	            tm.invoke(dgcObjID, ep, args, SEND_CLEAN_OP_NUM, false);
+	        } catch (Exception e) {
+	            // The clean call has failed.
+	        }
+    	}
+    }
+
+    /**
+     * Sends a dirty call to the DGC of the remote server, and returns the
+     * <code>Lease</code> granted by that DGC.
+     * 
+     * @param ep
+     *            The <code>Endpoint</code> where the dirty call will be sent.
+     * @param obj
+     *            An array containing the object identifiers that will be sent
+     *            in the dirty call.
+     * @return The <code>Lease</code> returned from the server DGC, or
+     *         <code>null</code> if the call has failed.
+     */
+    Lease sendDirty(Endpoint ep, ObjID[] obj) {
+    	synchronized(dgcObjID) { 
+	        Lease lease = new Lease(vmID, leaseValue);
+	        Object[] args = new Object[] { obj, ++sequenceNumber, lease };
+	        TransportManager tm = TransportManager.getTransportManager();
+	        Object response;
+	        try {
+	            response = tm.invoke(dgcObjID, ep, args, SEND_DIRTY_OP_NUM, true);
+	            if (response instanceof Lease) {
+	                if (vmID == null) {
+	                    vmID = ((Lease) response).getVMID();
+	                }
+	                return (Lease) response;
+	            }
+	            return null;
+	        } catch (Exception e) {
+	            return null;
+	        }
+    	}
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCQueuePoll.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCQueuePoll.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCQueuePoll.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DGCQueuePoll.java Thu May 18 23:00:52 2006
@@ -1,153 +1,153 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  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 ar.org.fitc.rmi.dgc.client;
-
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.rmi.Remote;
-import java.rmi.server.ObjID;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import ar.org.fitc.rmi.transport.Endpoint;
-import ar.org.fitc.rmi.utils.Pair;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This class sends the corresponding "clean" call to the remote server’s
- * garbage collector when a stub with a "live" reference is collected by the
- * local garbage collector.
- * 
- * @author Gonzalo Ortega
- * 
- */
-final class DGCQueuePoll extends Thread {
-
-    private ReferenceQueue<Remote> stubsQueue;
-
-    private Map<WeakReference, Pair<Endpoint, ObjID>> referenceDataTable;
-
-    private DGCClient dgc;
-
-    private Map<Endpoint, ArrayList<ObjID>> queuedCleanCalls;
-
-    /**
-     * Creates a new instance of <code>DGCQueuePoll</code>.
-     * 
-     * @param cdgc
-     *            The client garbage collector which has instantiated this
-     *            class.
-     */
-    public DGCQueuePoll(DGCClient cdgc) {
-        stubsQueue = new ReferenceQueue<Remote>();
-//        referenceDataTable = new Hashtable<WeakReference, Pair<Endpoint, ObjID>>();
-        referenceDataTable = new Hashtable<WeakReference, Pair<Endpoint, ObjID>>();
-        queuedCleanCalls = new HashMap<Endpoint, ArrayList<ObjID>>();
-        dgc = cdgc;
-    }
-
-    /**
-     * Adds a stub to the internal reference queue, in order to be detected when
-     * it is garbage collected by the local garbage collector.
-     * 
-     * @param stub
-     *            The stub that the clean call will be sent for.
-     * @param data
-     *            The <code>Endpoint / ObjID</code> pair representing the
-     *            internal data of the remote reference contained inside the
-     *            stub.
-     * @return A weak reference to the stub.
-     */
-    public final WeakReference<Remote> addToReferenceQueue(Remote stub,
-            Pair<Endpoint, ObjID> data) {
-        WeakReference<Remote> weakStub;
-        weakStub = new WeakReference<Remote>(stub, stubsQueue);
-        referenceDataTable.put(weakStub, data);
-        return weakStub;
-    }
-
-    /**
-     * Waits for the local garbage collector to collect a stub, and then removes
-     * the reference corresponding to that stub from the Client DGC's "live"
-     * references table, stops sending dirty calls for that reference, and sends
-     * a clean call for that reference to te remote server's garbage collector.
-     * 
-     */
-    @SuppressWarnings("unchecked")
-    public final void run() {
-        while (true) {
-            try {
-                WeakReference<Remote> remove = (WeakReference<Remote>) stubsQueue
-                        .remove();
-                do {
-                    Pair<Endpoint, ObjID> data = referenceDataTable.get(remove);
-                    if (dgc.isLiveReference(data)) {
-                        dgc.cancelDirtyCall(data.getFirst(), data.getSecond());
-                        enqueueCleanCall(data.getFirst(), data.getSecond());
-                    }
-                    referenceDataTable.remove(remove);
-                } while ((remove = (WeakReference<Remote>) stubsQueue.poll()) 
-                        != null);
-                sendQueuedCalls();
-            } catch (InterruptedException e) {
-            }
-        }
-    }
-
-    /**
-     * Groups the clean calls to be sent by <code>Endpoint</code>, in order
-     * to send only one clean call for all the objects exported in the same
-     * <code>Endpoint</code>.
-     * 
-     * @param ep
-     *            The <code>Endpoint</code> of the reference.
-     * @param objID
-     *            The <code>ObjID</code> of the reference.
-     */
-    private final void enqueueCleanCall(Endpoint ep, ObjID objID) {
-        ArrayList<ObjID> objIDList;
-        objIDList = queuedCleanCalls.get(ep);
-        if (objIDList == null) {
-            objIDList = new ArrayList<ObjID>();
-            queuedCleanCalls.put(ep, objIDList);
-        }
-        objIDList.add(objID);
-    }
-
-    /**
-     * Sends all the grouped clean calls to the remote server's garbage
-     * collector.
-     */
-    private final void sendQueuedCalls() {
-        if (!queuedCleanCalls.isEmpty()) {
-            ArrayList<ObjID> objIDList;
-            for (Endpoint ep : queuedCleanCalls.keySet()) {
-                objIDList = queuedCleanCalls.get(ep);
-                ObjID[] objArray = new ObjID[objIDList.size()];
-                objIDList.toArray(objArray);
-                dgc.sendClean(ep, objArray, false);
-            }
-            queuedCleanCalls.clear();
-        }
-    }
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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.harmony.rmi.internal.dgc.client;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.rmi.Remote;
+import java.rmi.server.ObjID;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.harmony.rmi.internal.transport.Endpoint;
+import org.apache.harmony.rmi.internal.utils.Pair;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This class sends the corresponding "clean" call to the remote server’s
+ * garbage collector when a stub with a "live" reference is collected by the
+ * local garbage collector.
+ * 
+ * @author Gonzalo Ortega
+ * 
+ */
+final class DGCQueuePoll extends Thread {
+
+    private ReferenceQueue<Remote> stubsQueue;
+
+    private Map<WeakReference, Pair<Endpoint, ObjID>> referenceDataTable;
+
+    private DGCClient dgc;
+
+    private Map<Endpoint, ArrayList<ObjID>> queuedCleanCalls;
+
+    /**
+     * Creates a new instance of <code>DGCQueuePoll</code>.
+     * 
+     * @param cdgc
+     *            The client garbage collector which has instantiated this
+     *            class.
+     */
+    public DGCQueuePoll(DGCClient cdgc) {
+        stubsQueue = new ReferenceQueue<Remote>();
+//        referenceDataTable = new Hashtable<WeakReference, Pair<Endpoint, ObjID>>();
+        referenceDataTable = new Hashtable<WeakReference, Pair<Endpoint, ObjID>>();
+        queuedCleanCalls = new HashMap<Endpoint, ArrayList<ObjID>>();
+        dgc = cdgc;
+    }
+
+    /**
+     * Adds a stub to the internal reference queue, in order to be detected when
+     * it is garbage collected by the local garbage collector.
+     * 
+     * @param stub
+     *            The stub that the clean call will be sent for.
+     * @param data
+     *            The <code>Endpoint / ObjID</code> pair representing the
+     *            internal data of the remote reference contained inside the
+     *            stub.
+     * @return A weak reference to the stub.
+     */
+    public final WeakReference<Remote> addToReferenceQueue(Remote stub,
+            Pair<Endpoint, ObjID> data) {
+        WeakReference<Remote> weakStub;
+        weakStub = new WeakReference<Remote>(stub, stubsQueue);
+        referenceDataTable.put(weakStub, data);
+        return weakStub;
+    }
+
+    /**
+     * Waits for the local garbage collector to collect a stub, and then removes
+     * the reference corresponding to that stub from the Client DGC's "live"
+     * references table, stops sending dirty calls for that reference, and sends
+     * a clean call for that reference to te remote server's garbage collector.
+     * 
+     */
+    @SuppressWarnings("unchecked")
+    public final void run() {
+        while (true) {
+            try {
+                WeakReference<Remote> remove = (WeakReference<Remote>) stubsQueue
+                        .remove();
+                do {
+                    Pair<Endpoint, ObjID> data = referenceDataTable.get(remove);
+                    if (dgc.isLiveReference(data)) {
+                        dgc.cancelDirtyCall(data.getFirst(), data.getSecond());
+                        enqueueCleanCall(data.getFirst(), data.getSecond());
+                    }
+                    referenceDataTable.remove(remove);
+                } while ((remove = (WeakReference<Remote>) stubsQueue.poll()) 
+                        != null);
+                sendQueuedCalls();
+            } catch (InterruptedException e) {
+            }
+        }
+    }
+
+    /**
+     * Groups the clean calls to be sent by <code>Endpoint</code>, in order
+     * to send only one clean call for all the objects exported in the same
+     * <code>Endpoint</code>.
+     * 
+     * @param ep
+     *            The <code>Endpoint</code> of the reference.
+     * @param objID
+     *            The <code>ObjID</code> of the reference.
+     */
+    private final void enqueueCleanCall(Endpoint ep, ObjID objID) {
+        ArrayList<ObjID> objIDList;
+        objIDList = queuedCleanCalls.get(ep);
+        if (objIDList == null) {
+            objIDList = new ArrayList<ObjID>();
+            queuedCleanCalls.put(ep, objIDList);
+        }
+        objIDList.add(objID);
+    }
+
+    /**
+     * Sends all the grouped clean calls to the remote server's garbage
+     * collector.
+     */
+    private final void sendQueuedCalls() {
+        if (!queuedCleanCalls.isEmpty()) {
+            ArrayList<ObjID> objIDList;
+            for (Endpoint ep : queuedCleanCalls.keySet()) {
+                objIDList = queuedCleanCalls.get(ep);
+                ObjID[] objArray = new ObjID[objIDList.size()];
+                objIDList.toArray(objArray);
+                dgc.sendClean(ep, objArray, false);
+            }
+            queuedCleanCalls.clear();
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DirtyRetryTask.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DirtyRetryTask.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DirtyRetryTask.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/dgc/client/DirtyRetryTask.java Thu May 18 23:00:52 2006
@@ -1,116 +1,116 @@
-/* 
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
- * 
- *  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 ar.org.fitc.rmi.dgc.client;
-
-import java.rmi.server.ObjID;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import ar.org.fitc.rmi.transport.Endpoint;
-import ar.org.fitc.rmi.utils.Pair;
-
-/**
- * When scheduled dirty calls fail, the dirty retry process uses instances of
- * this class to attempt to get a lease from the server. A <code>Timer</code>
- * should run this task in order to send the dirties for renewing the leases
- * periodically.
- * 
- * @author Gonzalo Ortega
- * 
- */
-final class DirtyRetryTask extends TimerTask {
-
-	private DGCClient dgc;
-
-	private long originalPeriod;
-
-	private Timer taskScheduler;
-
-	private Endpoint ep;
-
-	private ObjID[] objIDs;
-
-	private int retryNumber;
-
-	private static final int retriesAllowed = 4;
-
-	/**
-	 * Creates a new instance of <code>DirtyRetryTask</code>.
-	 * 
-	 * @param dgc
-	 *            The client DGC.
-	 * @param period
-	 *            The original period in milliseconds of the lease granted to
-	 *            the references grouped in the <code>DirtyTask</code> wich
-	 *            has isntantiated this task.
-	 * @param taskScheduler
-	 *            The <code>Timer</code> object which will run this scheduled
-	 *            <code>DirtyTask</code>.
-	 * @param ep
-	 *            The <code>Endpoint</code> of the references grouped in the
-	 *            failed dirty call.
-	 * @param objIDs
-	 *            The <code>ObjID</code> of the references drouped in the
-	 *            failed dirty call.
-	 * @param retryNumber
-	 *            The number of times the dirty call has been retried.
-	 */
-	public DirtyRetryTask(DGCClient dgc, long period, Timer taskScheduler,
-			Endpoint ep, ObjID[] objIDs, int retryNumber) {
-		this.dgc = dgc;
-		this.originalPeriod = period;
-		this.taskScheduler = taskScheduler;
-		this.ep = ep;
-		this.objIDs = objIDs;
-		this.retryNumber = ++retryNumber;
-	}
-
-	/**
-	 * This <code>DirtyRetryTask</code> will try to re-send the dirty call to
-	 * the detination <code>Endpoint</code>. If this dirty call success, the
-	 * references will be re-scheduled for normal lease renewal. If the dirty
-	 * call fails, a new <code>DirtyRetryTask</code> will be scheduled with an
-	 * exponential delay time for a new retry. If four retry attempts have been
-	 * made and the retry call still hasn't succeeded, no more dirties for those
-	 * references will be sent. The references will be removed from the DGC
-	 * "live" references table and a clean "strong" call will be sent to the
-	 * remote server's DGC.
-	 */
-	@Override
-	public final void run() {
-		if (dgc.sendDirty(ep, objIDs) != null) {
-			for (ObjID objID : objIDs) {
-				dgc.enqueueDirtyCall(new Pair<Endpoint, ObjID>(ep, objID),
-						originalPeriod);
-			}
-		} else {
-			if (retryNumber < retriesAllowed) {
-				DirtyRetryTask retryTask = new DirtyRetryTask(dgc,
-						originalPeriod, taskScheduler, ep, objIDs, retryNumber);
-				taskScheduler.schedule(retryTask, Double.valueOf(
-						(Math.pow(2, retryNumber))).longValue() * 1000);
-			} else {
-				// Giving up on dirties. Sending clean strong call for the
-				// references.
-				for (ObjID objID : objIDs) {
-					dgc.removeFromLiveReferences(new Pair<Endpoint, ObjID>(ep,
-							objID));
-				}
-				dgc.sendClean(ep, objIDs, true);
-			}
-		}
-	}
-}
+/* 
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+ * 
+ *  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.harmony.rmi.internal.dgc.client;
+
+import java.rmi.server.ObjID;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.harmony.rmi.internal.transport.Endpoint;
+import org.apache.harmony.rmi.internal.utils.Pair;
+
+/**
+ * When scheduled dirty calls fail, the dirty retry process uses instances of
+ * this class to attempt to get a lease from the server. A <code>Timer</code>
+ * should run this task in order to send the dirties for renewing the leases
+ * periodically.
+ * 
+ * @author Gonzalo Ortega
+ * 
+ */
+final class DirtyRetryTask extends TimerTask {
+
+	private DGCClient dgc;
+
+	private long originalPeriod;
+
+	private Timer taskScheduler;
+
+	private Endpoint ep;
+
+	private ObjID[] objIDs;
+
+	private int retryNumber;
+
+	private static final int retriesAllowed = 4;
+
+	/**
+	 * Creates a new instance of <code>DirtyRetryTask</code>.
+	 * 
+	 * @param dgc
+	 *            The client DGC.
+	 * @param period
+	 *            The original period in milliseconds of the lease granted to
+	 *            the references grouped in the <code>DirtyTask</code> wich
+	 *            has isntantiated this task.
+	 * @param taskScheduler
+	 *            The <code>Timer</code> object which will run this scheduled
+	 *            <code>DirtyTask</code>.
+	 * @param ep
+	 *            The <code>Endpoint</code> of the references grouped in the
+	 *            failed dirty call.
+	 * @param objIDs
+	 *            The <code>ObjID</code> of the references drouped in the
+	 *            failed dirty call.
+	 * @param retryNumber
+	 *            The number of times the dirty call has been retried.
+	 */
+	public DirtyRetryTask(DGCClient dgc, long period, Timer taskScheduler,
+			Endpoint ep, ObjID[] objIDs, int retryNumber) {
+		this.dgc = dgc;
+		this.originalPeriod = period;
+		this.taskScheduler = taskScheduler;
+		this.ep = ep;
+		this.objIDs = objIDs;
+		this.retryNumber = ++retryNumber;
+	}
+
+	/**
+	 * This <code>DirtyRetryTask</code> will try to re-send the dirty call to
+	 * the detination <code>Endpoint</code>. If this dirty call success, the
+	 * references will be re-scheduled for normal lease renewal. If the dirty
+	 * call fails, a new <code>DirtyRetryTask</code> will be scheduled with an
+	 * exponential delay time for a new retry. If four retry attempts have been
+	 * made and the retry call still hasn't succeeded, no more dirties for those
+	 * references will be sent. The references will be removed from the DGC
+	 * "live" references table and a clean "strong" call will be sent to the
+	 * remote server's DGC.
+	 */
+	@Override
+	public final void run() {
+		if (dgc.sendDirty(ep, objIDs) != null) {
+			for (ObjID objID : objIDs) {
+				dgc.enqueueDirtyCall(new Pair<Endpoint, ObjID>(ep, objID),
+						originalPeriod);
+			}
+		} else {
+			if (retryNumber < retriesAllowed) {
+				DirtyRetryTask retryTask = new DirtyRetryTask(dgc,
+						originalPeriod, taskScheduler, ep, objIDs, retryNumber);
+				taskScheduler.schedule(retryTask, Double.valueOf(
+						(Math.pow(2, retryNumber))).longValue() * 1000);
+			} else {
+				// Giving up on dirties. Sending clean strong call for the
+				// references.
+				for (ObjID objID : objIDs) {
+					dgc.removeFromLiveReferences(new Pair<Endpoint, ObjID>(ep,
+							objID));
+				}
+				dgc.sendClean(ep, objIDs, true);
+			}
+		}
+	}
+}