From 63f5926a4f85a4c5f4c8349a7d5bc985badd503f Mon Sep 17 00:00:00 2001 From: Audrius Meskauskas Date: Fri, 24 Mar 2006 17:40:24 +0000 Subject: 2006-03-24 Audrius Meskauskas * gnu/java/rmi/activation/ActivationSystemTransient.java: Inherit from Activator. 2006-03-24 Audrius Meskauskas * 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. --- .../rmi/activation/DefaultActivationSystem.java | 75 ++++++++++++++++++++-- 1 file changed, 68 insertions(+), 7 deletions(-) (limited to 'gnu/java/rmi/activation/DefaultActivationSystem.java') 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; + } } -- cgit v1.2.1