summaryrefslogtreecommitdiff
path: root/java/rmi
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-03-05 11:38:08 +0000
committerMark Wielaard <mark@klomp.org>2006-03-05 11:38:08 +0000
commit151c7439c5d7ca440f17b408ea9e2b750cd42543 (patch)
treee6eb1ec4bfeaa33e1a3936edd8c9b5d2dd862dfd /java/rmi
parentcb35a91377f1dc2d7b1b5bc4c70ab91cbb36506f (diff)
downloadclasspath-151c7439c5d7ca440f17b408ea9e2b750cd42543.tar.gz
* configure.ac (VERSION): Set to 0.90-pre-generics.
* Merge with CVS trunk from classpath-0_90-branch-point.
Diffstat (limited to 'java/rmi')
-rw-r--r--java/rmi/dgc/DGC.java39
-rw-r--r--java/rmi/dgc/Lease.java69
-rw-r--r--java/rmi/server/RMIClassLoader.java30
3 files changed, 113 insertions, 25 deletions
diff --git a/java/rmi/dgc/DGC.java b/java/rmi/dgc/DGC.java
index e78ec2a3a..66bfc6dfd 100644
--- a/java/rmi/dgc/DGC.java
+++ b/java/rmi/dgc/DGC.java
@@ -41,11 +41,40 @@ import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.ObjID;
-public interface DGC extends Remote
+/**
+ * The DGC implementation is used for the server side during the distributed
+ * garbage collection. This interface contains the two methods: dirty and clean.
+ * A dirty call is made when a remote reference is unmarshaled in a client. A
+ * corresponding clean call is made by client it no longer uses that remote
+ * reference. A reference to a remote object is also automatically released
+ * after so called lease period that starts after the dirty call is received. It
+ * is the client's responsibility to renew the leases, by making additional
+ * dirty calls before such leases expire.
+ */
+public interface DGC
+ extends Remote
{
- Lease dirty (ObjID[] ids, long sequenceNum, Lease lease)
- throws RemoteException;
+ /**
+ * Mark the given objects referecnes as used on the client side.
+ *
+ * @param ids the ids of the used objects.
+ * @param sequenceNum the number of the call (used to detect and discard late
+ * calls).
+ * @param lease the requested lease
+ * @return the granted lease
+ */
+ Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
+ throws RemoteException;
- void clean (ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
- throws RemoteException;
+ /**
+ * Mark the given objects as no longer used on the client side.
+ *
+ * @param ids the ids of the objects that are no longer used.
+ * @param sequenceNum the number of the call (used to detect and discard late
+ * @param vmid the VMID of the client.
+ * @param strong make the "strong" clean call ("strong" calls are scheduled
+ * after the failed dirty calls).
+ */
+ void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
+ throws RemoteException;
}
diff --git a/java/rmi/dgc/Lease.java b/java/rmi/dgc/Lease.java
index d3d7f6952..36ff12ad2 100644
--- a/java/rmi/dgc/Lease.java
+++ b/java/rmi/dgc/Lease.java
@@ -1,5 +1,6 @@
/* Lease.java
Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +8,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -39,29 +40,61 @@ package java.rmi.dgc;
import java.io.Serializable;
+/**
+ * A lease object is used to request and grant leases for the remote objects. It
+ * contains the lease duration and the unique VM indentifier.
+ */
public final class Lease
- implements Serializable {
+ implements Serializable
+{
-static final long serialVersionUID = -5713411624328831948L;
+ static final long serialVersionUID = - 5713411624328831948L;
-private VMID vmid;
-private long value;
+ private VMID vmid;
-public Lease(VMID id, long duration) {
- vmid = id;
- value = duration;
-}
+ private long value;
-public VMID getVMID() {
- return (vmid);
-}
+ /**
+ * Create the new lease with the given id and duration
+ *
+ * @param id the lease id
+ * @param duration the lease duration
+ */
+ public Lease(VMID id, long duration)
+ {
+ vmid = id;
+ value = duration;
+ }
-public long getValue() {
- return (value);
-}
+ /**
+ * Get the lease id.
+ *
+ * @return the lease id
+ */
+ public VMID getVMID()
+ {
+ return (vmid);
+ }
-public String toString() {
- return ("[" + vmid.toString() + ", " + Long.toString(value) + "]");
-}
+ /**
+ * Get the lease duration
+ *
+ * @return the lease duration
+ */
+ public long getValue()
+ {
+ return (value);
+ }
+
+ /**
+ * Get the string representation of this lease
+ *
+ * @return the string represenation (lease id, followed by the lease
+ * duration).
+ */
+ public String toString()
+ {
+ return ("[" + vmid.toString() + ", " + Long.toString(value) + "]");
+ }
}
diff --git a/java/rmi/server/RMIClassLoader.java b/java/rmi/server/RMIClassLoader.java
index 21dd19b0c..1998f1fcf 100644
--- a/java/rmi/server/RMIClassLoader.java
+++ b/java/rmi/server/RMIClassLoader.java
@@ -38,10 +38,13 @@ exception statement from your version. */
package java.rmi.server;
+import gnu.classpath.ServiceFactory;
+import gnu.classpath.SystemProperties;
import gnu.java.rmi.server.RMIClassLoaderImpl;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Iterator;
/**
* This class provides a set of public static utility methods for supporting
@@ -85,6 +88,16 @@ public class RMIClassLoader
return spi.loadClass(codebase, name, defaultLoader);
}
+ public static Class loadProxyClass (String codeBase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadProxyClass(codeBase, interfaces, defaultLoader);
+ }
+
/**
* Loads a class from <code>codeBase</code>.
*
@@ -172,7 +185,20 @@ public class RMIClassLoader
*/
private static RMIClassLoaderSpi getProviderInstance()
{
- // TODO: Do something more useful here.
- return null;
+ // If the user asked for the default, return it. We do a special
+ // check here because our standard service lookup function does not
+ // handle this -- nor should it.
+ String prop = SystemProperties.getProperty("java.rmi.server.RMIClassLoaderSpi");
+ if ("default".equals(prop))
+ return null;
+ Iterator it = ServiceFactory.lookupProviders(RMIClassLoaderSpi.class,
+ null);
+ if (it == null || ! it.hasNext())
+ return null;
+ // FIXME: the spec says we ought to throw an Error of some kind if
+ // the specified provider is not suitable for some reason. However
+ // our service factory simply logs the problem and moves on to the next
+ // provider in this situation.
+ return (RMIClassLoaderSpi) it.next();
}
}