harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r407625 [10/16] - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi3: ./ doc/ make/ src/ src/common/ src/common/javasrc/ src/common/javasrc/java/ src/common/javasrc/java/rmi/ src/common/javasrc/java/rmi/activation/ src/common/javasr...
Date Thu, 18 May 2006 20:01:30 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicStrings.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicStrings.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicStrings.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicStrings.java Thu May 18 13:01:22 2006
@@ -0,0 +1,281 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+
+/**
+ * This interface contains command line options and other textual constants
+ * for RMI Compiler.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+interface RmicStrings extends RmicConstants {
+
+    /**
+     * Options prefix character.
+     */
+    String optionPrefix = "-";
+
+    /**
+     * <code>-v1.1</code> option.
+     */
+    String optionV11 = optionPrefix + "v1.1";
+
+    /**
+     * <code>-v1.2</code> option.
+     */
+    String optionV12 = optionPrefix + "v1.2";
+
+    /**
+     * <code>-vcompat</code> option.
+     */
+    String optionVCompat = optionPrefix + "vcompat";
+
+    /**
+     * <code>-idl</code> option.
+     */
+    String optionIDL = optionPrefix + "idl";
+
+    /**
+     * <code>-iiop</code> option.
+     */
+    String optionIIOP = optionPrefix + "iiop";
+
+    /**
+     * <code>-source</code> option for Java Compiler.
+     */
+    String optionSource = optionPrefix + "source";
+
+    /**
+     * <code>-target</code> option.
+     */
+    String optionTarget = optionPrefix + "target";
+
+    /**
+     * <code>-keep</code> option.
+     */
+    String optionKeep = optionPrefix + "keep";
+
+    /**
+     * <code>-keepgenerated</code> option.
+     */
+    String optionKeepGenerated = optionPrefix + "keepgenerated";
+
+    /**
+     * <code>-always</code> option.
+     */
+    String optionAlways = optionPrefix + "always";
+
+    /**
+     * <code>-alwaysgenerate</code> option.
+     */
+    String optionAlwaysGenerate = optionPrefix + "alwaysgenerate";
+
+    /**
+     * <code>-factory</code> option.
+     */
+    String optionFactory = optionPrefix + "factory";
+
+    /**
+     * <code>-noValueMethods</code> option.
+     */
+    String optionNoValueMethods = optionPrefix + "noValueMethods";
+
+    /**
+     * <code>-nolocalstubs</code> option.
+     */
+    String optionNoLocalStubs = optionPrefix + "nolocalstubs";
+
+    /**
+     * <code>-poa</code> option.
+     */
+    String optionPOA = optionPrefix + "poa";
+
+    /**
+     * <code>-g</code> option.
+     */
+    String optionDebug = optionPrefix + 'g';
+
+    /**
+     * <code>-g:</code> option.
+     */
+    String optionDebugDetails = optionDebug + ':';
+
+    /**
+     * <code>-nowarn</code> option.
+     */
+    String optionNoWarnings = optionPrefix + "nowarn";
+
+    /**
+     * <code>-nowrite</code> option.
+     */
+    String optionNoWrite = optionPrefix + "nowrite";
+
+    /**
+     * <code>-verbose</code> option.
+     */
+    String optionVerbose = optionPrefix + "verbose";
+
+    /**
+     * <code>-depend</code> option.
+     */
+    String optionDepend = optionPrefix + "depend";
+
+    /**
+     * <code>-idlModule</code> option.
+     */
+    String optionIdlModule = optionPrefix + "idlModule";
+
+    /**
+     * <code>-idlFile</code> option.
+     */
+    String optionIdlFile = optionPrefix + "idlFile";
+
+    /**
+     * <code>-d</code> option.
+     */
+    String optionDestinationDir = optionPrefix + 'd';
+
+    /**
+     * <code>-classpath</code> option.
+     */
+    String optionClassPath = optionPrefix + "classpath";
+
+    /**
+     * <code>-cp</code> option.
+     */
+    String optionCP = optionPrefix + "cp";
+
+    /**
+     * <code>-bootclasspath</code> option.
+     */
+    String optionBootClassPath = optionPrefix + "bootclasspath";
+
+    /**
+     * <code>-extdirs</code> option.
+     */
+    String optionExtDirs = optionPrefix + "extdirs";
+
+    /**
+     * <code>-J</code> option.
+     */
+    String optionJava = optionPrefix + 'J';
+
+    /**
+     * <code>-X</code> option.
+     */
+    String optionX = optionPrefix + 'X';
+
+    /**
+     * RMI Compiler usage text.
+     */
+    String usageText = "Usage: rmic <options> <class names>" + EOLN
+            + EOLN + "Options:" + EOLN + "  " + optionV11 + "              "
+            + "Create stubs/skeletons for 1.1 stub protocol version only"
+            + EOLN + "  " + optionV12 + "              "
+            + "(default) Create stubs for 1.2 stub protocol version only"
+            + EOLN + "  " + optionVCompat + "           "
+            + "Create stubs/skeletons compatible with both v1.1 and v1.2"
+            + EOLN + EOLN + "  " + optionTarget + " <version>  "
+            + "Generate class files for the specified VM version"
+            + EOLN + EOLN + "  " + optionKeep + "              "
+            + "Do not delete generated source files" + EOLN + "  "
+            + optionKeepGenerated + "     (the same as \"" + optionKeep + "\")"
+            + EOLN + EOLN + "  " + optionDebug
+            + "                 Generate debug information" + EOLN + "  "
+            + optionNoWarnings + "            Do not notify about warnings"
+            + EOLN + "  " + optionNoWrite + "           "
+            + "Check run: do not write compiled classes" + EOLN + "  "
+            + optionVerbose + "           Print detailed compilation log"
+            + EOLN + EOLN + "  " + optionDestinationDir
+            + " <directory>         Target directory for generated files"
+            + EOLN + "  " + optionClassPath
+            + " <path>      Input class files location"
+            + EOLN + "  " + optionCP + " <path>             (the same as \""
+            + optionClassPath + "\")" + EOLN + "  " + optionBootClassPath
+            + " <path>  Override location of bootstrap class files"
+            + EOLN + "  " + optionExtDirs
+            + " <dirs>        Override location of installed extensions"
+            + EOLN + EOLN + "  " + optionJava
+            + "<JVM option>         Pass option to JVM"
+            + EOLN + "  " + optionX
+            + "<extended option>    Pass -X option to JVM";
+
+    /**
+     * Version error text.
+     */
+    String errorVersionText = "You should specify at most one of \""
+            + optionV11 + "\", \"" + optionV12 + "\" (default), \""
+            + optionVCompat + "\", \"" + optionIDL + "\", \"" + optionIIOP;
+
+    /**
+     * No option parameter error text.
+     */
+    String errorNeedParameterText = "Option %s requires a parameter";
+
+    /**
+     * No JVM option parameter error text.
+     */
+    String errorNeedJVMParameterText = "Option %s must be immediately "
+                                 + "(without a space) followed by a JVM option";
+
+    /**
+     * Need two parameters error text.
+     */
+    String errorNeedTwoParametersText = "Option %s requires two parameters";
+
+    /**
+     * Unknown option error text.
+     */
+    String errorUnknownOptionText = "Unknown option: %s";
+
+    /**
+     * No classes to compile error text.
+     */
+    String errorNoClassesText = "No classes to compile specified";
+
+    /**
+     * Unusable IDL/IIOP option error text.
+     */
+    String errorUnusableExceptIDL_IIOP = "Option %s must only be used with "
+                                         + optionIDL + " or " + optionIIOP;
+
+    /**
+     * Unusable IDL option error text.
+     */
+    String errorUnusableExceptIDL = "Option %s must only be used with "
+                                    + optionIDL;
+
+    /**
+     * Unusable IIOP option error text.
+     */
+    String errorUnusableExceptIIOP = "Option %s must only be used with "
+                                     + optionIIOP;
+
+    /**
+     * Warning about classpath.
+     */
+    String warningClassPathText = "%s is specified. For proper operation "
+            + "the same %s should be specified in VM arguments. "
+            + "This is a limitation of current RMIC implementation.";
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicStrings.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicUtil.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicUtil.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicUtil.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicUtil.java Thu May 18 13:01:22 2006
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+import java.io.File;
+
+import org.apache.harmony.rmi.common.RMIUtil;
+
+
+/**
+ * Utility functions for RMI compiler.
+ *
+ * This class cannot be instantiated.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+final class RmicUtil implements RmicConstants {
+
+    /**
+     * This class cannot be instantiated.
+     */
+    private RmicUtil() {}
+
+    /**
+     * Returns suitable name for a parameter based on its class name and number.
+     *
+     * @param   cls
+     *          Parameter class.
+     *
+     * @param   number
+     *          Parameter number.
+     *
+     * @return  Suitable name for a parameter.
+     */
+    static String getParameterName(Class cls, int number) {
+        StringBuffer buffer = new StringBuffer(paramPrefix);
+
+        while (cls.isArray()) {
+            buffer.append(arrayPrefix);
+            cls = cls.getComponentType();
+        }
+
+        buffer.append(RMIUtil.getShortName(cls) + '_' + number);
+
+        return buffer.toString();
+    }
+
+    /**
+     * Creates source code fragment for method parameter,
+     * wrapping primitive types into respective Object types.
+     *
+     * @param   cls
+     *          Parameter class.
+     *
+     * @param   varName
+     *          Parameter variable name.
+     *
+     * @return  Source code fragment for method parameter,
+     *          for Object types it's just <code>varName</code>,
+     *          for primitive types (e. g. <code>int</code>)
+     *          it's a string like this:
+     *          <code>"new java.lang.Integer(varName)"</code>.
+     */
+    static String getObjectParameterString(Class cls, String varName) {
+        return (cls.isPrimitive()
+                ? ("new " + RMIUtil.getWrappingClass(cls).getName()
+                + '(' + varName + ')') : varName);
+    }
+
+    /**
+     * Returns string with capitalized first letter.
+     *
+     * @param   str
+     *          String.
+     *
+     * @return  String with capitalized first letter,
+     *          or string itself if the string is empty.
+     */
+    static String firstLetterToUpperCase(String str) {
+        int length = str.length();
+
+        if (length < 1) {
+            return str;
+        }
+
+        char[] array = new char[length];
+        str.getChars(0, length, array, 0);
+        array[0] = Character.toUpperCase(array[0]);
+        return String.copyValueOf(array);
+    }
+
+    /**
+     * Returns name of the class with capitalized first letter
+     * for primitive classes and <code>Object</code> for non-primitive classes.
+     *
+     * @param   cls
+     *          Class.
+     *
+     * @return  Returns name of the class with capitalized first letter
+     *          for primitive classes and <code>Object</code> for non-primitive
+     *          classes.
+     */
+    static String getHandlingType(Class cls) {
+        return (cls.isPrimitive()
+                ? firstLetterToUpperCase(cls.getName()) : "Object");
+    }
+
+    /**
+     * Creates source code fragment for reading object from a stream,
+     * correctly handling primitive types.
+     *
+     * @param   cls
+     *          Class of object being read.
+     *
+     * @param   streamName
+     *          Name of stream to read variable from.
+     *
+     * @return  Source code fragment for reading object,
+     *          for Object class it's like
+     *          <code>"streamName.readObject()"</code>,
+     *          for other Object types (e. g. <code>Vector</code>)
+     *          it's a string like this:
+     *          <code>"(java.util.Vector) streamName.readObject()"</code>,
+     *          for primitive types (e. g. <code>int</code>)
+     *          it's a string like this:
+     *          <code>"streamName.readInt()"</code>.
+     */
+    static String getReadObjectString(Class cls, String streamName) {
+        // For primitive types, use respective special read method.
+        // For non-primitive types, use readObject() and cast (if not Object).
+        return (((!cls.isPrimitive() && (cls != Object.class))
+                ? ('(' + RMIUtil.getCanonicalName(cls) + ") ") : "")
+                + streamName + ".read" + getHandlingType(cls) + "()");
+    }
+
+    /**
+     * Creates source code fragment for writing object to a stream,
+     * correctly handling primitive types.
+     *
+     * @param   cls
+     *          Class of object to write.
+     *
+     * @param   varName
+     *          Name of the variable to write.
+     *
+     * @param   streamName
+     *          Name of stream to write variable to.
+     *
+     * @return  Source code fragment for writing object,
+     *          for object types it's like
+     *          <code>"streamName.writeObject(varName)"</code>,
+     *          for primitive types (e. g. <code>int</code>)
+     *          it's a string like this:
+     *          <code>"streamName.writeInt(varName)"</code>.
+     */
+    static String getWriteObjectString(Class cls, String varName,
+            String streamName) {
+        // For primitive types, use respective special write method.
+        // For non-primitive types, use writeObject().
+        return (streamName + ".write" + getHandlingType(cls)
+                + '(' + varName +')');
+    }
+
+    /**
+     * Creates source code fragment for return object,
+     * correctly de-wrapping primitive types.
+     *
+     * @param   cls
+     *          Return class.
+     *
+     * @param   varName
+     *          Return variable name.
+     *
+     * @return  Source code fragment for return object,
+     *          for {@link Object} class it's just <code>varName</code>,
+     *          for other Object types (e. g. <code>Vector</code>)
+     *          it's a string like this:
+     *          <code>"((java.util.Vector) varName)"</code>,
+     *          for primitive types (e. g. <code>int</code>)
+     *          it's a string like this:
+     *          <code>"((java.lang.Integer) varName).intValue()"</code>.
+     */
+    static String getReturnObjectString(Class cls, String varName) {
+        // For Object return type, do nothing.
+        if (cls == Object.class) {
+            return varName;
+        }
+
+        // For all other types, create the respective cast statement.
+        StringBuffer buffer = new StringBuffer("((");
+        buffer.append(RMIUtil.getCanonicalName(RMIUtil.getWrappingClass(cls)));
+        buffer.append(") " + varName + ')');
+
+        // For primitive types, include case to primitive type.
+        if (cls.isPrimitive()) {
+            buffer.append('.' + cls.getName() + "Value()");
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Creates a file object for a directory created basing on the specified
+     * base directory and the package name for subdirectory.
+     *
+     * @param   base
+     *          Base directory.
+     *
+     * @param   packageName
+     *          Package name (for subdirectory).
+     *
+     * @return  File object for a directoty like this:
+     *          <code>baseDir/my/java/package</code>.
+     *
+     * @throws  RMICompilerException
+     *          If directory cannot be created.
+     */
+    static File getPackageDir(String base, String packageName)
+            throws RMICompilerException {
+        File dir = new File(base, (packageName != null) ? packageName : "");
+
+        if (dir.exists() ? !dir.isDirectory() : !dir.mkdirs()) {
+            throw new RMICompilerException(
+                    "Can't create target directory: " + dir);
+        }
+
+        return dir;
+    }
+
+    /**
+     * Creates a file object for a file created basing on the specified
+     * directory and the name of file itself.
+     *
+     * @param   dir
+     *          Directory to create the file in.
+     *
+     * @param   fileName
+     *          Name of file itself.
+     *
+     * @return  File object for a file name like this:
+     *          <code>dir/fileName</code>.
+     *
+     * @throws  RMICompilerException
+     *          If file cannot be created.
+     */
+    static File getPackageFile(File dir, String fileName)
+            throws RMICompilerException {
+        File file = new File(dir, fileName);
+
+        if (file.exists()
+                ? !(file.isFile() && file.canWrite()) : !dir.canWrite()) {
+            throw new RMICompilerException("Can't create file: " + file);
+        }
+
+        return file;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/package.html
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/package.html?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/package.html (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/package.html Thu May 18 13:01:22 2006
@@ -0,0 +1,25 @@
+<html>
+<!--
+Copyright 2005-2006 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.
+-->
+<!--
+Author:  Vasily Zakharov
+Version: $Revision: 1.1.2.1 $
+-->
+<body>
+RMI Compiler classes.
+</body>
+</html>

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/package.html
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/package.html?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/package.html (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/package.html Thu May 18 13:01:22 2006
@@ -0,0 +1,25 @@
+<html>
+<!--
+Copyright 2005-2006 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.
+-->
+<!--
+Author:  Vasily Zakharov
+Version: $Revision: 1.1.2.1 $
+-->
+<body>
+Core RMI implementation classes.
+</body>
+</html>

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl.java Thu May 18 13:01:22 2006
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Mikhail A. Markov
+ * @version $Revision: 1.1.2.3 $
+ */
+package org.apache.harmony.rmi.registry;
+
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.RMISecurityManager;
+import java.rmi.server.ObjID;
+import java.rmi.server.RemoteServer;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.AccessException;
+import java.rmi.registry.Registry;
+
+import org.apache.harmony.rmi.common.RMIUtil;
+import org.apache.harmony.rmi.remoteref.UnicastServerRef;
+import org.apache.harmony.rmi.remoteref.UnicastServerRef2;
+import org.apache.harmony.rmi.server.ExportManager;
+import org.apache.harmony.rmi.server.ServerConnectionManager;
+
+
+/**
+ * Transient Registry interface implementation.
+ * It does not extend UnicastRemoteObject because all constructors of
+ * UnicastRemoteObject export itself, but we need a special export for
+ * objects with well-known ObjID numbers.
+ *
+ * @author  Mikhail A. Markov
+ * @version $Revision: 1.1.2.3 $
+ */
+public class RegistryImpl extends RemoteServer implements Registry {
+
+    private static final long serialVersionUID = 2202752560834503694L;
+
+    /** Registry Object ID. */
+    public static final ObjID regId = new ObjID(ObjID.REGISTRY_ID);
+
+    /* Bindings table. */
+    private transient Hashtable table = new Hashtable();
+
+    /**
+     * Starts rmiregistry on the specified port. If no port specified then
+     * registry will be started on default port. This method ends with a
+     * blocking construction to not let the VM exit.
+     *
+     * @param args arguments which can contain port number
+     */
+    public static void main(String[] args) throws Exception {
+        String usage =
+            "Usage: java org.apache.harmony.rmi.registry.RegistryImpl <port>";
+        int port = REGISTRY_PORT;
+
+        if (args.length > 1) {
+            System.err.println(usage);
+            System.exit(-1);
+        } else if (args.length == 1) {
+            try {
+                port = Integer.parseInt(args[0]);
+            } catch (NumberFormatException nfe) {
+                System.out.println("Invalid port number " + args[0]);
+                System.out.println(usage);
+                System.exit(-1);
+            }
+        }
+
+        if (System.getSecurityManager() == null) {
+            System.setSecurityManager(new RMISecurityManager());
+        }
+        Registry reg = new RegistryImpl(port, null, null);
+
+        // do not let VM exit
+        Object obj = new Object();
+
+        synchronized(obj) {
+            obj.wait();
+        }
+    }
+
+    /**
+     * Constructs registry listening on default port and using default client
+     * and server socket factories for RMI calls.
+     *
+     * @throws RemoteException if the registry could not be exported
+     */
+    public RegistryImpl() throws RemoteException {
+        this (REGISTRY_PORT, null, null);
+    }
+
+    /**
+     * Constructs registry listening on the specified port and using specified
+     * client and server socket factories for RMI calls.
+     *
+     * @param port port to accept connections
+     * @param csf client-side socket factory
+     * @param ssf server-side socket factory
+     *
+     * @throws RemoteException if the registry could not be exported
+     */
+    public RegistryImpl(int port,
+                        RMIClientSocketFactory csf,
+                        RMIServerSocketFactory ssf)
+            throws RemoteException {
+        UnicastServerRef sref;
+
+        if (csf != null || ssf != null) {
+            sref = new UnicastServerRef2(port, csf, ssf, regId);
+        } else {
+            sref = new UnicastServerRef(port, csf, ssf, regId);
+        }
+        ExportManager.exportObject(this, sref, false, true, true);
+    }
+
+    /**
+     * @see Registry.rebind(String, Remote)
+     */
+    public void rebind(String name, Remote obj)
+            throws RemoteException, AccessException {
+        if (name == null) {
+            throw new NullPointerException("name could not be null.");
+        }
+
+        if (obj == null) {
+            throw new NullPointerException("obj could not be null.");
+        }
+        checkAccess("RegistryImpl.rebind");
+        table.put(name, obj);
+    }
+
+    /**
+     * @see Registry.bind(String, Remote)
+     */
+    public void bind(String name, Remote obj)
+            throws RemoteException, AlreadyBoundException, AccessException {
+        if (name == null) {
+            throw new NullPointerException("name could not be null.");
+        }
+
+        if (obj == null) {
+            throw new NullPointerException("obj could not be null.");
+        }
+
+        if (table.containsKey(name)) {
+            throw new AlreadyBoundException(
+                    "There is already binding to the name " + name + ".");
+        }
+        checkAccess("RegistryImpl.bind");
+        table.put(name, obj);
+    }
+
+    /**
+     * @see Registry.lookup(String)
+     */
+    public Remote lookup(String name)
+            throws RemoteException, NotBoundException, AccessException {
+        if (name == null) {
+            throw new NullPointerException("name could not be null.");
+        }
+        Remote ref = (Remote) table.get(name);
+
+        if (ref == null) {
+            throw new NotBoundException("Name " + name
+                    + " is not associated with any remote reference.");
+        }
+        return ref;
+    }
+
+    /**
+     * @see Registry.unbind(String)
+     */
+    public void unbind(String name)
+            throws RemoteException, NotBoundException, AccessException {
+        if (name == null) {
+            throw new NullPointerException("name could not be null.");
+        }
+        checkAccess("RegistryImpl.unbind");
+
+        if (table.remove(name) == null) {
+            throw new NotBoundException("Name " + name
+                    + " is not associated with any remote reference.");
+        }
+    }
+
+    /**
+     * @see Registry.list()
+     */
+    public String[] list()
+            throws RemoteException, AccessException {
+        String[] names = new String[table.size()];
+        Enumeration e = table.keys();
+
+        for (int i = names.length - 1; i >= 0; --i) {
+            names[i] = (String) e.nextElement();
+        }
+        return names;
+    }
+
+    /*
+     * Checks if request came from local host. In this case the method will
+     * successfully return. If request came from non-local host then
+     * AccessException will be returned.
+     *
+     * @param registryMethod method requested access check
+     *
+     * @throws AccessException if request came from non-local host
+     */
+    private static void checkAccess(String registryMethod)
+            throws AccessException {
+        String hostName = ServerConnectionManager.getClientHost();
+
+        try {
+            if (!RMIUtil.isLocalHost(hostName)) {
+                throw new AccessException(registryMethod
+                        + " from non-local host " + hostName
+                        + " is not allowed");
+            }
+        } catch (UnknownHostException uhe) {
+            throw new AccessException(registryMethod
+                    + " from unknown host is not allowed", uhe);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Skel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Skel.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Skel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Skel.java Thu May 18 13:01:22 2006
@@ -0,0 +1,185 @@
+/*
+ * RMI skeleton class
+ * for class org.apache.harmony.rmi.registry.RegistryImpl
+ * Compatible with stub protocol version 1.1/1.2
+ *
+ * Generated by DRL RMI Compiler (rmic).
+ *
+ * DO NOT EDIT!!!
+ * Contents subject to change without notice!
+ */
+package org.apache.harmony.rmi.registry;
+
+
+public final class RegistryImpl_Skel implements java.rmi.server.Skeleton {
+
+    private static final long interfaceHash = 4905912898345647071L;
+
+    private static final java.rmi.server.Operation[] operations = {
+        new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"),
+        new java.rmi.server.Operation("java.lang.String list()[]"),
+        new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"),
+        new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"),
+        new java.rmi.server.Operation("void unbind(java.lang.String)")
+    };
+
+    public java.rmi.server.Operation[] getOperations() {
+        return (java.rmi.server.Operation[]) operations.clone();
+    }
+
+    public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash) throws java.lang.Exception {
+        if (opnum < 0) {
+            if (hash == 7583982177005850366L) {
+                opnum = 0;
+            } else if (hash == 2571371476350237748L) {
+                opnum = 1;
+            } else if (hash == -7538657168040752697L) {
+                opnum = 2;
+            } else if (hash == -8381844669958460146L) {
+                opnum = 3;
+            } else if (hash == 7305022919901907578L) {
+                opnum = 4;
+            } else {
+                throw new java.rmi.UnmarshalException("Invalid method hash: " + hash);
+            }
+        } else {
+            if (hash != interfaceHash) {
+                throw new java.rmi.server.SkeletonMismatchException(
+                        "Interface hash mismatch, expected: " + interfaceHash + ", received: " + hash);
+            }
+        }
+
+        org.apache.harmony.rmi.registry.RegistryImpl server = (org.apache.harmony.rmi.registry.RegistryImpl) obj;
+
+        switch (opnum) {
+
+        case 0: {    // bind(String, Remote)
+
+            java.lang.String $param_String_1;
+            java.rmi.Remote $param_Remote_2;
+
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $param_String_1 = (java.lang.String) in.readObject();
+                $param_Remote_2 = (java.rmi.Remote) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } finally {
+                call.releaseInputStream();
+            }
+
+            server.bind($param_String_1, $param_Remote_2);
+
+            try {
+                call.getResultStream(true);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("Error marshalling return", e);
+            }
+
+            break;
+        }
+
+        case 1: {    // list()
+
+            call.releaseInputStream();
+
+            java.lang.String[] $result = server.list();
+
+            try {
+                java.io.ObjectOutput out = call.getResultStream(true);
+                out.writeObject($result);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("Error marshalling return", e);
+            }
+
+            break;
+        }
+
+        case 2: {    // lookup(String)
+
+            java.lang.String $param_String_1;
+
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $param_String_1 = (java.lang.String) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } finally {
+                call.releaseInputStream();
+            }
+
+            java.rmi.Remote $result = server.lookup($param_String_1);
+
+            try {
+                java.io.ObjectOutput out = call.getResultStream(true);
+                out.writeObject($result);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("Error marshalling return", e);
+            }
+
+            break;
+        }
+
+        case 3: {    // rebind(String, Remote)
+
+            java.lang.String $param_String_1;
+            java.rmi.Remote $param_Remote_2;
+
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $param_String_1 = (java.lang.String) in.readObject();
+                $param_Remote_2 = (java.rmi.Remote) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } finally {
+                call.releaseInputStream();
+            }
+
+            server.rebind($param_String_1, $param_Remote_2);
+
+            try {
+                call.getResultStream(true);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("Error marshalling return", e);
+            }
+
+            break;
+        }
+
+        case 4: {    // unbind(String)
+
+            java.lang.String $param_String_1;
+
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $param_String_1 = (java.lang.String) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("Error unmarshalling arguments", e);
+            } finally {
+                call.releaseInputStream();
+            }
+
+            server.unbind($param_String_1);
+
+            try {
+                call.getResultStream(true);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("Error marshalling return", e);
+            }
+
+            break;
+        }
+
+        default:
+            throw new java.rmi.UnmarshalException("Invalid method number: " + opnum);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Skel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Stub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Stub.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Stub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Stub.java Thu May 18 13:01:22 2006
@@ -0,0 +1,234 @@
+/*
+ * RMI stub class
+ * for class org.apache.harmony.rmi.registry.RegistryImpl
+ * Compatible with stub protocol version 1.1/1.2
+ *
+ * Generated by DRL RMI Compiler (rmic).
+ *
+ * DO NOT EDIT!!!
+ * Contents subject to change without notice!
+ */
+package org.apache.harmony.rmi.registry;
+
+
+public final class RegistryImpl_Stub extends java.rmi.server.RemoteStub
+        implements java.rmi.registry.Registry, java.rmi.Remote {
+
+    private static final long serialVersionUID = 2;
+
+    private static final long interfaceHash = 4905912898345647071L;
+
+    private static boolean useNewInvoke;
+
+    private static final java.rmi.server.Operation[] operations = {
+        new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"),
+        new java.rmi.server.Operation("java.lang.String list()[]"),
+        new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"),
+        new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"),
+        new java.rmi.server.Operation("void unbind(java.lang.String)")
+    };
+
+    private static java.lang.reflect.Method $method_bind_0;
+    private static java.lang.reflect.Method $method_list_1;
+    private static java.lang.reflect.Method $method_lookup_2;
+    private static java.lang.reflect.Method $method_rebind_3;
+    private static java.lang.reflect.Method $method_unbind_4;
+
+    static {
+        try {
+            java.rmi.server.RemoteRef.class.getMethod("invoke", new java.lang.Class[] {java.rmi.Remote.class, java.lang.reflect.Method.class, java.lang.Object[].class, long.class});
+
+            $method_bind_0 = java.rmi.registry.Registry.class.getMethod("bind", new java.lang.Class[] {java.lang.String.class, java.rmi.Remote.class});
+            $method_list_1 = java.rmi.registry.Registry.class.getMethod("list", new java.lang.Class[] {});
+            $method_lookup_2 = java.rmi.registry.Registry.class.getMethod("lookup", new java.lang.Class[] {java.lang.String.class});
+            $method_rebind_3 = java.rmi.registry.Registry.class.getMethod("rebind", new java.lang.Class[] {java.lang.String.class, java.rmi.Remote.class});
+            $method_unbind_4 = java.rmi.registry.Registry.class.getMethod("unbind", new java.lang.Class[] {java.lang.String.class});
+
+            useNewInvoke = true;
+        } catch (java.lang.NoSuchMethodException e) {
+            useNewInvoke = false;
+        }
+    }
+
+    public RegistryImpl_Stub() {
+        super();
+    }
+
+    public RegistryImpl_Stub(java.rmi.server.RemoteRef ref) {
+        super(ref);
+    }
+
+    // Implementation of bind(String, Remote)
+    public void bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
+            throws java.rmi.RemoteException, java.rmi.AlreadyBoundException, java.rmi.AccessException {
+        try {
+            if (useNewInvoke) {
+                ref.invoke(this, $method_bind_0, new java.lang.Object[] {$param_String_1, $param_Remote_2}, 7583982177005850366L);
+            } else {
+                java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
+
+                try {
+                    java.io.ObjectOutput out = call.getOutputStream();
+                    out.writeObject($param_String_1);
+                    out.writeObject($param_Remote_2);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("Error marshalling arguments", e);
+                }
+
+                ref.invoke(call);
+
+                ref.done(call);
+            }
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.rmi.AlreadyBoundException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("Undeclared checked exception", e);
+        }
+    }
+
+    // Implementation of list()
+    public java.lang.String[] list()
+            throws java.rmi.RemoteException, java.rmi.AccessException {
+        try {
+            if (useNewInvoke) {
+                java.lang.Object $result = ref.invoke(this, $method_list_1, null, 2571371476350237748L);
+                return ((java.lang.String[]) $result);
+            } else {
+                java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
+
+                ref.invoke(call);
+
+                java.lang.String[] $result;
+
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $result = (java.lang.String[]) in.readObject();
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.UnmarshalException("Error unmarshalling return value", e);
+                } catch (java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("Error unmarshalling return value", e);
+                } finally {
+                    ref.done(call);
+                }
+
+                return $result;
+            }
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("Undeclared checked exception", e);
+        }
+    }
+
+    // Implementation of lookup(String)
+    public java.rmi.Remote lookup(java.lang.String $param_String_1)
+            throws java.rmi.RemoteException, java.rmi.NotBoundException, java.rmi.AccessException {
+        try {
+            if (useNewInvoke) {
+                java.lang.Object $result = ref.invoke(this, $method_lookup_2, new java.lang.Object[] {$param_String_1}, -7538657168040752697L);
+                return ((java.rmi.Remote) $result);
+            } else {
+                java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
+
+                try {
+                    java.io.ObjectOutput out = call.getOutputStream();
+                    out.writeObject($param_String_1);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("Error marshalling arguments", e);
+                }
+
+                ref.invoke(call);
+
+                java.rmi.Remote $result;
+
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $result = (java.rmi.Remote) in.readObject();
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.UnmarshalException("Error unmarshalling return value", e);
+                } catch (java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("Error unmarshalling return value", e);
+                } finally {
+                    ref.done(call);
+                }
+
+                return $result;
+            }
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.rmi.NotBoundException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("Undeclared checked exception", e);
+        }
+    }
+
+    // Implementation of rebind(String, Remote)
+    public void rebind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
+            throws java.rmi.RemoteException, java.rmi.AccessException {
+        try {
+            if (useNewInvoke) {
+                ref.invoke(this, $method_rebind_3, new java.lang.Object[] {$param_String_1, $param_Remote_2}, -8381844669958460146L);
+            } else {
+                java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
+
+                try {
+                    java.io.ObjectOutput out = call.getOutputStream();
+                    out.writeObject($param_String_1);
+                    out.writeObject($param_Remote_2);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("Error marshalling arguments", e);
+                }
+
+                ref.invoke(call);
+
+                ref.done(call);
+            }
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("Undeclared checked exception", e);
+        }
+    }
+
+    // Implementation of unbind(String)
+    public void unbind(java.lang.String $param_String_1)
+            throws java.rmi.RemoteException, java.rmi.NotBoundException, java.rmi.AccessException {
+        try {
+            if (useNewInvoke) {
+                ref.invoke(this, $method_unbind_4, new java.lang.Object[] {$param_String_1}, 7305022919901907578L);
+            } else {
+                java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash);
+
+                try {
+                    java.io.ObjectOutput out = call.getOutputStream();
+                    out.writeObject($param_String_1);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("Error marshalling arguments", e);
+                }
+
+                ref.invoke(call);
+
+                ref.done(call);
+            }
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.rmi.NotBoundException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("Undeclared checked exception", e);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/RegistryImpl_Stub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/package.html
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/package.html?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/package.html (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/package.html Thu May 18 13:01:22 2006
@@ -0,0 +1,25 @@
+<html>
+<!--
+Copyright 2005-2006 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.
+-->
+<!--
+Author:  Vasily Zakharov
+Version: $Revision: 1.1.2.1 $
+-->
+<body>
+RMI Registry implementation classes.
+</body>
+</html>

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/registry/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableRef.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableRef.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableRef.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableRef.java Thu May 18 13:01:22 2006
@@ -0,0 +1,233 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Victor A. Martynov
+ * @version $Revision: 1.1.2.3 $
+ */
+package org.apache.harmony.rmi.remoteref;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.ConnectException;
+import java.rmi.ConnectIOException;
+import java.rmi.Remote;
+import java.rmi.StubNotFoundException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.UnknownObjectException;
+import java.rmi.server.RMIClassLoader;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+
+import org.apache.harmony.rmi.common.RMILog;
+import org.apache.harmony.rmi.common.RMIUtil;
+
+
+/**
+ * Activatable ref is the Remote Reference that organizes the next level of indirection during the remote method invocation.
+ * It means that ActivatableRef contains another RemoteRef inside that can be 'null' if the ActivatableRef wasn't yet activated or will contain
+ * the Remote Reference to the active object.
+ *
+ * @author  Victor A. Martynov
+ * @version $Revision: 1.1.2.3 $
+ *
+ * ActivatableRef
+ */
+public class ActivatableRef extends UnicastRef2 {
+
+    private static final long serialVersionUID = -2842326509564440186L;
+
+    RMILog rlog = RMILog.getActivationLog();
+
+    /**
+     * The ActivationID of the Activatable Object of this ActivatableRef.
+     */
+    protected ActivationID id;
+
+    /**
+     *  The internal Remote Reference of this ActivatableRef. This ref is 'null' initially
+     *  but when the remote call happens, 'ref' points to the active object.
+     */
+    protected RemoteRef ref;
+
+    /**
+     * Default constructor. It is used mostly in Deserialization.
+     */
+    public ActivatableRef() {
+    }
+
+    /**
+     * Special constructor to create ActivatableRef with the given Remote Reference and ActivationID.
+     * Used in ActivatableServerRef.
+     * @param aid The handle for the Activatable Object.
+     * @param ref The internal reference of this ActivatableRef.
+     */
+    public ActivatableRef(ActivationID aid, RemoteRef ref) {
+        this.ref = ref;
+        this.id = aid;
+    }
+
+    /**
+     * Returns the Remote Stub for the given activatable class.
+     */
+    public static RemoteStub getStub(ActivationDesc desc, ActivationID aid)
+            throws StubNotFoundException {
+
+        String cn = desc.getClassName();
+        String stubName = "";
+
+        try {
+            Class cl = RMIClassLoader.loadClass(desc.getLocation(), cn);
+            Class rcl = RMIUtil.getRemoteClass(cl);
+            stubName = rcl.getName() + "_Stub";
+            Class stubClass = RMIClassLoader.loadClass((String) null, stubName);
+            Constructor constructor = stubClass.getConstructor(new Class[] { RemoteRef.class });
+            RemoteStub stub = (RemoteStub) constructor.newInstance(new Object[] {
+                    new ActivatableRef(aid, null)
+            });
+            return stub;
+
+        } catch (Exception ex) {
+            throw new StubNotFoundException("Stub " + stubName + " not found.",
+                    ex);
+        }
+    }
+
+
+    /**
+     * The getRefClass method returns "ActivatableRef" String.
+     */
+    public String getRefClass(ObjectOutput objectoutput) {
+        return "ActivatableRef";
+    }
+
+    /**
+     * To obtain the description of the Serialization of this class see the Serialized form of
+     * java.rmi.server.RemoteObject.
+     */
+    public void writeExternal(ObjectOutput out) throws IOException {
+
+        out.writeObject(id);
+
+        if (ref == null) {
+            out.writeUTF("");
+        } else {
+            out.writeUTF(ref.getRefClass(out));
+            ref.writeExternal(out);
+        }
+    }
+
+    /**
+     * To obtain the description of the Serialization of this class see the Serialized form of
+     * java.rmi.server.RemoteObject.
+     */
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        id = (ActivationID) in.readObject();
+
+        String s = in.readUTF();
+
+        if (s.equals("")) {
+            return;
+        }
+        Class extRefTypeClass = Class.forName(RemoteRef.packagePrefix +"."+ s);
+
+        try {
+            ref = (RemoteRef)extRefTypeClass.newInstance();
+        }
+        catch(Throwable  t) {
+            throw new ClassNotFoundException("Instantiation failed.", t);
+        }
+        ref.readExternal(in);
+    }
+
+    /**
+     * If the internal remote reference of this ActivatableRef is null, the activatable object is activated using
+     * ActivationID.activate() methiod. After that the remote call is delegated to the ref, by means of calling its 'invoke' method.
+     */
+    public Object invoke(Remote obj, Method method, Object[] params, long opnum)
+            throws Exception {
+        Exception signal_exception  = null;
+        RemoteRef rref;
+
+        rlog.log(RMILog.VERBOSE, "$$$$$$$$$ ActivatableRef.invoke: "+obj+", "+method+";");
+
+        if(ref == null) {
+            rlog.log(RMILog.VERBOSE, "ref == null");
+
+            RemoteStub stub = (RemoteStub)id.activate(false); //ToDo Check whether it returns Remote or RemoteStub
+            rlog.log(RMILog.VERBOSE, "stub = "+stub);
+
+            ActivatableRef aref = (ActivatableRef)stub.getRef();
+            rlog.log(RMILog.VERBOSE, "aref = "+aref);
+
+            ref = aref.ref; // Global variable stored for next calls
+            rref = aref.ref; // local variable
+        } else {
+            rref = ref;
+        }
+
+        /*
+         * If the group's VM was killed(or something bad happened to it) we may have stale activatable reference to the object.
+         * In this case rref.invoke() will throw 3 types of Exceptions: ConnectException, ConnectIOException and UnknownObjectException
+         * which should be catched and activation group should be activated again.
+         */
+        try {
+            return rref.invoke(obj, method, params, opnum);
+        }
+        catch(ConnectException ce) {
+        }
+        catch(ConnectIOException cioe) {
+        }
+        catch(UnknownObjectException uoe) {
+        }
+        catch(Exception t) {
+            signal_exception = t;
+        }
+
+        rlog.log(RMILog.VERBOSE, "signal_exception = "+signal_exception);
+
+        if (signal_exception == null) {
+            RemoteStub stub = (RemoteStub)id.activate(true);
+            ActivatableRef aref = (ActivatableRef) stub.getRef();
+            ref = aref.ref;
+            rref = aref.ref;
+            return rref.invoke(obj, method, params, opnum);
+        }
+        else {
+            throw signal_exception;
+        }
+    }
+
+    /**
+     * Standart remoteEquals implementaion.
+     *
+     * @param ref
+     *
+     * @return
+     */
+    public boolean remoteEquals(RemoteRef ref) {
+        if (ref instanceof ActivatableRef) {
+            ActivationID id = ((ActivatableRef)ref).id;
+            return this.id.equals(id);
+        }
+        return false;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableRef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableServerRef.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableServerRef.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableServerRef.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableServerRef.java Thu May 18 13:01:22 2006
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Victor A. Martynov
+ * @version $Revision: 1.1.2.3 $
+ */
+package org.apache.harmony.rmi.remoteref;
+
+import java.io.ObjectOutput;
+import java.rmi.activation.ActivationID;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+
+import org.apache.harmony.rmi.transport.Endpoint;
+
+
+/**
+ *
+ * @author  Victor A. Martynov
+ * @version $Revision: 1.1.2.3 $
+ *
+ * ActivatableServerRef
+ */
+public class ActivatableServerRef extends UnicastServerRef2 {
+
+    private static final long serialVersionUID = 460723133775318075L;
+
+    private ActivationID aid;
+
+    /**
+     * Constructor intended to create ActivatableServerRef on the given port.
+     *
+     * @param aid Activation identificator of this ActivatableRef
+     * @param port Port on which ActivatableServerRef will be exported.
+     * @param csf Client socket factory.
+     * @param ssf Server socket factory.
+     */
+    public ActivatableServerRef(ActivationID aid,
+                                int port,
+                                RMIClientSocketFactory csf,
+                                RMIServerSocketFactory ssf) {
+        super(port, csf, ssf, new ObjID());
+        this.aid = aid;
+    }
+
+    /**
+     * Constructor intended to create ActivatableServerRef on the given port.
+     * @param aid Activation identificator of this ActivatableRef
+     * @param port Port on which ActivatableServerRef will be exported.
+     */
+    public ActivatableServerRef(ActivationID aid, int port) {
+        this(aid, port, null, null);
+    }
+
+    /**
+     *
+     * @param out
+     *
+     * @return The String "ActivatableServerRef" that indicates which Serialization
+     * rules should be applied to this remote reference.
+     */
+    public String getRefClass(ObjectOutput out) {
+        return "ActivatableServerRef";
+    }
+
+    /**
+     *
+     * @return The instance of the ActivatableRef instance with the same Activation identifier as this ActivatableServerRef.
+     */
+    protected UnicastRef getClientRef(Endpoint ep, ObjID obj_id) {
+        return new ActivatableRef(aid, new UnicastRef2(ep, obj_id, true));
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/ActivatableServerRef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef.java Thu May 18 13:01:22 2006
@@ -0,0 +1,282 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+package org.apache.harmony.rmi.remoteref;
+
+import java.lang.reflect.Method;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.rmi.MarshalException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnmarshalException;
+import java.rmi.server.ObjID;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteCall;
+import java.rmi.server.Operation;
+
+import org.apache.harmony.rmi.client.ClientConnection;
+import org.apache.harmony.rmi.client.ClientConnectionManager;
+import org.apache.harmony.rmi.client.ClientRemoteCall;
+import org.apache.harmony.rmi.common.RMILog;
+import org.apache.harmony.rmi.server.RemoteRefBase;
+import org.apache.harmony.rmi.transport.Endpoint;
+import org.apache.harmony.rmi.transport.RMIObjectInputStream;
+import org.apache.harmony.rmi.transport.RMIObjectOutputStream;
+import org.apache.harmony.rmi.transport.RMIProtocolConstants;
+
+
+/**
+ * Implementation of handle for remote objects.
+ *
+ * @author  Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+public class UnicastRef extends RemoteRefBase {
+
+    private static final long serialVersionUID = -2637470287094993242L;
+
+    /** Logger where to write client-side log of remote calls. */
+    public static final RMILog clientCallsLog = RMILog.getClientCallsLog();
+
+    // Log where to write server-side log of remote reference activity
+    private static final RMILog clientRefLog = RMILog.getClientRefLog();
+
+    /**
+     * Default constructor: constructs an empty instance of this class.
+     */
+    public UnicastRef() {
+        ep = null;
+        objId = null;
+    }
+
+    /**
+     * Constructs UnicastRef.
+     *
+     * @param host host name where remote object impl. is located.
+     * @param port port on remote host where remote object accepts RMI calls
+     * @param objId Object ID of remoteObject
+     */
+    public UnicastRef(String host,
+                      int port,
+                      ObjID objId) {
+        this(new Endpoint(host, port, null, null), objId);
+    }
+
+    /**
+     * Constructs UnicastRef using specified Endpoint and objId.
+     *
+     * @param ep Endpoint for remote calls
+     * @param objId Object ID of remote object
+     */
+    public UnicastRef(Endpoint ep, ObjID objId) {
+        this(ep, objId, false);
+    }
+
+    /**
+     * Constructs UnicastRef using specified Endpoint and objId.
+     *
+     * @param ep Endpoint for remote calls
+     * @param objId Object ID of remote object
+     * @param isLocal if true this UnicastRef belongs to local object
+     */
+    public UnicastRef(Endpoint ep, ObjID objId, boolean isLocal) {
+        this.ep = ep;
+        this.objId = objId;
+        this.isLocal = isLocal;
+    }
+
+
+    /**
+     * @see RemoteRef.invoke(Remote, Method, Object[], long)
+     */
+    public Object invoke(Remote obj,
+                         Method m,
+                         Object[] params,
+                         long h) throws Exception {
+        Object toReturn = null;
+        logClientCall(obj, m.toString());
+
+        if (clientRefLog.isLoggable(RMILog.BRIEF)) {
+            clientRefLog.log(RMILog.BRIEF, "New call: method = [" + m
+                    + "], hash = " + h);
+        }
+
+        // initiate a new call
+        RemoteCall call = newCall(null, null, -1, h);
+        ((ClientRemoteCall) call).setMethod(m);
+
+
+        try {
+            // write arguments for the method called
+            RMIObjectOutputStream oout =
+                    (RMIObjectOutputStream) call.getOutputStream();
+            Class[] paramTypes = m.getParameterTypes();
+
+            try {
+                if (params != null) {
+                    for (int i = 0; i < params.length; ++i) {
+                        oout.writeRMIObject(params[i], paramTypes[i]);
+                    }
+                }
+            } catch (IOException ioe) {
+                throw new MarshalException("I/O error occured while "
+                        + "marshalling arguments", ioe);
+            }
+
+            // execute the call
+            invoke(call);
+
+            // read return value
+            // if we pass here then server produced no exceptions
+            if (m.getReturnType() != Void.TYPE) {
+                RMIObjectInputStream oin =
+                        (RMIObjectInputStream) call.getInputStream();
+
+                try {
+                    toReturn = oin.readRMIObject(m.getReturnType(), null);
+                } catch (IOException ioe) {
+                    throw new UnmarshalException("IOException occured while "
+                            + "unmarshalling return value", ioe);
+                } catch (ClassNotFoundException cnfe) {
+                    throw new UnmarshalException(
+                            "ClassNotFoundException occured "
+                            + "while unmarshalling return value", cnfe);
+                }
+            }
+        } catch (IOException ioe) {
+            ((ClientRemoteCall) call).close();
+            throw ioe;
+        }
+        done(call);
+        return toReturn;
+    }
+
+    /**
+     * @see RemoteRef.getRefClass(ObjectOutput)
+     */
+    public String getRefClass(ObjectOutput out) {
+        return "UnicastRef";
+    }
+
+    /**
+     * Writes this UnicastRef object to the specified output stream.
+     *
+     * @param out the stream to write the object to
+     *
+     * @throws IOException if any I/O error occured or class is not serializable
+     */
+    public void writeExternal(ObjectOutput out) throws IOException {
+        ep.writeExternal(out, false);
+        writeCommon(out);
+    }
+
+    /**
+     * Reads data for creating RemoteRef object from the specified input stream.
+     *
+     * @param in the stream to read data from
+     *
+     * @throws IOException if any I/O error occured
+     * @throws ClassNotFoundException if class could not be loaded by current
+     *         class loader
+     */
+    public void readExternal(ObjectInput in)
+            throws IOException, ClassNotFoundException {
+        ep = Endpoint.readExternal(in, false);
+        readCommon(in);
+    }
+
+    /**
+     * @see RemoteRef.newCall(RemoteObject, Operation[], int, long)
+     */
+    public RemoteCall newCall(RemoteObject obj,
+                              Operation[] op,
+                              int opnum,
+                              long hash)
+            throws RemoteException {
+        if (opnum != -1) {
+            if (clientRefLog.isLoggable(RMILog.BRIEF)) {
+                clientRefLog.log(RMILog.BRIEF, "New call: method = ["
+                        + op[opnum].toString() + "], opnum = " + opnum
+                        + ", hash = " + hash);
+            }
+            logClientCall(obj, op[opnum].toString());
+        }
+        ClientConnection conn = ClientConnectionManager.getConnection(ep);
+        RemoteCall call = new ClientRemoteCall(conn);
+
+        if (clientRefLog.isLoggable(RMILog.VERBOSE)) {
+            clientRefLog.log(RMILog.VERBOSE, "Created new call " + call);
+        }
+
+        try {
+            // write method signature
+            DataOutputStream dout = new DataOutputStream(conn.getOutputStream());
+            dout.writeByte(RMIProtocolConstants.CALL_MSG);
+            ObjectOutputStream oout =
+                    (ObjectOutputStream) call.getOutputStream();
+            objId.write(oout);
+            oout.writeInt(opnum);
+            oout.writeLong(hash);
+            return call;
+        } catch (IOException ioe) {
+            done(call);
+            throw new MarshalException("Unable to marshal call header", ioe);
+        }
+    }
+
+    /**
+     * @see RemoteRef.invoke(RemoteCall)
+     */
+    public void invoke(RemoteCall call) throws Exception {
+        if (clientRefLog.isLoggable(RMILog.VERBOSE)) {
+            clientRefLog.log(RMILog.VERBOSE, "Execute call " + call);
+        }
+        call.releaseOutputStream();
+        call.executeCall();
+    }
+
+    /**
+     * @see RemoteRef.done(RemoteCall)
+     */
+    public void done(RemoteCall call) throws RemoteException {
+        if (clientRefLog.isLoggable(RMILog.VERBOSE)) {
+            clientRefLog.log(RMILog.VERBOSE, "Finalize call " + call);
+        }
+
+        try {
+            call.done();
+        } catch (Exception ex) {
+        }
+    }
+
+    // Logs remote method call on client side.
+    private void logClientCall(Remote obj, String m) {
+        if (clientCallsLog.isLoggable(RMILog.VERBOSE)) {
+            clientCallsLog.log(RMILog.VERBOSE,
+                    "Outbound remote call to endpoint:" + ep + ": method:[" + m
+                    + "], obj:[" + obj + "].");
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef2.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef2.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef2.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef2.java Thu May 18 13:01:22 2006
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * @author  Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+package org.apache.harmony.rmi.remoteref;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIClientSocketFactory;
+
+import org.apache.harmony.rmi.transport.Endpoint;
+
+
+/**
+ * Handle of remote objects using custom client socket factory.
+ *
+ * @author  Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+public class UnicastRef2 extends UnicastRef {
+
+    private static final long serialVersionUID = 1358245507919642056L;
+
+    /**
+     * Default constructor: constructs an empty instance of this class.
+     */
+    public UnicastRef2() {
+        super();
+    }
+
+    /**
+     * Constructs UnicastRef2.
+     *
+     * @param host host name where remote object impl. is located.
+     * @param port port on remote host where remote object accepts RMI calls
+     * @param objId Object ID of remoteObject
+     * @param csf client-side socket factory; if null - then default socket
+     *        factory will be used (call RMISocketFactory.getSocketFactory
+     *        method and if it returns null, then call
+     *        RMISocketFactory.getDefaultSocketFactory)
+     */
+    public UnicastRef2(String host,
+                       int port,
+                       RMIClientSocketFactory csf,
+                       ObjID objId) {
+        this(new Endpoint(host, port, csf, null), objId);
+    }
+
+    /**
+     * Constructs UnicastRef2 using specified Endpoint.
+     *
+     * @param ep Endpoint for remote calls
+     * @param objId Object ID of remote object
+     */
+    public UnicastRef2(Endpoint ep, ObjID objId) {
+        super(ep, objId);
+    }
+
+    /**
+     * Constructs UnicastRef2 using specified Endpoint and objId.
+     *
+     * @param ep Endpoint for remote calls
+     * @param objId Object ID of remote object
+     * @param isLocal if true this UnicastRef2 belongs to local object
+     */
+    public UnicastRef2(Endpoint ep, ObjID objId, boolean isLocal) {
+        super(ep, objId, isLocal);
+    }
+
+    /**
+     * @see RemoteRef.getRefClass(ObjectOutput)
+     */
+    public String getRefClass(ObjectOutput out) {
+        return "UnicastRef2";
+    }
+
+    /**
+     * Writes this UnicastRef2 object to the specified output stream.
+     *
+     * @param out the stream to write the object to
+     *
+     * @throws IOException if any I/O error occured or class is not serializable
+     */
+    public void writeExternal(ObjectOutput out) throws IOException {
+        ep.writeExternal(out, true);
+        writeCommon(out);
+    }
+
+    /**
+     * Reads data for creating RemoteRef object from the specified input stream.
+     *
+     * @param in the stream to read data from
+     *
+     * @throws IOException if any I/O error occured
+     * @throws ClassNotFoundException if class could not be loaded by current
+     *         class loader
+     */
+    public void readExternal(ObjectInput in)
+            throws IOException, ClassNotFoundException {
+        ep = Endpoint.readExternal(in, true);
+        readCommon(in);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/remoteref/UnicastRef2.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message