diff options
| author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2006-03-24 17:40:24 +0000 |
|---|---|---|
| committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2006-03-24 17:40:24 +0000 |
| commit | 63f5926a4f85a4c5f4c8349a7d5bc985badd503f (patch) | |
| tree | e459cef953f7bdc2a4d995b04143b2bcac9ff478 /gnu/java | |
| parent | f370efa1358a912b3c57e4bce650babbebd59269 (diff) | |
| download | classpath-63f5926a4f85a4c5f4c8349a7d5bc985badd503f.tar.gz | |
2006-03-24 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* gnu/java/rmi/activation/ActivationSystemTransient.java:
Inherit from Activator.
2006-03-24 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* gnu/java/rmi/activation/DefaultActivationGroup.java (newInstance):
Print debug message if debug flag is set.
* gnu/java/rmi/activation/DefaultActivationSystem.java: Rewritten.
* gnu/java/rmi/server/ActivatableServerRef.java (activate): assign
detail, do not call iniCause(). (exportClass): New method.
* gnu/java/rmi/server/CombinedClassLoader.java (constructor):
Ignore null (bootstrap) class loader.
* gnu/java/rmi/server/UnicastServerRef.java (methods, skel, stub,
buildMethodHash, findStubSkelClass, getHelperClass): Changed
visibility to protected.
* java/rmi/activation/Activatable.java (export, register): Rewritten.
(toStub): New method.
* java/rmi/activation/ActivationGroup.java (getSystem): Rewritten.
* java/rmi/activation/ActivationSystem.java (SYSTEM_PORT):
Explained property java.rmi.activation.port.
Applying two patches toghether because the intermediate version does not build.
Diffstat (limited to 'gnu/java')
| -rw-r--r-- | gnu/java/rmi/activation/ActivationSystemTransient.java | 3 | ||||
| -rw-r--r-- | gnu/java/rmi/activation/DefaultActivationGroup.java | 3 | ||||
| -rw-r--r-- | gnu/java/rmi/activation/DefaultActivationSystem.java | 75 | ||||
| -rw-r--r-- | gnu/java/rmi/server/ActivatableServerRef.java | 54 | ||||
| -rw-r--r-- | gnu/java/rmi/server/CombinedClassLoader.java | 2 | ||||
| -rw-r--r-- | gnu/java/rmi/server/UnicastServerRef.java | 12 |
6 files changed, 133 insertions, 16 deletions
diff --git a/gnu/java/rmi/activation/ActivationSystemTransient.java b/gnu/java/rmi/activation/ActivationSystemTransient.java index 3ef5685a5..ea31e4bdf 100644 --- a/gnu/java/rmi/activation/ActivationSystemTransient.java +++ b/gnu/java/rmi/activation/ActivationSystemTransient.java @@ -49,6 +49,7 @@ import java.rmi.activation.ActivationID; import java.rmi.activation.ActivationInstantiator; import java.rmi.activation.ActivationMonitor; import java.rmi.activation.ActivationSystem; +import java.rmi.activation.Activator; import java.rmi.activation.UnknownGroupException; import java.rmi.activation.UnknownObjectException; import java.util.HashMap; @@ -63,7 +64,7 @@ import java.util.Map; */ public class ActivationSystemTransient extends DefaultActivationSystem - implements ActivationSystem, ActivationMonitor + implements ActivationSystem, ActivationMonitor, Activator { /** * Maps group identifiers into group descriptions. diff --git a/gnu/java/rmi/activation/DefaultActivationGroup.java b/gnu/java/rmi/activation/DefaultActivationGroup.java index 95c5a4139..dc2a3221a 100644 --- a/gnu/java/rmi/activation/DefaultActivationGroup.java +++ b/gnu/java/rmi/activation/DefaultActivationGroup.java @@ -120,6 +120,9 @@ public class DefaultActivationGroup { try { + if (ActivationSystemTransient.debug) + System.out.println("Instantiating "+desc.getClassName()); + Remote object; Class objectClass; diff --git a/gnu/java/rmi/activation/DefaultActivationSystem.java b/gnu/java/rmi/activation/DefaultActivationSystem.java index 75fb45160..754b5dcb9 100644 --- a/gnu/java/rmi/activation/DefaultActivationSystem.java +++ b/gnu/java/rmi/activation/DefaultActivationSystem.java @@ -39,19 +39,80 @@ exception statement from your version. */ package gnu.java.rmi.activation; import java.rmi.activation.ActivationSystem; -import java.rmi.activation.Activator; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; /** - * The default activation system for this jre. + * Finds and returns the default activation system for this jre. * - * @author Audrius Meskauskas (audriusa@bioinformatics.org) + * @author Audrius Meskauskas (audriusa@bioinformatics.org) */ public abstract class DefaultActivationSystem - implements ActivationSystem, Activator { /** - * The singleton instance of the default activation system. + * The activation system (assigned if once found). */ - public static final ActivationSystem singleton - = ActivationSystemTransient.getInstance(); + static ActivationSystem system; + + /** + * The default activation registry port. + */ + static int ACTIVATION_REGISTRY_PORT; + + /** + * The name of the activation system registry port property. + */ + static String AS_PORT_PROPERTY = "java.rmi.activation.port"; + + /** + * The defalut name of the activation system in the activation registry. + */ + static String ACTIVATION_SYSTEM_NAME = "java.rmi.activation.ActivationSystem"; + + /** + * Get the activation system, default for this jre. If no external activation + * system exists, the internal activation system will be activated. This + * internal system is limited in capabilities and should be used exclusively + * for automated testing, to avoid necessity of starting rmi daemon during + * testing process. + */ + public static ActivationSystem get() + { + if (system == null) + try + { + // Obtain the port: + String asr = System.getProperty("java.rmi.activation.port"); + + if (asr != null) + { + try + { + ACTIVATION_REGISTRY_PORT = Integer.parseInt(asr); + if (ACTIVATION_REGISTRY_PORT <= 0) + throw new InternalError("Invalid " + asr + " value, " + + ACTIVATION_REGISTRY_PORT); + } + catch (NumberFormatException e) + { + throw new InternalError("Unable to parse " + asr + + " to integer"); + } + } + else + ACTIVATION_REGISTRY_PORT = ActivationSystem.SYSTEM_PORT; + + // Expect the naming service running first. + // The local host may want to use the shared registry + Registry r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT); + ActivationSystem system = (ActivationSystem) r.lookup(ACTIVATION_SYSTEM_NAME); + return system; + } + catch (Exception ex) + { + system = ActivationSystemTransient.getInstance(); + } + + return system; + } } diff --git a/gnu/java/rmi/server/ActivatableServerRef.java b/gnu/java/rmi/server/ActivatableServerRef.java index 6463f40d2..d89e351d3 100644 --- a/gnu/java/rmi/server/ActivatableServerRef.java +++ b/gnu/java/rmi/server/ActivatableServerRef.java @@ -43,6 +43,8 @@ import java.rmi.RemoteException; import java.rmi.activation.ActivationID; import java.rmi.server.ObjID; import java.rmi.server.RMIServerSocketFactory; +import java.rmi.server.RemoteStub; +import java.rmi.server.Skeleton; /** * The activatable server reference works like UnicastServerReference, but it @@ -117,7 +119,7 @@ public class ActivatableServerRef extends UnicastServerRef catch (Exception exc) { RemoteException rx = new RemoteException("Activation failed."); - rx.initCause(exc); + rx.detail = exc; throw rx; } } @@ -143,4 +145,54 @@ public class ActivatableServerRef extends UnicastServerRef UnicastServer.registerActivatable(this); return r; } + + /** + * Export object and ensure it is present in the server activation table as + * well. + * + * @param aClass the class being exported, must implement Remote. + */ + public Remote exportClass(Class aClass) throws RemoteException + { + if (!Remote.class.isAssignableFrom(aClass)) + throw new InternalError(aClass.getName()+" must implement Remote"); + + String ignoreStubs; + + ClassLoader loader =aClass.getClassLoader(); + + // Stubs are always searched for the bootstrap classes that may have + // obsolete pattern and may still need also skeletons. + if (loader==null) + ignoreStubs = "false"; + else + ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses", + "false"); + + if (! ignoreStubs.equals("true")) + { + // Find and install the stub + Class cls = aClass; + + // where ist the _Stub? (check superclasses also) + Class expCls = expCls = findStubSkelClass(cls); + + if (expCls != null) + { + stub = (RemoteStub) getHelperClass(expCls, "_Stub"); + // Find and install the skeleton (if there is one) + skel = (Skeleton) getHelperClass(expCls, "_Skel"); + } + } + + if (stub == null) + stub = createProxyStub(aClass, this); + + // Build hash of methods which may be called. + buildMethodHash(aClass, true); + + UnicastServer.registerActivatable(this); + return stub; + } + } diff --git a/gnu/java/rmi/server/CombinedClassLoader.java b/gnu/java/rmi/server/CombinedClassLoader.java index efffda4c6..6225fb30b 100644 --- a/gnu/java/rmi/server/CombinedClassLoader.java +++ b/gnu/java/rmi/server/CombinedClassLoader.java @@ -77,7 +77,7 @@ public class CombinedClassLoader extends ClassLoader while (iter.hasNext()) { cl = iter.next(); - if (!sLoaders.contains(cl)) + if (cl!=null && !sLoaders.contains(cl)) sLoaders.add(cl); } diff --git a/gnu/java/rmi/server/UnicastServerRef.java b/gnu/java/rmi/server/UnicastServerRef.java index 237e6d94d..cd891a1aa 100644 --- a/gnu/java/rmi/server/UnicastServerRef.java +++ b/gnu/java/rmi/server/UnicastServerRef.java @@ -84,18 +84,18 @@ public class UnicastServerRef /** * The skeleton (if any), associated with the exported remote object. */ - private Skeleton skel; + protected Skeleton skel; /** * The stub, associated with the exported remote object (may be proxy class). */ - private Remote stub; + protected Remote stub; /** * The method table (RMI hash code to method) of the methods of the * exported object. */ - private Hashtable methods = new Hashtable(); + protected Hashtable methods = new Hashtable(); /** * Used by serialization. @@ -205,7 +205,7 @@ public class UnicastServerRef * * @return the class having stub defined, null if none. */ - private Class findStubSkelClass(Class startCls) + protected Class findStubSkelClass(Class startCls) { Class cls = startCls; @@ -245,7 +245,7 @@ public class UnicastServerRef * @return the instantiated instance of the helper class or null if the * helper class cannot be found or instantiated. */ - private Object getHelperClass(Class cls, String type) + protected Object getHelperClass(Class cls, String type) { try { @@ -313,7 +313,7 @@ public class UnicastServerRef * @param build if true, the class methods are added to the table. If * false, they are removed from the table. */ - private void buildMethodHash(Class cls, boolean build) + protected void buildMethodHash(Class cls, boolean build) { Method[] meths = cls.getMethods(); for (int i = 0; i < meths.length; i++) |
