geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r158814 [9/9] - in geronimo/trunk/modules: assembly/ assembly/src/plan/ interop/ interop/src/idl/ interop/src/java/org/apache/geronimo/interop/ interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/ interop/src/java/org/apache/geronimo/interop/adapter/ interop/src/java/org/apache/geronimo/interop/client/ interop/src/java/org/apache/geronimo/interop/generator/ interop/src/java/org/apache/geronimo/interop/naming/ interop/src/java/org/apache/geronimo/interop/properties/ interop/src/java/org/apache/geronimo/interop/repository/ interop/src/java/org/apache/geronimo/interop/rmi/iiop/ interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ interop/src/java/org/apache/geronimo/interop/server/ interop/src/java/org/apache/geronimo/interop/util/
Date Wed, 23 Mar 2005 17:57:00 GMT
Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java Wed Mar 23 09:56:34 2005
@@ -21,7 +21,22 @@
 
 
 public class StubClass {
-    public Class stubClass;
+    private Class stubClass;
+    private Method getInstanceMethod;
 
-    public Method getInstance;
+    public StubClass( Class stubClass, Method getInstanceMethod )
+    {
+        this.stubClass = stubClass;
+        this.getInstanceMethod = getInstanceMethod;
+    }
+
+    public Class getStubClass()
+    {
+        return stubClass;
+    }
+
+    public Method getGetInstanceMethod()
+    {
+        return getInstanceMethod;
+    }
 }

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java Wed Mar 23 09:56:34 2005
@@ -18,93 +18,65 @@
 package org.apache.geronimo.interop.rmi.iiop.compiler;
 
 import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.geronimo.interop.generator.GenOptions;
-import org.apache.geronimo.interop.generator.JBlockStatement;
-import org.apache.geronimo.interop.generator.JCatchStatement;
-import org.apache.geronimo.interop.generator.JClass;
-import org.apache.geronimo.interop.generator.JCodeStatement;
-import org.apache.geronimo.interop.generator.JConstructor;
-import org.apache.geronimo.interop.generator.JExpression;
-import org.apache.geronimo.interop.generator.JField;
-import org.apache.geronimo.interop.generator.JForStatement;
-import org.apache.geronimo.interop.generator.JIfElseIfElseStatement;
-import org.apache.geronimo.interop.generator.JIfStatement;
-import org.apache.geronimo.interop.generator.JLocalVariable;
-import org.apache.geronimo.interop.generator.JMethod;
-import org.apache.geronimo.interop.generator.JPackage;
-import org.apache.geronimo.interop.generator.JParameter;
-import org.apache.geronimo.interop.generator.JReturnType;
-import org.apache.geronimo.interop.generator.JTryCatchFinallyStatement;
-import org.apache.geronimo.interop.generator.JTryStatement;
-import org.apache.geronimo.interop.generator.JVariable;
-import org.apache.geronimo.interop.generator.JavaGenerator;
+import java.io.File;
+import java.util.*;
+
+import org.apache.geronimo.interop.generator.*;
 import org.apache.geronimo.interop.util.JavaClass;
 import org.apache.geronimo.interop.util.ProcessUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+public class StubCompiler extends Compiler {
+    private final Log log = LogFactory.getLog(StubCompiler.class);
 
-public class StubCompiler
-        extends Compiler {
-    protected ValueTypeContext _vtc = new ValueTypeContext();
-    protected static JParameter _objInputVar = new JParameter(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.class, "input");
-    protected static JParameter _objOutputVar = new JParameter(org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.class, "output");
-
-    protected String _stubClassName = "";
-    protected Class _stubClass = null;
-
-    protected String _inStreamName = "getInputStream";
-    protected String _outStreamName = "getOutputStream";
-
-    public StubCompiler(Class riClass) {
-        super(riClass);
-        init();
-    }
-
-    public StubCompiler(Class riClass, GenOptions go) {
-        super(riClass, go);
-        init();
-    }
-
-    protected void init() {
-        String className = _riClass.getName();
-        _stubClassName = JavaClass.addPackageSuffix(className, "iiop_stubs") + "_Stub";
-    }
+    private ValueTypeContext        vtc = new ValueTypeContext();
 
-    protected void addMethod(JClass jc, JReturnType jrc, String name, JParameter[] jparms, Class[] excepts) {
-//        java.lang.Object $key_1 = $getRequestKey();
-//        for (int $retry = 0; ; $retry++)
-//        {
-//            try
-//            {
-//                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
-//                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();  // simple idl
-//                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getOutputStream();        // rmi-iiop
-//                $output_3.writeObject(type$1, p1);
-//                $connection_2.invoke(this, "_is_a", $key_1, $retry);
-//                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();     // simple idl
-//                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getInputStream();           // rmi-iiop
-//                $connection_2.forget($key_1);
-//                $connection_2.close();
-//                java.lang.String $et_5 = $connection_2.getExceptionType();
-//                if ($et_5 != null)
-//                {
-//                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
-//                }
-//                boolean $djc_result;
-//                $djc_result = $input_4.readBoolean();
-//                return $djc_result;
-//            }
-//            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
-//            {
-//                if ($retry == 3)
-//                {
-//                    throw $ex_6.getRuntimeException();
-//                }
-//            }
-//        }
+    private String                  inStreamName = "getInputStream";
+    private String                  outStreamName = "getOutputStream";
+
+    private HashMap                 packages = new HashMap();
+
+    public StubCompiler(GenOptions go, ClassLoader cl) {
+        super(go, cl);
+    }
+
+    protected void addMethod(JClass jc, String iiopMethodName, JReturnType jrc,
+                             String name, JParameter[] jparms, Class[] excepts) {
+        //
+        // Method Template:
+        //
+        // java.lang.Object $key_1 = $getRequestKey();
+        // for (int $retry = 0; ; $retry++)
+        // {
+        //     try
+        //     {
+        //         org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+        //         org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();  // simple idl
+        //         org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getOutputStream();        // rmi-iiop
+        //         $output_3.writeObject(type$1, p1);
+        //         $connection_2.invoke(this, "_is_a", $key_1, $retry);
+        //         org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();     // simple idl
+        //         org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getInputStream();           // rmi-iiop
+        //         $connection_2.forget($key_1);
+        //         $connection_2.close();
+        //         java.lang.String $et_5 = $connection_2.getExceptionType();
+        //         if ($et_5 != null)
+        //         {
+        //             throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+        //         }
+        //         boolean $djc_result;
+        //         $djc_result = $input_4.readBoolean();
+        //         return $djc_result;
+        //     }
+        //     catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+        //     {
+        //         if ($retry == 3)
+        //         {
+        //             throw $ex_6.getRuntimeException();
+        //         }
+        //     }
+        // }
 
         //JParameter jpID = new JParameter( java.lang.String.class, "id" );
         JMethod jm = jc.newMethod(jrc, name, jparms, excepts);
@@ -135,7 +107,7 @@
         }
 
         jbs.addStatement(new JCodeStatement(jlvConn.getName() + " = this.$connect();"));
-        jbs.addStatement(new JCodeStatement(jlvOutput.getName() + " = " + jlvConn.getName() + "." + _outStreamName + "();"));
+        jbs.addStatement(new JCodeStatement(jlvOutput.getName() + " = " + jlvConn.getName() + "." + outStreamName + "();"));
 
         String writeMethod = null;
         String writeCall = "";
@@ -145,15 +117,15 @@
             if (writeMethod != null) {
                 writeCall = writeMethod + "( " + jparms[i].getName() + " )";
             } else {
-                writeCall = "writeObject( " + _vtc.getValueTypeVarName(jc, jparms[i]) + ", " + jparms[i].getName() + ")";
+                writeCall = "writeObject( " + vtc.getValueTypeVarName(jc, jparms[i]) + ", " + jparms[i].getName() + ")";
             }
 
             jbs.addStatement(new JCodeStatement(jlvOutput.getName() + "." + writeCall + ";"));
         }
 
-        jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(this, \"" + name + "\", " + jlvKey.getName() + ", $retry);"));
+        jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(this, \"" + iiopMethodName + "\", " + jlvKey.getName() + ", $retry);"));
         if (jlvRc != null) {
-            jbs.addStatement(new JCodeStatement(jlvInput.getName() + " = " + jlvConn.getName() + "." + _inStreamName + "();"));
+            jbs.addStatement(new JCodeStatement(jlvInput.getName() + " = " + jlvConn.getName() + "." + inStreamName + "();"));
         }
         jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".forget(" + jlvKey.getName() + ");"));
         jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".close();"));
