Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 42446 invoked from network); 24 Mar 2005 02:58:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Mar 2005 02:58:58 -0000 Received: (qmail 83392 invoked by uid 500); 24 Mar 2005 02:58:58 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 83373 invoked by uid 500); 24 Mar 2005 02:58:58 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 83356 invoked by uid 99); 24 Mar 2005 02:58:57 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 23 Mar 2005 18:58:56 -0800 Received: (qmail 32197 invoked by uid 65534); 24 Mar 2005 02:30:55 -0000 Message-ID: <20050324023055.32195.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Thu, 24 Mar 2005 02:30:54 -0000 Subject: svn commit: r158862 [8/9] - in geronimo/trunk/modules/interop: ./ src/idl/ src/java/org/apache/geronimo/interop/ src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/ src/java/org/apache/geronimo/interop/adapter/ src/java/org/apache/geronimo/interop/client/ src/java/org/apache/geronimo/interop/generator/ src/java/org/apache/geronimo/interop/naming/ src/java/org/apache/geronimo/interop/properties/ src/java/org/apache/geronimo/interop/repository/ src/java/org/apache/geronimo/interop/rmi/iiop/ src/java/org/apache/geronimo/interop/rmi/iiop/client/ src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ src/java/org/apache/geronimo/interop/rmi/iiop/server/ src/java/org/apache/geronimo/interop/server/ src/java/org/apache/geronimo/interop/util/ To: scm@geronimo.apache.org From: adc@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/inter= op/rmi/iiop/compiler/Compiler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/= org/apache/geronimo/interop/rmi/iiop/compiler/Compiler.java?view=3Ddiff&r1= =3D158861&r2=3D158862 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi= /iiop/compiler/Compiler.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi= /iiop/compiler/Compiler.java Wed Mar 23 18:30:30 2005 @@ -18,74 +18,97 @@ package org.apache.geronimo.interop.rmi.iiop.compiler; =20 import java.lang.reflect.Method; -import java.util.*; -import java.io.File; +import java.util.HashMap; =20 import org.apache.geronimo.interop.generator.GenOptions; import org.apache.geronimo.interop.generator.JParameter; import org.apache.geronimo.interop.generator.JVariable; =20 -public class Compiler { - protected GenOptions genOptions; - - private ClassLoader classLoader; =20 - private static HashMap readMethods; - private static HashMap writeMethods; - private static HashMap overloadTypes; +public class Compiler { + protected Class _riClass; + protected GenOptions _genOptions; + protected ClassLoader _cl; + protected boolean _simpleIDL =3D false; + + protected static HashMap _readMethods; + protected static HashMap _writeMethods; + protected static HashMap _overloadTypes; =20 static { - readMethods =3D new HashMap(); - readMethods.put("boolean", "readBoolean"); - readMethods.put("char", "readChar"); - readMethods.put("byte", "readByte"); - readMethods.put("short", "readShort"); - readMethods.put("int", "readInt"); - readMethods.put("long", "readLong"); - readMethods.put("float", "readFloat"); - readMethods.put("double", "readDouble"); - - writeMethods =3D new HashMap(); - writeMethods.put("boolean", "writeBoolean"); - writeMethods.put("char", "writeChar"); - writeMethods.put("byte", "writeByte"); - writeMethods.put("short", "writeShort"); - writeMethods.put("int", "writeInt"); - writeMethods.put("long", "writeLong"); - writeMethods.put("float", "writeFloat"); - writeMethods.put("double", "writeDouble"); - - overloadTypes =3D new HashMap(); - overloadTypes.put("boolean", "boolean"); - overloadTypes.put("byte", "octet"); - overloadTypes.put("char", "wchar"); - overloadTypes.put("double", "double"); - overloadTypes.put("float", "float"); - overloadTypes.put("int", "long"); - overloadTypes.put("long", "long_long"); - overloadTypes.put("short", "short"); - overloadTypes.put("java.lang.Class", "javax_rmi_CORBA.ClassDesc"); - overloadTypes.put("java.lang.String", "CORBA.WStringValue"); - overloadTypes.put("org.omg.CORBA.Object", "Object"); - overloadTypes.put("org.omg.CORBA.Any", "org_omg_boxedIDL_CORBA.Any= "); - overloadTypes.put("org.omg.CORBA.TypeCode", "org_omg_boxedIDL_CORB= A=2ETypeCode"); - } + _readMethods =3D new HashMap(); + _readMethods.put("boolean", "readBoolean"); + _readMethods.put("char", "readChar"); + _readMethods.put("byte", "readByte"); + _readMethods.put("short", "readShort"); + _readMethods.put("int", "readInt"); + _readMethods.put("long", "readLong"); + _readMethods.put("float", "readFloat"); + _readMethods.put("double", "readDouble"); + + _writeMethods =3D new HashMap(); + _writeMethods.put("boolean", "writeBoolean"); + _writeMethods.put("char", "writeChar"); + _writeMethods.put("byte", "writeByte"); + _writeMethods.put("short", "writeShort"); + _writeMethods.put("int", "writeInt"); + _writeMethods.put("long", "writeLong"); + _writeMethods.put("float", "writeFloat"); + _writeMethods.put("double", "writeDouble"); + + _overloadTypes =3D new HashMap(); + _overloadTypes.put("boolean", "boolean"); + _overloadTypes.put("byte", "octet"); + _overloadTypes.put("char", "wchar"); + _overloadTypes.put("double", "double"); + _overloadTypes.put("float", "float"); + _overloadTypes.put("int", "long"); + _overloadTypes.put("long", "long_long"); + _overloadTypes.put("short", "short"); + _overloadTypes.put("java.lang.Class", "javax_rmi_CORBA.ClassDesc")= ; + _overloadTypes.put("java.lang.String", "CORBA.WStringValue"); + _overloadTypes.put("org.omg.CORBA.Object", "Object"); + _overloadTypes.put("org.omg.CORBA.Any", "org_omg_boxedIDL_CORBA.An= y"); + _overloadTypes.put("org.omg.CORBA.TypeCode", "org_omg_boxedIDL_COR= BA.TypeCode"); + } + + public Compiler(Class remoteInterface) { + this(remoteInterface, null); + } + + public Compiler(Class riClass, GenOptions go) { + _riClass =3D riClass; + + _cl =3D _riClass.getClassLoader(); + if (_cl =3D=3D null) { + _cl =3D ClassLoader.getSystemClassLoader(); + } + + if (go =3D=3D null) { + go =3D new GenOptions(); + } + + _genOptions =3D go; + } + + // + // Properties + // =20 - public Compiler(GenOptions go, ClassLoader cl) { - classLoader =3D cl; - if (classLoader =3D=3D null) { - classLoader =3D ClassLoader.getSystemClassLoader(); - } + public boolean isSimpleIDL() { + return _simpleIDL; + } =20 - genOptions =3D go; + public void setSimpleIDL(boolean simpleIDL) { + _simpleIDL =3D simpleIDL; } =20 public GenOptions getGenOptions() { - return genOptions; + return _genOptions; } =20 - public ClassLoader getClassLoader() { - return classLoader; + public void setGenOptions(GenOptions genOptions) { + _genOptions =3D genOptions; } =20 public JParameter[] getMethodParms(Method m) { @@ -108,7 +131,7 @@ String rc =3D null; =20 if (v !=3D null) { - rc =3D (String) readMethods.get(v.getTypeDecl()); + rc =3D (String) _readMethods.get(v.getTypeDecl()); } =20 return rc; @@ -118,191 +141,11 @@ String rc =3D null; =20 if (v !=3D null) { - rc =3D (String) writeMethods.get(v.getTypeDecl()); + rc =3D (String) _writeMethods.get(v.getTypeDecl()); } =20 return rc; } =20 - protected static void error( String errMsg ) { - System.err.println( "Error: " + errMsg ); - System.exit(1); - } - - protected void error(String msg, Throwable t) { - error(msg); - t.printStackTrace(); - } - - protected static void warn( String warnMsg ) { - System.out.println( "Warning: " + warnMsg ); - } - - protected String adjustPath( String path ) - { - // Maybe it would be easier if GenOptions just made sure that plat= form path - // separators and file separators were as required on the platform= ? - =20 - if (File.separatorChar =3D=3D '/') { - // We're under Unix, change '\\' to '/' - return path.replace( '\\', '/' ); - } else { - // We're under Windows, change '/' to '\\' - return path.replace( '/', '\\' ); - } - } - - protected void addMethodsToList( ArrayList list, Method[] methods ) - { - for(int i=3D0; list !=3D null && methods !=3D null && i < methods.= length; i++ ) - { - list.add( methods[i] ); - } - } - - protected void collectInterfaceMethods( ArrayList list, Class intfClas= s, boolean simpleIdl ) - { - Method myMethods[] =3D intfClass.getDeclaredMethods(); - - if (!simpleIdl) - { - addMethodsToList( list, myMethods ); - } - - Class myInterfaces[] =3D intfClass.getInterfaces(); - if (myInterfaces !=3D null && myInterfaces.length > 0) - { - String opsName =3D intfClass.getName() + "Operations"; - - for (int i =3D 0; i < myInterfaces.length; i++) - { - if (simpleIdl) - { - // add interface and its Operations, only if there is = a coresponding Operations - if (myInterfaces[i].getName().equals(opsName)) - { - addMethodsToList( list, myMethods ); - addMethodsToList( list, myInterfaces[i].getDeclare= dMethods() ); - continue; - } - else - { - collectInterfaceMethods( list, myInterfaces[i], si= mpleIdl ); - } - } - else - { - // Collect the interface methods for all interfaces .. - collectInterfaceMethods( list, myInterfaces[i], simple= Idl ); - } - } - } - } - - protected Method[] getMethods( Class intfClass, GenOptions go ) - { - Method myMethods[] =3D intfClass.getDeclaredMethods(); - ArrayList list =3D new ArrayList( myMethods.length * 2 ); - - collectInterfaceMethods( list, intfClass, go.isSimpleIdl() ); - - Object[] objs =3D list.toArray(); - Method[] methods =3D new Method[objs.length]; - System.arraycopy( objs, 0, methods, 0, objs.length ); =20 - return methods; - } - - public MethodOverload[] getMethodOverloads( Method methods[] ) - { - HashMap hm =3D new HashMap( methods.length ); - - // Put all the methods into the hashmap - for( int i=3D0; methods !=3D null && i < methods.length; i++ ) - { - ArrayList al =3D (ArrayList)hm.get( methods[i].getName() ); - if (al =3D=3D null) - { - al =3D new ArrayList( methods.length ); - al.add( methods[i] ); - hm.put( methods[i].getName(), al ); - } - else - { - al.add( methods[i] ); - } - } - - Set keySet =3D hm.keySet(); - ArrayList overloadList =3D new ArrayList( methods.length ); - for (Iterator keyIt =3D keySet.iterator(); keyIt !=3D null && keyI= t=2EhasNext(); ) - { - ArrayList al =3D (ArrayList)hm.get( keyIt.next() ); - if (al.size() =3D=3D 1) - { - Method m =3D (Method)al.remove(0); - overloadList.add( new MethodOverload( m.getName(), m ) ); - } - else - { - for( int i=3D0; i<=3Dal.size(); i++ ) - { - Method m =3D (Method)al.remove(0); - overloadList.add( new MethodOverload( overloadMethodNa= me(m), m ) ); - } - } - } - - Object obj[] =3D overloadList.toArray(); - MethodOverload m[] =3D new MethodOverload[ obj.length ]; - System.arraycopy( obj, 0, m, 0, obj.length ); - - return m; - } - - protected String overloadMethodName( Method m ) - { - Class parms[] =3D m.getParameterTypes(); - String name =3D m.getName() + "_"; - for( int i=3D0; i 0) - { - JTryCatchFinallyStatement tcfs =3D new JTryCatchFinallyStateme= nt(); - JTryStatement ts =3D tcfs.getTryStatement(); - - if (declareStatementList.size() > 0) - { - for( int i=3D0; i 0) - { - for( int i=3D0; i 0) { + int i; + for (i =3D 0; i < m.length; i++) { // Enter a new method id in the _methods hashtable. - jcCon.addStatement(new JCodeStatement("registerMethod( \""= + mo[i].iiop_name + "\", " + i + ");")); + jcCon.addStatement(new JCodeStatement("registerMethod( \""= + m[i].getName() + "\", " + i + ");")); =20 // Add a new case statement to the invoke swtich - caseStmt =3D switchStmt.newCase(new JExpression(new JCodeS= tatement("" + i))); - caseStmt.addStatement(new JCodeStatement(mo[i].iiop_name += "(input,output);")); + cs =3D ss.newCase(new JExpression(new JCodeStatement("" + = i))); + cs.addStatement(new JCodeStatement(m[i].getName() + "(inpu= t,output);")); =20 // Generate the method wrapper - addMethod(mo[i], jc, go); + addMethod(m[i], jc); } - - JCatchStatement catchStmt =3D null; - JVariable jvExcept =3D null; - - jvExcept =3D new JVariable(java.lang.Error.class, "erEx"); - catchStmt =3D tcfs.newCatch(jvExcept); - catchStmt.addStatement(new JCodeStatement( "throw new org.apac= he.geronimo.interop.SystemException( " + jvExcept.getName() + " );" ) ); - - jvExcept =3D new JVariable(java.lang.RuntimeException.class, "= rtEx"); - catchStmt =3D tcfs.newCatch(jvExcept); - catchStmt.addStatement(new JCodeStatement( "throw " + jvExcept= .getName() + ";" ) ); - - jvExcept =3D new JVariable(java.lang.Exception.class, "exEx"); - catchStmt =3D tcfs.newCatch(jvExcept); - catchStmt.addStatement(new JCodeStatement( "throw new org.apac= he.geronimo.interop.SystemException( " + jvExcept.getName() + " );" ) ); - - jmInvoke.addStatement( tcfs ); } =20 - Set pkgSet =3D packages.keySet(); - Iterator pkgIt =3D pkgSet.iterator(); - String skelPkg =3D ""; - - while (pkgIt.hasNext()) - { - skelPkg =3D (String) pkgIt.next(); - pkg =3D (JPackage)packages.get(skelPkg); - System.out.println("Generating Package: " + skelPkg); - jg.generate(pkg); - } + jg.generate(p); } =20 public void compile() throws Exception { - - Set pkg =3D packages.keySet(); - Iterator pkgIt =3D pkg.iterator(); - String skelPkg =3D ""; - - /* - * Each of the packages were generated under go.getGenSrcDir(). - * - * Go through all the packages and run the compiler on *.java - */ - - GenOptions go =3D getGenOptions(); - String classpath =3D adjustPath(go.getClasspath()); - String srcpath =3D adjustPath(go.getGenSrcDir()); - - String filesToCompile =3D ""; - String javacCmd =3D ""; - - while (pkgIt.hasNext()) - { - skelPkg =3D (String) pkgIt.next(); - skelPkg =3D skelPkg.replace( '.', File.separatorChar ); - filesToCompile =3D adjustPath(go.getGenSrcDir() + File.separat= or + skelPkg + File.separator + "*.java"); - - System.out.println("Compiling Package: " + filesToCompile); - - javacCmd =3D "javac -d " + go.getGenClassDir() + - ( go.isCompileDebug() ? " -g" : "" ) + - " -classpath " + classpath + " " + - " -sourcepath " + srcpath + " " + filesToCompi= le; - - System.out.println( "Lauching: " + javacCmd ); - - ProcessUtil pu =3D ProcessUtil.getInstance(); - pu.setEcho(System.out); - pu.run(javacCmd, (String[]) null, "./" ); - } } =20 public Class getSkelClass() { @@ -580,27 +429,62 @@ return c; } =20 - public static void main(String args[]) throws Exception { - GenOptions go =3D null; - - try - { - go =3D new GenOptions( "./skels", args ); - } - catch( GenWarning gw ) - { - gw.printStackTrace(); + public static void main(String args[]) + throws Exception { + boolean generate =3D false; + boolean compile =3D false; + boolean simpleIDL =3D false; + String ri =3D ""; + GenOptions go =3D new GenOptions(); + + go.setGenDir("./src"); + go.setOverwrite(false); + go.setVerbose(false); + + for (int i =3D 0; i < args.length; i++) { + if (args[i].equals("-g")) { + generate =3D true; + } else if (args[i].equals("-c")) { + compile =3D 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].equals("-s")) { + simpleIDL =3D true; + } else if (args[i].startsWith("-")) { + System.out.println("Warning: Ignoring unrecognized options= : '" + args[i] + "'"); + } else { + ri =3D args[i]; + } } =20 - ClassLoader cl =3D ClassLoader.getSystemClassLoader(); - SkelCompiler sg =3D new SkelCompiler( go, cl ); + Class riClass =3D Class.forName(ri); + + SkelCompiler sg =3D new SkelCompiler(riClass, go); + + sg.setSimpleIDL(simpleIDL); + + if (generate) { + if (go.isVerbose()) { + System.out.println("Generating: " + ri); + } =20 - if (go.isGenerate()) { sg.generate(); } =20 - if (go.isCompile()) { + if (compile) { + if (go.isVerbose()) { + System.out.println("Compiling: " + ri); + } + sg.compile(); } + + // sg.setSimpleIDL( true ); + // sg.generate( "org.apache.geronimo.interop.rmi.iiop.NameServiceO= perations"); } } + Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/inter= op/rmi/iiop/compiler/SkelFactory.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/= org/apache/geronimo/interop/rmi/iiop/compiler/SkelFactory.java?view=3Ddiff&= r1=3D158861&r2=3D158862 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi= /iiop/compiler/SkelFactory.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi= /iiop/compiler/SkelFactory.java Wed Mar 23 18:30:30 2005 @@ -23,27 +23,56 @@ import org.apache.geronimo.interop.rmi.iiop.RemoteObject; import org.apache.geronimo.interop.util.ThreadContext; =20 + public class SkelFactory { - private static SkelFactory sf =3D new SkelFactory(); + protected static SkelFactory _sf =3D new SkelFactory(); =20 protected SkelFactory() { } =20 public static SkelFactory getInstance() { - return sf; + return _sf; } =20 - private static HashMap skelClassMap; + // private data + + private static HashMap _skelClassMap; + + // internal methods =20 protected void init() { - skelClassMap =3D new HashMap(); + _skelClassMap =3D new HashMap(); } =20 - /* protected Class loadStub(Class remoteInterface) { String className =3D remoteInterface.getName(); String skelClassName =3D className + "_Skeleton"; =20 + /* + StubClass sc =3D new StubClass(); + if (sc.skelClass =3D=3D null) + { + // Try generating skel class now. + System.out.println( "TODO: StubFactory.loadStub(): className = =3D " + className ); + StubCompiler skelCompiler =3D StubCompiler.getInstance(remoteI= nterface); + sc.skelClass =3D skelCompiler.getStubClass(); + } + + if (sc.skelClass !=3D null) + { + try + { + sc.getInstance =3D sc.skelClass.getMethod("$getInstance", = ArrayUtil.EMPTY_CLASS_ARRAY); + } + catch (Exception ex) + { + throw new SystemException(ex); + } + } + + return sc; + */ + Class sc =3D null; try { sc =3D Class.forName(skelClassName); @@ -55,19 +84,19 @@ =20 return sc; } - */ =20 - /* + // public methods + public RemoteObject getSkel(Class remoteInterface) { System.out.println("SkelFactory.getSkel(): remoteInterface: " + re= moteInterface); try { - Class sc =3D (Class) skelClassMap.get(remoteInterface); + Class sc =3D (Class) _skelClassMap.get(remoteInterface); if (sc =3D=3D null) { - synchronized (skelClassMap) { - sc =3D (Class) skelClassMap.get(remoteInterface); + synchronized (_skelClassMap) { + sc =3D (Class) _skelClassMap.get(remoteInterface); if (sc =3D=3D null) { sc =3D loadStub(remoteInterface); - skelClassMap.put(remoteInterface, sc); + _skelClassMap.put(remoteInterface, sc); } } } @@ -77,11 +106,8 @@ throw new SystemException(ex); } } - */ =20 - /* public Object getSkel(String remoteInterface) { return getSkel(ThreadContext.loadClass(remoteInterface)); } - */ } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/inter= op/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=3Ddiff&r1= =3D158861&r2=3D158862 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 18:30:30 2005 @@ -21,22 +21,7 @@ =20 =20 public class StubClass { - private Class stubClass; - private Method getInstanceMethod; + public Class stubClass; =20 - public StubClass( Class stubClass, Method getInstanceMethod ) - { - this.stubClass =3D stubClass; - this.getInstanceMethod =3D getInstanceMethod; - } - - public Class getStubClass() - { - return stubClass; - } - - public Method getGetInstanceMethod() - { - return getInstanceMethod; - } + public Method getInstance; } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/inter= op/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=3Ddiff= &r1=3D158861&r2=3D158862 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 18:30:30 2005 @@ -18,65 +18,93 @@ package org.apache.geronimo.interop.rmi.iiop.compiler; =20 import java.lang.reflect.Method; -import java.io.File; -import java.util.*; - -import org.apache.geronimo.interop.generator.*; +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 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; =20 -public class StubCompiler extends Compiler { - private final Log log =3D LogFactory.getLog(StubCompiler.class); =20 - private ValueTypeContext vtc =3D new ValueTypeContext(); +public class StubCompiler + extends Compiler { + protected ValueTypeContext _vtc =3D new ValueTypeContext(); + protected static JParameter _objInputVar =3D new JParameter(org.apache= .geronimo.interop.rmi.iiop.ObjectInputStream.class, "input"); + protected static JParameter _objOutputVar =3D new JParameter(org.apach= e=2Egeronimo.interop.rmi.iiop.ObjectOutputStream.class, "output"); + + protected String _stubClassName =3D ""; + protected Class _stubClass =3D null; + + protected String _inStreamName =3D "getInputStream"; + protected String _outStreamName =3D "getOutputStream"; + + public StubCompiler(Class riClass) { + super(riClass); + init(); + } + + public StubCompiler(Class riClass, GenOptions go) { + super(riClass, go); + init(); + } + + protected void init() { + String className =3D _riClass.getName(); + _stubClassName =3D JavaClass.addPackageSuffix(className, "iiop_stu= bs") + "_Stub"; + } =20 - private String inStreamName =3D "getInputStream"; - private String outStreamName =3D "getOutputStream"; - - private HashMap packages =3D 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[] exc= epts) { - // - // Method Template: - // - // java.lang.Object $key_1 =3D $getRequestKey(); - // for (int $retry =3D 0; ; $retry++) - // { - // try - // { - // org.apache.geronimo.interop.rmi.iiop.client.Connection = $connection_2 =3D this.$connect(); - // org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream= $output_3 =3D $connection_2.getSimpleOutputStream(); // simple idl - // org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream= $output_3 =3D $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 =3D $connection_2.getSimpleInputStream(); // simple idl - // org.apache.geronimo.interop.rmi.iiop.ObjectInputStream = $input_4 =3D $connection_2.getInputStream(); // rmi-iiop - // $connection_2.forget($key_1); - // $connection_2.close(); - // java.lang.String $et_5 =3D $connection_2.getExceptionTy= pe(); - // if ($et_5 !=3D null) - // { - // throw org.apache.geronimo.interop.rmi.iiop.SystemEx= ceptionFactory.getException($connection_2.getException()); - // } - // boolean $djc_result; - // $djc_result =3D $input_4.readBoolean(); - // return $djc_result; - // } - // catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInv= okeException $ex_6) - // { - // if ($retry =3D=3D 3) - // { - // throw $ex_6.getRuntimeException(); - // } - // } - // } + protected void addMethod(JClass jc, JReturnType jrc, String name, JPar= ameter[] jparms, Class[] excepts) { +// java.lang.Object $key_1 =3D $getRequestKey(); +// for (int $retry =3D 0; ; $retry++) +// { +// try +// { +// org.apache.geronimo.interop.rmi.iiop.client.Connection $= connection_2 =3D this.$connect(); +// org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream = $output_3 =3D $connection_2.getSimpleOutputStream(); // simple idl +// org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream = $output_3 =3D $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 =3D $connection_2.getSimpleInputStream(); // simple idl +// org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $= input_4 =3D $connection_2.getInputStream(); // rmi-iiop +// $connection_2.forget($key_1); +// $connection_2.close(); +// java.lang.String $et_5 =3D $connection_2.getExceptionTyp= e(); +// if ($et_5 !=3D null) +// { +// throw org.apache.geronimo.interop.rmi.iiop.SystemExc= eptionFactory.getException($connection_2.getException()); +// } +// boolean $djc_result; +// $djc_result =3D $input_4.readBoolean(); +// return $djc_result; +// } +// catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvo= keException $ex_6) +// { +// if ($retry =3D=3D 3) +// { +// throw $ex_6.getRuntimeException(); +// } +// } +// } =20 //JParameter jpID =3D new JParameter( java.lang.String.class, "id"= ); JMethod jm =3D jc.newMethod(jrc, name, jparms, excepts); @@ -107,7 +135,7 @@ } =20 jbs.addStatement(new JCodeStatement(jlvConn.getName() + " =3D this= .$connect();")); - jbs.addStatement(new JCodeStatement(jlvOutput.getName() + " =3D " = + jlvConn.getName() + "." + outStreamName + "();")); + jbs.addStatement(new JCodeStatement(jlvOutput.getName() + " =3D " = + jlvConn.getName() + "." + _outStreamName + "();")); =20 String writeMethod =3D null; String writeCall =3D ""; @@ -117,15 +145,15 @@ if (writeMethod !=3D null) { writeCall =3D writeMethod + "( " + jparms[i].getName() + "= )"; } else { - writeCall =3D "writeObject( " + vtc.getValueTypeVarName(jc= , jparms[i]) + ", " + jparms[i].getName() + ")"; + writeCall =3D "writeObject( " + _vtc.getValueTypeVarName(j= c, jparms[i]) + ", " + jparms[i].getName() + ")"; } =20 jbs.addStatement(new JCodeStatement(jlvOutput.getName() + "." = + writeCall + ";")); } =20 - jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(t= his, \"" + iiopMethodName + "\", " + jlvKey.getName() + ", $retry);")); + jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(t= his, \"" + name + "\", " + jlvKey.getName() + ", $retry);")); if (jlvRc !=3D null) { - jbs.addStatement(new JCodeStatement(jlvInput.getName() + " =3D= " + jlvConn.getName() + "." + inStreamName + "();")); + jbs.addStatement(new JCodeStatement(jlvInput.getName() + " =3D= " + jlvConn.getName() + "." + _inStreamName + "();")); } jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".forget("= + jlvKey.getName() + ");")); jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".close();= ")); @@ -143,7 +171,7 @@ if (readMethod !=3D null) { readCall =3D jlvInput.getName() + "." + readMethod + "()"; } else { - readCall =3D "(" + jlvRc.getTypeDecl() + ")" + jlvInput.ge= tName() + "." + "readObject( " + vtc.getValueTypeVarName(jc, jlvRc) + ")"; + readCall =3D "(" + jlvRc.getTypeDecl() + ")" + jlvInput.ge= tName() + "." + "readObject( " + _vtc.getValueTypeVarName(jc, jlvRc) + ")"; } =20 jbs.addStatement(new JCodeStatement(jlvRc.getName() + " =3D " = + readCall + ";")); @@ -163,167 +191,200 @@ jfs.addStatement(tcfs); } =20 - protected void addMethod_is_a(JClass jc) { + // public methods + + public void addMethod_is_a(JClass jc) { JParameter jpID =3D new JParameter(java.lang.String.class, "id"); - addMethod(jc, "_is_a", new JReturnType(boolean.class), + addMethod(jc, new JReturnType(boolean.class), "_is_a", new JParameter[]{jpID}, (Class[]) null); =20 } =20 - protected void addMethod(MethodOverload mo, JClass jc) { - Method m =3D mo.method; - + public void addMethod(Method m, JClass jc) { String name =3D m.getName(); JParameter[] sparms =3D getMethodParms(m); =20 - addMethod(jc, mo.iiop_name, new JReturnType(m.getReturnType()), + addMethod(jc, new JReturnType(m.getReturnType()), name, sparms, m.getExceptionTypes()); =20 } =20 - public void generate() throws GenException { - GenOptions go =3D getGenOptions(); - List interfaces =3D go.getInterfaces(); - Iterator intf =3D null; - - if (interfaces !=3D null) { - intf =3D interfaces.iterator(); + protected Method[] getMethods() { + Method myMethods[] =3D _riClass.getDeclaredMethods(); + Method myOpsMethods[] =3D null; + Class myInterfaces[] =3D _riClass.getInterfaces(); + + if (myInterfaces !=3D null && myInterfaces.length > 0) { + String opsName =3D _riClass.getName() + "Operations"; + + for (int i =3D 0; i < myInterfaces.length; i++) { + if (myInterfaces[i].getName().equals(opsName)) { + myOpsMethods =3D myInterfaces[i].getDeclaredMethods(); + break; + } + } } =20 - JavaGenerator jg =3D new JavaGenerator(genOptions); + Method m[] =3D null; =20 - if (go.isSimpleIdl()) { - inStreamName =3D "getSimpleInputStream"; - outStreamName =3D "getSimpleOutputStream"; + if (myOpsMethods =3D=3D null) { + m =3D myMethods; } else { - inStreamName =3D "getInputStream"; - outStreamName =3D "getOutputStream"; + m =3D new Method[myMethods.length + myOpsMethods.length]; + System.arraycopy(myMethods, 0, m, 0, myMethods.length); + System.arraycopy(myOpsMethods, 0, m, myMethods.length, myOpsMe= thods.length); } =20 - String riClassName =3D ""; - Class riClass =3D null; - String stubClassName =3D ""; - JPackage pkg =3D null; + return m; + } =20 - while (intf !=3D null && intf.hasNext() ) { - // Clear the value type cache. - vtc.clear(); + public void generate() + throws Exception { + _vtc.clear(); =20 - riClassName =3D (String)intf.next(); - stubClassName =3D JavaClass.addPackageSuffix(riClassName, "iio= p_stubs") + "_Stub"; + if (_simpleIDL) { + _inStreamName =3D "getSimpleInputStream"; + _outStreamName =3D "getSimpleOutputStream"; + } =20 - try { - riClass =3D getClassLoader().loadClass( riClassName ); - } catch (Exception ex) { - throw new GenException( "Generate Stubs Failed:", ex ); - } + JavaGenerator jg =3D new JavaGenerator(_genOptions); =20 - String pkgName =3D JavaClass.getNamePrefix(stubClassName); - pkg =3D (JPackage) packages.get( pkgName ); - if (pkg =3D=3D null) - { - pkg =3D new JPackage( pkgName ); - packages.put( pkgName, pkg ); - } + String className; + JPackage p =3D new JPackage(JavaClass.getNamePrefix(_stubClassName= )); + className =3D JavaClass.getNameSuffix(_stubClassName); =20 - String className =3D JavaClass.getNameSuffix(stubClassName); - JClass jc =3D pkg.newClass(className); - jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRe= f"); - jc.setExtends("ObjectRef"); - jc.addImplements(riClass.getName()); - - JConstructor jcCon =3D jc.newConstructor((JParameter[]) null, = (Class[]) null); - jcCon.addStatement(new JCodeStatement("super();")); - - addMethod_is_a(jc); - - Method m[] =3D getMethods( riClass, go ); - MethodOverload mo[] =3D null; - mo =3D getMethodOverloads( m ); - for (int i =3D 0; mo !=3D null && i < mo.length; i++) { - addMethod( mo[i], jc ); - } - } + JClass jc =3D p.newClass(className); + jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRef"); + jc.setExtends("ObjectRef"); + jc.addImplements(_riClass.getName()); =20 - Set pkgSet =3D packages.keySet(); - Iterator pkgIt =3D pkgSet.iterator(); - String stubPkg =3D ""; - - while (pkgIt.hasNext()) - { - stubPkg =3D (String) pkgIt.next(); - pkg =3D (JPackage)packages.get(stubPkg); - System.out.println("Generating Package: " + stubPkg); - jg.generate(pkg); - } - } + JField idsField =3D jc.newField(String[].class, "_ids", new JExpre= ssion(new JCodeStatement("{ \"" + _riClass.getName() + "\", \"RMI:" + _riCl= ass.getName() + ":0000000000000000\"}")), true); =20 - public void compile() - throws Exception { + JConstructor jcCon =3D jc.newConstructor((JParameter[]) null, (Cla= ss[]) null); + jcCon.addStatement(new JCodeStatement("super();")); =20 - Set pkg =3D packages.keySet(); - Iterator pkgIt =3D pkg.iterator(); - String stubPkg =3D ""; + addMethod_is_a(jc); =20 - /* - * Each of the packages were generated under go.getGenSrcDir(). - * - * Go through all the packages and run the compiler on *.java - */ + Method m[] =3D null; + m =3D getMethods(); + for (int i =3D 0; m !=3D null && i < m.length; i++) { + addMethod(m[i], jc); + } =20 - GenOptions go =3D getGenOptions(); - String classpath =3D adjustPath(go.getClasspath()); - String srcpath =3D adjustPath(go.getGenSrcDir()); + jg.generate(p); + } =20 - String filesToCompile =3D ""; - String javacCmd =3D ""; + public void compile() + throws Exception { + String className =3D _riClass.getName(); + String stubClassName =3D JavaClass.addPackageSuffix(className, "ii= op_stubs"); + String stubPackage =3D JavaClass.getNamePrefix(stubClassName); + + System.out.println("Compiling Package: " + stubPackage); + System.out.println("Compiling Stub: " + stubClassName); + + String javac =3D "javac -d ../classes -classpath ../classes;D:/Dev= /3rdparty.jag/ejb21/ejb-2_1-api.jar " + stubPackage.replace('.', '/') + "/*= .java"; + + ProcessUtil pu =3D ProcessUtil.getInstance(); + pu.setEcho(System.out); + pu.run(javac, (String[]) null, "./src"); + } =20 - while (pkgIt.hasNext()) - { - stubPkg =3D (String) pkgIt.next(); - stubPkg =3D stubPkg.replace( '.', File.separatorChar ); - filesToCompile =3D adjustPath(go.getGenSrcDir() + File.separat= or + stubPkg + File.separator + "*.java"); + public Class getStubClass() { + System.out.println("StubCompiler.getStubClass(): riClass: " + _riC= lass); =20 - System.out.println("Compiling Package: " + filesToCompile); + if (_stubClass =3D=3D null) { + try { + _stubClass =3D Class.forName(_stubClassName); + } catch (Exception e) { + e.printStackTrace(); + } =20 - javacCmd =3D "javac -d " + go.getGenClassDir() + - ( go.isCompileDebug() ? " -g" : "" ) + - " -classpath " + classpath + " " + - " -sourcepath " + srcpath + " " + filesToCompi= le; + try { + if (_stubClass =3D=3D null) { + generate(); + compile(); + _stubClass =3D Class.forName(_stubClassName); + } + } catch (Exception e) { + e.printStackTrace(); + } + } =20 - System.out.println( "Lauching: " + javacCmd ); + return _stubClass; + } =20 - ProcessUtil pu =3D ProcessUtil.getInstance(); - pu.setEcho(System.out); - pu.run(javacCmd, (String[]) null, "./" ); + public static void main(String args[]) + throws Exception { + boolean generate =3D false; + boolean compile =3D false; + boolean loadclass =3D false; + boolean simpleidl =3D false; + List interfaces =3D new LinkedList(); + GenOptions go =3D new GenOptions(); + + go.setGenDir("./"); + go.setOverwrite(false); + go.setVerbose(false); + + for (int i =3D 0; i < args.length; i++) { + if (args[i].equals("-g")) { + generate =3D true; + } else if (args[i].equals("-c")) { + compile =3D true; + } else if (args[i].equals("-l")) { + loadclass =3D true; + } else if (args[i].equals("-s")) { + simpleidl =3D 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]); + } } - } =20 - public static void main(String args[]) throws Exception { - GenOptions go =3D null; + Iterator i =3D interfaces.iterator(); + while (i !=3D null && i.hasNext()) { + String intfName =3D (String) i.next(); + + if (intfName.startsWith("RMI:")) { + simpleidl =3D false; + intfName =3D intfName.substring(4); + } else if (intfName.startsWith("IDL:")) { + simpleidl =3D true; + intfName =3D intfName.substring(4); + } =20 - try - { - go =3D new GenOptions( "./stubs", args ); - } - catch( GenWarning gw ) - { - gw.printStackTrace(); - } + Class riClass =3D Class.forName(intfName); + StubCompiler sg =3D new StubCompiler(riClass, go); + sg.setSimpleIDL(simpleidl); =20 - ClassLoader cl =3D ClassLoader.getSystemClassLoader(); - StubCompiler sg =3D new StubCompiler( go, cl ); + if (generate) { + sg.generate(); + } =20 - if (go.isGenerate()) { - sg.generate(); - } + if (compile) { + sg.compile(); + } =20 - if (go.isCompile()) { - sg.compile(); + if (loadclass) { + Class c =3D sg.getStubClass(); + System.out.println("StubClass: " + c); + } } + + // sg.setSimpleIDL( true ); + // sg.generate( "org.apache.geronimo.interop.rmi.iiop.NameServiceO= perations"); } + } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/inter= op/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=3Ddiff&= r1=3D158861&r2=3D158862 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 18:30:30 2005 @@ -24,29 +24,34 @@ import org.apache.geronimo.interop.util.JavaClass; import org.apache.geronimo.interop.util.ThreadContext; =20 + public class StubFactory { - protected static StubFactory sf; + protected static StubFactory _sf; =20 protected StubFactory() { } =20 public static StubFactory getInstance() { - if (sf =3D=3D null) { + if (_sf =3D=3D null) { synchronized (StubFactory.class) { - if (sf =3D=3D null) { - sf =3D new StubFactory(); - sf.init(); + if (_sf =3D=3D null) { + _sf =3D new StubFactory(); + _sf.init(); } } } =20 - return sf; + return _sf; } =20 - private static HashMap stubClassMap; + // private data + + private static HashMap _stubClassMap; + + // internal methods =20 protected void init() { - stubClassMap =3D new HashMap(); + _stubClassMap =3D new HashMap(); } =20 protected Class loadStub(Class remoteInterface) { @@ -71,9 +76,9 @@ // Try generating stub class now. // =20 - //StubCompiler stubCompiler =3D new StubCompiler(remoteInterfa= ce); - //System.out.println("StubFactory.loadStub(): stubCompiler: " = + stubCompiler); - //sc =3D stubCompiler.getStubClass(); + StubCompiler stubCompiler =3D new StubCompiler(remoteInterface= ); + System.out.println("StubFactory.loadStub(): stubCompiler: " + = stubCompiler); + sc =3D stubCompiler.getStubClass(); System.out.println("StubFactory.loadStub(): sc: " + sc); } =20 @@ -94,18 +99,20 @@ return sc; } =20 + // public methods + public ObjectRef getStub(Class remoteInterface) { System.out.println("StubFactory.getStub(): remoteInterface: " + re= moteInterface); try { - Class sc =3D (Class) stubClassMap.get(remoteInterface); + Class sc =3D (Class) _stubClassMap.get(remoteInterface); System.out.println("StubFactory.getStub(): sc: " + sc); if (sc =3D=3D null) { - synchronized (stubClassMap) { - sc =3D (Class) stubClassMap.get(remoteInterface); + synchronized (_stubClassMap) { + sc =3D (Class) _stubClassMap.get(remoteInterface); if (sc =3D=3D null) { sc =3D loadStub(remoteInterface); System.out.println("StubFactory.getStub(): sc: " += sc); - stubClassMap.put(remoteInterface, sc); + _stubClassMap.put(remoteInterface, sc); } } }