@@ -171,7 +143,7 @@
             if (readMethod != null) {
                 readCall = jlvInput.getName() + "." + readMethod + "()";
             } else {
-                readCall = "(" + jlvRc.getTypeDecl() + ")" + jlvInput.getName() + "." + "readObject( " + _vtc.getValueTypeVarName(jc, jlvRc) + ")";
+                readCall = "(" + jlvRc.getTypeDecl() + ")" + jlvInput.getName() + "." + "readObject( " + vtc.getValueTypeVarName(jc, jlvRc) + ")";
             }
 
             jbs.addStatement(new JCodeStatement(jlvRc.getName() + " = " + readCall + ";"));
@@ -191,200 +163,167 @@
         jfs.addStatement(tcfs);
     }
 
-    // public methods
-
-    public void addMethod_is_a(JClass jc) {
+    protected void addMethod_is_a(JClass jc) {
         JParameter jpID = new JParameter(java.lang.String.class, "id");
-        addMethod(jc, new JReturnType(boolean.class),
+        addMethod(jc, "_is_a", new JReturnType(boolean.class),
                   "_is_a",
                   new JParameter[]{jpID},
                   (Class[]) null);
 
     }
 
-    public void addMethod(Method m, JClass jc) {
+    protected void addMethod(MethodOverload mo, JClass jc) {
+        Method m = mo.method;
+
         String name = m.getName();
         JParameter[] sparms = getMethodParms(m);
 
-        addMethod(jc, new JReturnType(m.getReturnType()),
+        addMethod(jc, mo.iiop_name, new JReturnType(m.getReturnType()),
                   name,
                   sparms,
                   m.getExceptionTypes());
 
     }
 
-    protected Method[] getMethods() {
-        Method myMethods[] = _riClass.getDeclaredMethods();
-        Method myOpsMethods[] = null;
-        Class myInterfaces[] = _riClass.getInterfaces();
-
-        if (myInterfaces != null && myInterfaces.length > 0) {
-            String opsName = _riClass.getName() + "Operations";
-
-            for (int i = 0; i < myInterfaces.length; i++) {
-                if (myInterfaces[i].getName().equals(opsName)) {
-                    myOpsMethods = myInterfaces[i].getDeclaredMethods();
-                    break;
-                }
-            }
-        }
-
-        Method m[] = null;
+    public void generate() throws GenException {
+        GenOptions go = getGenOptions();
+        List interfaces = go.getInterfaces();
+        Iterator intf = null;
 
-        if (myOpsMethods == null) {
-            m = myMethods;
-        } else {
-            m = new Method[myMethods.length + myOpsMethods.length];
-            System.arraycopy(myMethods, 0, m, 0, myMethods.length);
-            System.arraycopy(myOpsMethods, 0, m, myMethods.length, myOpsMethods.length);
+        if (interfaces != null) {
+            intf = interfaces.iterator();
         }
 
-        return m;
-    }
-
-    public void generate()
-            throws Exception {
-        _vtc.clear();
+        JavaGenerator jg = new JavaGenerator(genOptions);
 
-        if (_simpleIDL) {
-            _inStreamName = "getSimpleInputStream";
-            _outStreamName = "getSimpleOutputStream";
+        if (go.isSimpleIdl()) {
+            inStreamName = "getSimpleInputStream";
+            outStreamName = "getSimpleOutputStream";
+        } else {
+            inStreamName = "getInputStream";
+            outStreamName = "getOutputStream";
         }
 
-        JavaGenerator jg = new JavaGenerator(_genOptions);
-
-        String className;
-        JPackage p = new JPackage(JavaClass.getNamePrefix(_stubClassName));
-        className = JavaClass.getNameSuffix(_stubClassName);
+        String riClassName = "";
+        Class  riClass = null;
+        String stubClassName = "";
+        JPackage pkg = null;
 
-        JClass jc = p.newClass(className);
-        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRef");
-        jc.setExtends("ObjectRef");
-        jc.addImplements(_riClass.getName());
+        while (intf != null && intf.hasNext() ) {
+            // Clear the value type cache.
+            vtc.clear();
 
-        JField idsField = jc.newField(String[].class, "_ids", new JExpression(new JCodeStatement("{ \"" + _riClass.getName() + "\", \"RMI:" + _riClass.getName() + ":0000000000000000\"}")), true);
+            riClassName = (String)intf.next();
+            stubClassName = JavaClass.addPackageSuffix(riClassName, "iiop_stubs") + "_Stub";
 
-        JConstructor jcCon = jc.newConstructor((JParameter[]) null, (Class[]) null);
-        jcCon.addStatement(new JCodeStatement("super();"));
+            try {
+                riClass = getClassLoader().loadClass( riClassName );
+            } catch (Exception ex) {
+                throw new GenException( "Generate Stubs Failed:", ex );
+            }
 
-        addMethod_is_a(jc);
+            String pkgName = JavaClass.getNamePrefix(stubClassName);
+            pkg = (JPackage) packages.get( pkgName );
+            if (pkg == null)
+            {
+                pkg = new JPackage( pkgName );
+                packages.put( pkgName, pkg );
+            }
 
-        Method m[] = null;
-        m = getMethods();
-        for (int i = 0; m != null && i < m.length; i++) {
-            addMethod(m[i], jc);
+            String className = JavaClass.getNameSuffix(stubClassName);
+            JClass jc = pkg.newClass(className);
+            jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRef");
+            jc.setExtends("ObjectRef");
+            jc.addImplements(riClass.getName());
+
+            JConstructor jcCon = jc.newConstructor((JParameter[]) null, (Class[]) null);
+            jcCon.addStatement(new JCodeStatement("super();"));
+
+            addMethod_is_a(jc);
+
+            Method m[] = getMethods( riClass, go );
+            MethodOverload mo[] = null;
+            mo = getMethodOverloads( m );
+            for (int i = 0; mo != null && i < mo.length; i++) {
+                addMethod( mo[i], jc );
+            }
         }
 
-        jg.generate(p);
+        Set pkgSet = packages.keySet();
+        Iterator pkgIt = pkgSet.iterator();
+        String stubPkg = "";
+
+        while (pkgIt.hasNext())
+        {
+            stubPkg = (String) pkgIt.next();
+            pkg = (JPackage)packages.get(stubPkg);
+            System.out.println("Generating Package: " + stubPkg);
+            jg.generate(pkg);
+        }
     }
 
     public void compile()
             throws Exception {
-        String className = _riClass.getName();
-        String stubClassName = JavaClass.addPackageSuffix(className, "iiop_stubs");
-        String stubPackage = JavaClass.getNamePrefix(stubClassName);
-
-        System.out.println("Compiling Package: " + stubPackage);
-        System.out.println("Compiling Stub: " + stubClassName);
-
-        String javac = "javac -d ../classes -classpath ../classes;D:/Dev/3rdparty.jag/ejb21/ejb-2_1-api.jar " + stubPackage.replace('.', '/') + "/*.java";
-
-        ProcessUtil pu = ProcessUtil.getInstance();
-        pu.setEcho(System.out);
-        pu.run(javac, (String[]) null, "./src");
-    }
 
-    public Class getStubClass() {
-        System.out.println("StubCompiler.getStubClass(): riClass: " + _riClass);
+        Set pkg = packages.keySet();
+        Iterator pkgIt = pkg.iterator();
+        String stubPkg = "";
 
-        if (_stubClass == null) {
-            try {
-                _stubClass = Class.forName(_stubClassName);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
+        /*
+         * Each of the packages were generated under go.getGenSrcDir().
+         *
+         * Go through all the packages and run the compiler on *.java
+         */
 
-            try {
-                if (_stubClass == null) {
-                    generate();
-                    compile();
-                    _stubClass = Class.forName(_stubClassName);
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
+        GenOptions  go = getGenOptions();
+        String classpath = adjustPath(go.getClasspath());
+        String srcpath = adjustPath(go.getGenSrcDir());
 
-        return _stubClass;
-    }
+        String filesToCompile = "";
+        String javacCmd = "";
 
-    public static void main(String args[])
-            throws Exception {
-        boolean generate = false;
-        boolean compile = false;
-        boolean loadclass = false;
-        boolean simpleidl = false;
-        List interfaces = new LinkedList();
-        GenOptions go = new GenOptions();
-
-        go.setGenDir("./");
-        go.setOverwrite(false);
-        go.setVerbose(false);
-
-        for (int i = 0; i < args.length; i++) {
-            if (args[i].equals("-g")) {
-                generate = true;
-            } else if (args[i].equals("-c")) {
-                compile = true;
-            } else if (args[i].equals("-l")) {
-                loadclass = true;
-            } else if (args[i].equals("-s")) {
-                simpleidl = true;
-            } else if (args[i].equals("-d") && ((i + 1) < args.length)) {
-                go.setGenDir(args[++i]);
-            } else if (args[i].equals("-v")) {
-                go.setVerbose(true);
-            } else if (args[i].equals("-o")) {
-                go.setOverwrite(true);
-            } else if (args[i].startsWith("-")) {
-                System.out.println("Warning: Ignoring unrecognized options: '" + args[i] + "'");
-            } else {
-                interfaces.add(args[i]);
-            }
-        }
+        while (pkgIt.hasNext())
+        {
+            stubPkg = (String) pkgIt.next();
+            stubPkg = stubPkg.replace( '.', File.separatorChar );
+            filesToCompile = adjustPath(go.getGenSrcDir() + File.separator + stubPkg + File.separator + "*.java");
 
-        Iterator i = interfaces.iterator();
-        while (i != null && i.hasNext()) {
-            String intfName = (String) i.next();
-
-            if (intfName.startsWith("RMI:")) {
-                simpleidl = false;
-                intfName = intfName.substring(4);
-            } else if (intfName.startsWith("IDL:")) {
-                simpleidl = true;
-                intfName = intfName.substring(4);
-            }
+            System.out.println("Compiling Package: " + filesToCompile);
 
-            Class riClass = Class.forName(intfName);
-            StubCompiler sg = new StubCompiler(riClass, go);
-            sg.setSimpleIDL(simpleidl);
+            javacCmd = "javac -d " + go.getGenClassDir() +
+                            ( go.isCompileDebug() ? " -g" : "" ) +
+                            " -classpath " + classpath + " " +
+                            " -sourcepath " + srcpath + " " + filesToCompile;
 
-            if (generate) {
-                sg.generate();
-            }
+            System.out.println( "Lauching: " + javacCmd );
 
-            if (compile) {
-                sg.compile();
-            }
+            ProcessUtil pu = ProcessUtil.getInstance();
+            pu.setEcho(System.out);
+            pu.run(javacCmd, (String[]) null, "./" );
+        }
+    }
 
-            if (loadclass) {
-                Class c = sg.getStubClass();
-                System.out.println("StubClass: " + c);
-            }
+    public static void main(String args[]) throws Exception {
+        GenOptions go = null;
+
+        try
+        {
+            go = new GenOptions( "./stubs", args );
+        }
+        catch( GenWarning gw )
+        {
+            gw.printStackTrace();
         }
 
-        // sg.setSimpleIDL( true );
-        // sg.generate( "org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
-    }
+        ClassLoader cl = ClassLoader.getSystemClassLoader();
+        StubCompiler sg = new StubCompiler( go, cl );
+
+        if (go.isGenerate()) {
+            sg.generate();
+        }
 
+        if (go.isCompile()) {
+            sg.compile();
+        }
+    }
 }

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java Wed Mar 23 09:56:34 2005
@@ -24,34 +24,29 @@
 import org.apache.geronimo.interop.util.JavaClass;
 import org.apache.geronimo.interop.util.ThreadContext;
 
-
 public class StubFactory {
-    protected static StubFactory _sf;
+    protected static StubFactory sf;
 
     protected StubFactory() {
     }
 
     public static StubFactory getInstance() {
-        if (_sf == null) {
+        if (sf == null) {
             synchronized (StubFactory.class) {
-                if (_sf == null) {
-                    _sf = new StubFactory();
-                    _sf.init();
+                if (sf == null) {
+                    sf = new StubFactory();
+                    sf.init();
                 }
             }
         }
 
-        return _sf;
+        return sf;
     }
 
-    // private data
-
-    private static HashMap _stubClassMap;
-
-    // internal methods
+    private static HashMap stubClassMap;
 
     protected void init() {
-        _stubClassMap = new HashMap();
+        stubClassMap = new HashMap();
     }
 
     protected Class loadStub(Class remoteInterface) {
@@ -76,9 +71,9 @@
             // Try generating stub class now.
             //
 
-            StubCompiler stubCompiler = new StubCompiler(remoteInterface);
-            System.out.println("StubFactory.loadStub(): stubCompiler: " + stubCompiler);
-            sc = stubCompiler.getStubClass();
+            //StubCompiler stubCompiler = new StubCompiler(remoteInterface);
+            //System.out.println("StubFactory.loadStub(): stubCompiler: " + stubCompiler);
+            //sc = stubCompiler.getStubClass();
             System.out.println("StubFactory.loadStub(): sc: " + sc);
         }
 
@@ -99,20 +94,18 @@
         return sc;
     }
 
-    // public methods
-
     public ObjectRef getStub(Class remoteInterface) {
         System.out.println("StubFactory.getStub(): remoteInterface: " + remoteInterface);
         try {
-            Class sc = (Class) _stubClassMap.get(remoteInterface);
+            Class sc = (Class) stubClassMap.get(remoteInterface);
             System.out.println("StubFactory.getStub(): sc: " + sc);
             if (sc == null) {
-                synchronized (_stubClassMap) {
-                    sc = (Class) _stubClassMap.get(remoteInterface);
+                synchronized (stubClassMap) {
+                    sc = (Class) stubClassMap.get(remoteInterface);
                     if (sc == null) {
                         sc = loadStub(remoteInterface);
                         System.out.println("StubFactory.getStub(): sc: " + sc);
-                        _stubClassMap.put(remoteInterface, sc);
+                        stubClassMap.put(remoteInterface, sc);
                     }
                 }
             }

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java Wed Mar 23 09:56:34 2005
@@ -19,116 +19,98 @@
 
 import java.net.InetAddress;
 import java.net.Socket;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.InputStream;
 
 import org.apache.geronimo.interop.GIOP.*;
 import org.apache.geronimo.interop.IOP.*;
 import org.apache.geronimo.interop.SystemException;
-import org.apache.geronimo.interop.adapter.Adapter;
+import org.apache.geronimo.interop.adapter.HomeAdapter;
 import org.apache.geronimo.interop.adapter.AdapterManager;
+import org.apache.geronimo.interop.adapter.Adapter;
 import org.apache.geronimo.interop.naming.NameService;
-import org.apache.geronimo.interop.properties.BooleanProperty;
-import org.apache.geronimo.interop.properties.SystemProperties;
-import org.apache.geronimo.interop.rmi.iiop.BadMagicException;
-import org.apache.geronimo.interop.rmi.iiop.CdrInputStream;
-import org.apache.geronimo.interop.rmi.iiop.CdrOutputStream;
-import org.apache.geronimo.interop.rmi.iiop.GiopMessage;
-import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
-import org.apache.geronimo.interop.rmi.iiop.UnsupportedProtocolVersionException;
-import org.apache.geronimo.interop.util.ExceptionUtil;
-import org.apache.geronimo.interop.util.ThreadContext;
+import org.apache.geronimo.interop.rmi.iiop.*;
 import org.apache.geronimo.interop.util.UTF8;
+import org.openejb.server.ServiceException;
 
+public class MessageHandler {
 
-public class MessageHandler extends Thread {
-    public static MessageHandler getInstance(ListenerInfo listenerInfo, Socket socket) {
-        MessageHandler object = new MessageHandler();
-        object.init(listenerInfo, socket);
-        return object;
+    private AdapterManager      adapterManager;
+    private boolean             simpleIDL;
+    private boolean             writeSystemExceptionStackTrace;
+    private NameService         nameService = NameService.getInstance();
+
+    public MessageHandler( AdapterManager adapterManager, boolean simpleIDL,
+                           boolean writeSystemExceptionStackTrace )
+    {
+        this.adapterManager = adapterManager;
+        this.simpleIDL = simpleIDL;
+        this.writeSystemExceptionStackTrace = writeSystemExceptionStackTrace;
     }
 
-    // -----------------------------------------------------------------------
-    // properties
-    // -----------------------------------------------------------------------
-
-
-    public static final BooleanProperty simpleIDLProperty =
-            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.simpleIDL");
-
-    public static BooleanProperty writeSystemExceptionStackTraceProperty =
-            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.iiop.writeSystemExceptionStackTrace")
-            .defaultValue(true);
-
-    // -----------------------------------------------------------------------
-    // private data
-    // -----------------------------------------------------------------------
-
-    private static final boolean SIMPLE_IDL = simpleIDLProperty.getBoolean();
-
-    private static boolean _writeSystemExceptionStackTrace = writeSystemExceptionStackTraceProperty.getBoolean();
-
-    private static RequestHandler[] _handlers = new RequestHandler[128];
-
-    private NameService _nameService;
-    private ListenerInfo _listenerInfo;
-    private java.net.Socket _socket;
-    private java.io.InputStream _socketIn;
-    private java.io.OutputStream _socketOut;
-    private String _clientHostName;
-    private String _clientHostAddress;
-    private String _clientInfo;
-    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _objectInput;
-    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _objectOutput;
-    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _simpleInput;
-    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _simpleOutput;
-
-    // -----------------------------------------------------------------------
-    // public methods
-    // -----------------------------------------------------------------------
+    public void service(Socket socket) throws ServiceException, IOException {
 
-    public static void registerHandler(char keyType, RequestHandler handler) {
-        _handlers[keyType] = handler;
-    }
+        InputStream in;
+        OutputStream out;
+
+        String clientHostName;
+        String clientHostAddress;
+        String clientInfo;
+
+        in = socket.getInputStream();
+        out = socket.getOutputStream();
+
+        InetAddress addr = socket.getInetAddress();
+        clientHostName = addr.getHostName();
+        clientHostAddress = addr.getHostAddress();
+        clientInfo = clientHostName;
+
+        if (!clientHostAddress.equals(clientHostName)) {
+            clientInfo += " (" + clientHostAddress + ")";
+        }
 
-    public void run() {
-        ThreadContext.setDefaultRmiHost(_listenerInfo.host);
-        ThreadContext.setDefaultRmiPort(_listenerInfo.port);
         boolean firstMessage = true;
         CdrInputStream input = CdrInputStream.getInstance();
         CdrOutputStream output = CdrOutputStream.getInstance();
         CdrOutputStream results = CdrOutputStream.getInstance();
+
         for (; ;) {
             boolean sendResponse = true;
             GiopMessage inputMessage;
+
             try {
-                inputMessage = input.receive_message(_socketIn, _clientInfo);
+                inputMessage = input.receive_message( in, clientInfo );
                 firstMessage = false;
             } catch (BadMagicException ex) {
                 if (firstMessage) {
-                    warnBadMagic(_clientInfo, ex);
+                    warnBadMagic(clientInfo, ex);
                 } else {
-                    warnBadMagicBadSize(_clientInfo, ex);
+                    warnBadMagicBadSize(clientInfo, ex);
                 }
-                closeSocket();
+                closeStreams( in, out );
                 return;
             } catch (UnsupportedProtocolVersionException ex) {
-                warnGiopVersion(_clientInfo, ex);
-                closeSocket();
+                warnGiopVersion( clientInfo, ex);
+                closeStreams( in, out );
                 return;
             } catch (Exception ex) {
                 if (input.getOffset() > 0) {
                     ex.printStackTrace();
-                    warnReceiveFailed(_clientInfo, ex);
+                    warnReceiveFailed( clientInfo, ex);
                 }
                 // Otherwise client shutdown was not in the middle of a
                 // request, i.e. probably 'normal' and unworthy of a
                 // log message.
-                closeSocket();
+                closeStreams( in, out );
                 return;
             }
+
             output.setGiopVersion(input.getGiopVersion());
+
             switch (inputMessage.type) {
                 case MsgType_1_1._Request:
-                    processRequest(input, output, results, inputMessage.request);
+                    processRequest(input, output, results, inputMessage.request, clientInfo);
                     if ((inputMessage.request.response_flags & 1) == 0) {
                         sendResponse = false; // oneway request
                     }
@@ -139,63 +121,37 @@
                 default:
                     throw new SystemException("TODO: message type = " + inputMessage.type);
             }
+
             if (sendResponse) {
                 try {
-                    output.send_message(_socketOut, _clientInfo);
+                    output.send_message( out, clientInfo );
                 } catch (Exception ex) {
-                    warnSendFailed(_clientInfo, ex);
-                    closeSocket();
+                    warnSendFailed(clientInfo, ex);
+                    closeStreams( in, out );
                     return;
                 }
             }
+
             input.reset();
             output.reset();
             results.reset();
         }
     }
 
-    // -----------------------------------------------------------------------
-    // protected methods
-    // -----------------------------------------------------------------------
-
-    protected void init(ListenerInfo listenerInfo, Socket socket) {
-        setDaemon(true);
-        _nameService = NameService.getInstance();
-        _listenerInfo = listenerInfo;
-        _socket = socket;
+    protected void closeStreams( InputStream in, OutputStream out ) {
         try {
-            _socketIn = _socket.getInputStream();
-            _socketOut = _socket.getOutputStream();
-            InetAddress addr = _socket.getInetAddress();
-            _clientHostName = addr.getHostName();
-            _clientHostAddress = addr.getHostAddress();
-            _clientInfo = _clientHostName;
-            if (!_clientHostAddress.equals(_clientHostName)) {
-                _clientInfo += " (" + _clientHostAddress + ")";
-            }
-        } catch (Throwable ex) {
-            closeSocket();
-            throw ExceptionUtil.rethrow(ex);
-        }
-    }
-
-    protected void closeSocket() {
-        try {
-            if (_socketIn != null) {
-                _socketIn.close();
+            if (in != null) {
+                in.close();
             }
         } catch (Exception ignore) {
         }
+
         try {
-            if (_socketOut != null) {
-                _socketOut.close();
+            if (out != null) {
+                out.close();
             }
         } catch (Exception ignore) {
         }
-        try {
-            _socket.close();
-        } catch (Exception ignore) {
-        }
     }
 
     protected byte[] getObjectKey(TargetAddress target) {
@@ -210,25 +166,23 @@
         }
     }
 
-    protected void processRequest(CdrInputStream parameters, CdrOutputStream output, CdrOutputStream results, RequestHeader_1_2 request) {
+    protected void processRequest(CdrInputStream parameters,
+                                  CdrOutputStream output,
+                                  CdrOutputStream results,
+                                  RequestHeader_1_2 request,
+                                  String clientInfo
+                                  ) {
         byte[] objectKey = getObjectKey(request.target);
         int keyLength = objectKey.length;
         int keyType = keyLength == 0 ? 0 : objectKey[0];
-        if (keyType >= 'A' && keyType <= 'Z') {
-            RequestHandler handler = _handlers[keyType];
-            if (handler != null) {
-                handler.processRequest(objectKey, request.operation, parameters, output);
-                return;
-            }
-        }
 
         ReplyHeader_1_2 reply = new ReplyHeader_1_2();
         reply.request_id = request.request_id;
 
-        org.apache.geronimo.interop.rmi.iiop.ObjectInputStream objectIn;
-        org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream objectOut;
+        ObjectInputStream objectIn;
+        ObjectOutputStream objectOut;
 
-        if (SIMPLE_IDL || keyType == 'N' || keyType == 'J') {
+        if (simpleIDL || keyType == 'N' || keyType == 'J') {
             // Name Service and JMS use simple IDL interoperability.
             objectIn = org.apache.geronimo.interop.rmi.iiop.SimpleObjectInputStream.getInstance(parameters);
             objectOut = org.apache.geronimo.interop.rmi.iiop.SimpleObjectOutputStream.getInstance(results);
@@ -255,82 +209,38 @@
                 objectName = UTF8.toString(objectKey);
             }
 
-            /*
-            if (objectName.startsWith("EJB~"))
-            {
-                // Compact encoding of component class names,
-                // saves 11 bytes per request.
-                objectName = "ejb.components." + objectName.substring(4);
-            }
-            */
-
             processServiceContext(request);
 
-            /*
             Object object;
             try
             {
-                object = null; //_nameService.lookup(objectName);
+                object = nameService.lookup(objectName);
             }
             catch (javax.naming.NameNotFoundException notFound)
             {
-                warnLookupFailed(_clientInfo, notFound);
+                warnLookupFailed(clientInfo, notFound);
                 throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
             }
 
-            if (object instanceof RemoteInterface)
+            Adapter adapter = (Adapter)object;
+            if (adapter != null)
             {
-                RemoteInterface skeleton = ((RemoteInterface)object).$getSkeleton();
-                skeleton.$invoke(request.operation, objectKey, objectIn, objectOut);
-                if (objectOut.hasException())
-                {
-                    reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
-                }
-                else
-                {
-                    reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
-                }
-                output.write_reply(reply, results);
-            }
-            else
-            {
-                warnInvokeFailedNoRemoteInterface(_clientInfo, object, object.getClass());
-                throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
-            }
-            */
-
-            Object object;
-            try {
-                object = _nameService.lookup(objectName);
-            } catch (javax.naming.NameNotFoundException notFound) {
-                object = AdapterManager.getInstance().getAdapter(objectName);
-
-                if (object == null) {
-                    warnLookupFailed(_clientInfo, notFound);
-                    throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
-                }
-            }
-
-//            Adapter a = AdapterManager.getInstance().getAdapter(objectName);
-//            if (a != null)
-            if (object != null && object instanceof Adapter) {
-                Adapter a = (Adapter) object;
-                //RemoteInterface skeleton = a.getRemoteInterface();
-                a.invoke(request.operation, objectKey, objectIn, objectOut);
+                adapter.invoke(request.operation, objectKey, objectIn, objectOut);
 
                 if (objectOut.hasException()) {
                     reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
                 } else {
                     reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
                 }
+
                 output.write_reply(reply, results);
             } else {
                 throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
             }
         } catch (Exception ex) {
-            warnSystemException(_clientInfo, ex);
+            warnSystemException(clientInfo, ex);
             results = CdrOutputStream.getInstance(); // in case we already wrote to it
-            results.write_SystemException(ex, _writeSystemExceptionStackTrace);
+            results.write_SystemException(ex, writeSystemExceptionStackTrace);
             reply.reply_status = ReplyStatusType_1_2.SYSTEM_EXCEPTION;
             output.write_reply(reply, results);
         }
@@ -365,26 +275,9 @@
                 password = SecurityInfo.decode(context.context_data);
             }
             */
-            // Otherwise OK to ignore unknown tags.
-        }
 
-        // Default security info.
-        /*
-        if (username == null)
-        {
-            username = User.GUEST;
-        }
-        if (password == null)
-        {
-            password = "";
+            // TODO: Is the ServiceContext a CSIv2 Security Context?
         }
-
-        // Check if the password is correct.
-        User user = User.getInstance(username);
-        user.login(password); // may throw SecurityException
-        User.setCurrent(user);
-        SimpleSubject.setCurrent(new SimpleSubject(username, password));
-        */
     }
 
     // log methods

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RmiIiopServerGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RmiIiopServerGBean.java?view=auto&rev=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RmiIiopServerGBean.java (added)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RmiIiopServerGBean.java Wed Mar 23 09:56:34 2005
@@ -0,0 +1,157 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.interop.rmi.iiop.server;
+
+import org.apache.geronimo.gbean.*;
+import org.apache.geronimo.interop.adapter.AdapterManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.openejb.server.SocketService;
+import org.openejb.server.ServerService;
+import org.openejb.server.ServiceException;
+
+import java.util.*;
+import java.net.Socket;
+import java.io.IOException;
+
+public class RmiIiopServerGBean implements ServerService {
+
+    private final Log log = LogFactory.getLog(RmiIiopServerGBean.class);
+
+    private MessageHandler          msgHandler;
+    private ArrayList               args = new ArrayList();
+    private Properties              props = new Properties();
+    private boolean                 simpleIDL = false;
+    private boolean                 writeSystemExceptionStackTrace = false;
+    private AdapterManager          adapterManager;
+
+    public RmiIiopServerGBean(AdapterManager adapterManager, ArrayList args, Properties props,
+                              boolean simpleIDL, boolean writeSystemExceptionStackTrace ) {
+        this.adapterManager = adapterManager;
+        this.args = args;
+        this.props = props;
+        this.simpleIDL = simpleIDL;
+        this.writeSystemExceptionStackTrace = writeSystemExceptionStackTrace;
+        this.msgHandler = new MessageHandler( this.adapterManager, this.simpleIDL,
+                                              this.writeSystemExceptionStackTrace );
+
+    }
+
+    public RmiIiopServerGBean() throws Exception {
+        this.adapterManager = null;
+        this.args = null;
+        this.props = null;
+        this.simpleIDL = false;
+        this.writeSystemExceptionStackTrace = false;
+        this.msgHandler = null;
+    }
+
+    public void service(Socket socket) throws ServiceException, IOException {
+        log.debug( "RmiIiopServerGBean.service(): socket = " + socket );
+        msgHandler.service(socket);
+    }
+
+    public void init(Properties properties) throws Exception
+    {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void start() throws ServiceException {
+        log.debug( "RmiIiopServerGBean.start(): " );
+    }
+
+    public void stop() throws ServiceException {
+        log.debug( "RmiIiopServerGBean.stop(): " );
+    }
+
+    public String getName() {
+        return "rmiiiopd";
+    }
+
+    /*
+    public void setArgs( ArrayList args )
+    {
+        this.args = args;
+    }
+
+    public ArrayList getArgs() {
+        return args;
+    }
+
+    public void setProps( Properties props )
+    {
+        this.props = props;
+    }
+
+    public Properties getProps() {
+        return props;
+    }
+    */
+
+    /*
+     * The following methods are from ServerService...
+     * getPort() and getIP() ... Do we need them??
+     */
+
+    private int port;
+    private String ip;
+
+    public void setPort( int port )
+    {
+        log.debug( "RmiIiopServerGBean.setPort(): port = " + port );
+        this.port = port;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setIP( String ip )
+    {
+        log.debug( "RmiIiopServerGBean.setIP(): ip = " + ip );
+        this.ip = ip;
+    }
+
+    public String getIP() {
+        return "";
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(RmiIiopServerGBean.class);
+
+        infoFactory.addInterface(SocketService.class);
+
+        infoFactory.addAttribute("args", ArrayList.class, true);
+        infoFactory.addAttribute("props", Properties.class, true);
+        infoFactory.addAttribute("simpleIDL", boolean.class, true);
+        infoFactory.addAttribute("writeSystemExceptionStackTrace", boolean.class, true);
+        infoFactory.addReference("adapterManager", AdapterManager.class);
+
+        infoFactory.setConstructor(new String[]{"adapterManager", "args", "props", "simpleIDL", "writeSystemExceptionStackTrace"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}
+

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java Wed Mar 23 09:56:34 2005
@@ -20,10 +20,7 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
-import org.apache.geronimo.interop.CosNaming.BindingIteratorHolder;
-import org.apache.geronimo.interop.CosNaming.BindingListHolder;
-import org.apache.geronimo.interop.CosNaming.NameComponent;
-import org.apache.geronimo.interop.CosNaming.NamingContext;
+import org.apache.geronimo.interop.CosNaming.*;
 import org.apache.geronimo.interop.CosNaming.NamingContextExtPackage.InvalidAddress;
 import org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound;
 import org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed;
@@ -33,41 +30,22 @@
 import org.apache.geronimo.interop.adapter.Adapter;
 import org.apache.geronimo.interop.naming.NameService;
 import org.apache.geronimo.interop.naming.NameServiceLog;
-import org.apache.geronimo.interop.rmi.iiop.RemoteInterface;
+import org.apache.geronimo.interop.rmi.iiop.CorbaObject;
 
+public class ServerNamingContext extends CorbaObject implements NamingContextExt {
 
-public class ServerNamingContext implements org.apache.geronimo.interop.rmi.iiop.NameServiceOperations {
-    
-    protected static ServerNamingContext _snc = null;
+    private NameService                     nameService;
+    protected static ServerNamingContext    snc = null;
 
-    public static ServerNamingContext getInstance() {
-        if (_snc == null) {
-            synchronized (ServerNamingContext.class) {
-                _snc = new ServerNamingContext();
-                _snc.init();
-            }
-        }
-
-        return _snc;
+    public ServerNamingContext()
+    {
+        nameService = NameService.getInstance();
     }
 
-    // -----------------------------------------------------------------------
-    // private data
-    // -----------------------------------------------------------------------
-
-    private NameService _nameService;
-
-    private volatile int _cycle;
-
-    // -----------------------------------------------------------------------
-    // public methods from interface NamingContextExtOperations
-    // -----------------------------------------------------------------------
-
     public org.omg.CORBA.Object resolve_str(String name) throws NotFound, CannotProceed, InvalidName {
         return lookup(name, null);
     }
 
-
     public String to_string(NameComponent[] n) throws InvalidName {
         throw NoImplement();
     }
@@ -80,10 +58,6 @@
         throw NoImplement();
     }
 
-    // -----------------------------------------------------------------------
-    // public methods from interface NamingContextOperations
-    // -----------------------------------------------------------------------
-
     public org.omg.CORBA.Object resolve(NameComponent[] name) throws NotFound, CannotProceed, InvalidName {
         return lookup(toString(name), name);
     }
@@ -124,51 +98,15 @@
         return new org.omg.CORBA.NO_IMPLEMENT();
     }
 
-    // -----------------------------------------------------------------------
-    // public methods from interface NameServiceOperations (Sybase proprietary)
-    // -----------------------------------------------------------------------
-
-    public String resolve_host(String host) {
-        System.out.println("ServerNamingContext.resolve_host(): TODO host = " + host);
-
-        //String resolvedHost = ClusterPartition.getInstance(host).resolveHost();
-        //return "cycle=" + Math.max(1, ++_cycle) + ";" + resolvedHost;
-        
-        // Cycle prefix for round-robin load balancing.
-        // Any weighted balancing is applied by client.
-
-        return host;
-    }
-
-    // -----------------------------------------------------------------------
-    // protected methods
-    // -----------------------------------------------------------------------
-
-    protected void init() {
-        _nameService = NameService.getInstance();
-    }
-
     protected org.omg.CORBA.Object lookup(String nameString, NameComponent[] name) throws NotFound {
         try {
-            Object object = _nameService.lookup(nameString);
-
-            /*
-            if (object instanceof RemoteInterface)
-            {
-                RemoteInterface remote = (RemoteInterface)object;
-                return remote.$getObjectRef();
-            }
-            else
-            {
-                NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName());
-                throw new NotFound(NotFoundReason.not_object, name);
-            }
-            */
+            Object object = nameService.lookup(nameString);
 
             if (object instanceof Adapter) {
                 Adapter a = (Adapter) object;
-                RemoteInterface remote = a.getRemoteInterface();
-                return remote.$getObjectRef();
+                //RemoteInterface remote = a.getRemoteInterface();
+                //return remote.$getObjectRef();
+                return a.getObjectRef();
             } else {
                 NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName());
                 throw new NotFound(NotFoundReason.not_object, name);

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java Wed Mar 23 09:56:34 2005
@@ -1,128 +0,0 @@
-/**
- *
- *  Copyright 2004-2005 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.geronimo.interop.rmi.iiop.server;
-
-import java.net.InetAddress;
-import java.net.Socket;
-
-import org.apache.geronimo.interop.SystemException;
-import org.apache.geronimo.interop.properties.SystemProperties;
-import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
-import org.apache.geronimo.interop.rmi.iiop.Protocol;
-
-
-public class SocketListener extends Thread {
-    public static SocketListener getInstance() {
-        return new SocketListener();
-    }
-
-    // private data
-
-    private String _name;
-
-    private String _host;
-
-    private int _port;
-
-    private int _listenBacklog;
-
-    private java.net.ServerSocket _listener;
-
-    // internal methods
-
-    protected void init() {
-        _host = "localhost";
-        _port = 2000;
-        _listenBacklog = 10;
-        setDaemon(true);
-    }
-
-    // public methods
-
-    public void setHost(String host) {
-        _host = host;
-    }
-
-    public void setPort(int port) {
-        _port = port;
-    }
-
-    public void setListenBacklog(int backlog) {
-        _listenBacklog = backlog;
-    }
-
-    public void run() {
-        String iiopURL = "iiop://" + _host + ":" + _port;
-        ListenerInfo listenerInfo = new ListenerInfo();
-        listenerInfo.protocol = Protocol.IIOP; // TODO: other protocols (IIOPS etc.)
-        listenerInfo.host = _host;
-        listenerInfo.port = _port;
-        try {
-            InetAddress addr = InetAddress.getByName(_host);
-            _listener = new java.net.ServerSocket(_port, _listenBacklog, addr);
-        } catch (Exception ex) {
-            System.out.println("SocketListener: Error creating server socket.");
-            ex.printStackTrace();
-            try {
-                Socket socket = new Socket(_host, _port);
-                socket.close();
-                System.out.println("SocketListener: Error server already running: " + iiopURL);
-                ex.printStackTrace();
-            } catch (Exception ignore) {
-            }
-            return;
-        }
-        new CheckConnect().start();
-        for (; ;) {
-            java.net.Socket socket;
-            try {
-                socket = _listener.accept();
-            } catch (Exception ex) {
-                throw new SystemException(ex); // TODO: log error message
-            }
-            MessageHandler.getInstance(listenerInfo, socket).start();
-        }
-    }
-
-    private class CheckConnect extends Thread {
-        public void run() {
-            try {
-                Socket socket = new Socket(_host, _port);
-                socket.close();
-                if (!SystemProperties.quiet()) {
-                    System.out.println(formatAcceptingIiopConnections());
-                }
-            } catch (Exception ex) {
-                warnConnectFailed(_host, _port);
-            }
-        }
-    }
-
-    // format methods
-
-    protected String formatAcceptingIiopConnections() {
-        String msg = "SocketListener.formatAcceptingIiopConnection(): ";
-        return msg;
-    }
-
-    // log methods
-
-    protected void warnConnectFailed(String host, int port) {
-        System.out.println("SocketListener.warnConnectFailed(): host = " + host + ", port = " + port);
-    }
-}

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java Wed Mar 23 09:56:34 2005
@@ -1,166 +0,0 @@
-/**
- *
- *  Copyright 2004-2005 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.geronimo.interop.server;
-
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-import org.apache.geronimo.interop.adapter.Adapter;
-import org.apache.geronimo.interop.adapter.AdapterManager;
-import org.apache.geronimo.interop.naming.NameService;
-import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
-import org.apache.geronimo.interop.rmi.iiop.server.MessageHandler;
-
-
-public class IIOPDaemon implements Runnable {
-    protected String _host = "localhost";
-    protected int _port = 9000;
-    protected String _name = "IIOP";
-    protected ServerSocket _ss = null;
-    protected boolean _ready = false;
-
-    public void setHost(String host) {
-        _host = host;
-    }
-
-    public String getHost() {
-        return _host;
-    }
-
-    public void setPort(int port) {
-        _port = port;
-    }
-
-    public int getPort() {
-        return _port;
-    }
-
-    public void setName(String name) {
-        _name = name;
-    }
-
-    public String getName() {
-        return _name;
-    }
-
-    public void setReady() {
-        _ready = true;
-    }
-
-    public boolean isReady() {
-        return _ready;
-    }
-
-    public ServerSocket getServerSocket() {
-        if (_ss == null) {
-            synchronized (this) {
-                try {
-                    InetSocketAddress isa = new InetSocketAddress(_host, _port);
-                    _ss = new ServerSocket();
-                    _ss.bind(isa);
-                    setReady();
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            }
-        }
-
-        return _ss;
-    }
-
-    public void run() {
-        ListenerInfo li = new ListenerInfo();
-        li.protocol = 1;
-        li.host = getHost();
-        li.port = getPort();
-
-        ServerSocket ss = getServerSocket();
-        Socket s = null;
-        System.out.println("[" + getName() + "-" + getHost() + ":" + getPort() + "] Accepting Connections...");
-        while (isReady()) {
-            try {
-                s = ss.accept();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-
-            MessageHandler mh;
-            mh = MessageHandler.getInstance(li, s);
-            mh.start();
-        }
-    }
-
-    public static void main(String args[]) {
-        IIOPDaemon id = new IIOPDaemon();
-        id.setHost("localhost");
-        id.setPort(9000);
-
-        Thread t = new Thread(id);
-        t.setName(id.getName() + " Daemon");
-        t.start();
-
-        NameService ns = NameService.getInstance();
-        AdapterManager am = AdapterManager.getInstance();
-
-        //
-        // NameService
-        //
-        Adapter a = new Adapter();
-        a.setBindName("NameService");
-        a.setRemoteClassName("org.apache.geronimo.interop.rmi.iiop.server.ServerNamingContext");
-        a.setRemoteInterfaceName("org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
-        a.setShared(true);
-        a.addId("IDL:org.apache.geronimo.interop/rmi/iiop/NameService:1.0");
-        a.addId("IDL:omg.org/CosNaming/NamingContext:1.0");
-        a.addId("IDL:omg.org/CosNaming/NamingContextExt:1.0");
-        a.addId("NameService"); // this gets passed in by the J2SE 1.4 ORB
-        a.setClassLoader(id.getClass().getClassLoader());
-        //a.generateSkels();
-        //a.compileSkels();
-
-        am.registerAdapter(a);
-        ns.bindAdapter(a);
-
-        //
-        // Component
-        //
-        a = new Adapter();
-        a.setBindName("mark.comps.Add");
-        a.setRemoteClassName("mark.comps.AddImpl");
-        a.setRemoteInterfaceName("mark.comps.Add");
-        a.addId("RMI:mark.comps.Add:0000000000000000");
-        a.setClassLoader(id.getClass().getClassLoader());
-
-        am.registerAdapter(a);
-        ns.bindAdapter(a);
-
-        //
-        // Component
-        //
-        a = new Adapter();
-        a.setBindName("mark.comps.Add2");
-        a.setRemoteClassName("mark.comps.Add2Impl");
-        a.setRemoteInterfaceName("mark.comps.Add2");
-        a.addId("RMI:mark.comps.Add2:0000000000000000");
-        a.setClassLoader(id.getClass().getClassLoader());
-
-        am.registerAdapter(a);
-        ns.bindAdapter(a);
-    }
-}

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java Wed Mar 23 09:56:34 2005
@@ -1,33 +0,0 @@
-/**
- *
- *  Copyright 2004-2005 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.geronimo.interop.server;
-
-
-
-
-public class IIOPSDaemon extends IIOPDaemon {
-    public static void main(String args[]) {
-        IIOPSDaemon id = new IIOPSDaemon();
-        id.setName("IIOPS");
-        id.setHost("localhost");
-        id.setPort(9000);
-
-        Thread t = new Thread(id);
-        t.start();
-    }
-}

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java Wed Mar 23 09:56:34 2005
@@ -26,9 +26,6 @@
 
 
 public abstract class JavaClass {
-    // -----------------------------------------------------------------------
-    // properties
-    // -----------------------------------------------------------------------
 
     public static final StringProperty classDirProperty =
             new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.classDir")
@@ -48,21 +45,10 @@
                           + File.pathSeparator
                           + FileUtil.pretty(SystemProperties.getHome() + "/genfiles/java/src"));
 
-    // -----------------------------------------------------------------------
-    // private data
-    // -----------------------------------------------------------------------
-
     private static String _classDir = classDirProperty.getString();
-
     private static List _classPath = ListUtil.getPathList(classPathProperty.getString());
-
     private static String _sourceDir = sourceDirProperty.getString();
-
     private static List _sourcePath = ListUtil.getPathList(sourcePathProperty.getString());
-
-    // -----------------------------------------------------------------------
-    // public methods
-    // -----------------------------------------------------------------------
 
     public static String addPackageSuffix(String className, String suffix) {
         String jp = getPackagePrefix(className);

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java?view=diff&r1=158813&r2=158814
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java (original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java Wed Mar 23 09:56:34 2005
@@ -54,6 +54,11 @@
         return _isJDK14;
     }
 
+    public static String getVmVersion()
+    {
+        return _vmVersion;
+    }
+
     public static boolean isWindows() {
         return java.io.File.separatorChar == '\\';
     }



Mime
View raw message