Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 12685 invoked from network); 25 Mar 2005 12:21:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Mar 2005 12:21:39 -0000 Received: (qmail 62750 invoked by uid 500); 25 Mar 2005 12:21:38 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 62610 invoked by uid 500); 25 Mar 2005 12:21:38 -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 62596 invoked by uid 99); 25 Mar 2005 12:21:37 -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; Fri, 25 Mar 2005 04:21:35 -0800 Received: (qmail 1087 invoked by uid 65534); 25 Mar 2005 11:54:53 -0000 Message-ID: <20050325115453.1085.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: Fri, 25 Mar 2005 11:54:53 -0000 Subject: svn commit: r159005 [8/9] - in geronimo/trunk/modules: 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/ 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= =3D159004&r2=3D159005 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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 Fri Mar 25 03:54:30 2005 @@ -18,97 +18,74 @@ package org.apache.geronimo.interop.rmi.iiop.compiler; =20 import java.lang.reflect.Method; -import java.util.HashMap; +import java.util.*; +import java.io.File; =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 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; + protected GenOptions genOptions; =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.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 - // + private ClassLoader classLoader; + + private static HashMap readMethods; + private static HashMap writeMethods; + private static HashMap overloadTypes; =20 - public boolean isSimpleIDL() { - return _simpleIDL; + 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"); } =20 - public void setSimpleIDL(boolean simpleIDL) { - _simpleIDL =3D simpleIDL; + public Compiler(GenOptions go, ClassLoader cl) { + classLoader =3D cl; + if (classLoader =3D=3D null) { + classLoader =3D ClassLoader.getSystemClassLoader(); + } + + genOptions =3D go; } =20 public GenOptions getGenOptions() { - return _genOptions; + return genOptions; } =20 - public void setGenOptions(GenOptions genOptions) { - _genOptions =3D genOptions; + public ClassLoader getClassLoader() { + return classLoader; } =20 public JParameter[] getMethodParms(Method m) { @@ -131,7 +108,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; @@ -141,11 +118,191 @@ 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++) { + jc.addImport("org.apache.geronimo.interop.rmi.iiop", "RemoteIn= terface"); + jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRe= f"); + jc.addImport("org.apache.geronimo.interop.rmi.iiop", "RemoteOb= ject"); =20 + + jc.setExtends("RemoteObject"); + jc.addImplements("RemoteInterface"); + + JField idsField =3D jc.newField(String[].class, "_ids", new JE= xpression(new JCodeStatement("{ \"" + riClass.getName() + "\", \"RMI:" + ri= Class.getName() + ":0000000000000000\"}")), true); + idsField.setModifiers(Modifier.PRIVATE | Modifier.STATIC | Mod= ifier.FINAL); + + JField servantField =3D jc.newField(riClass, "_servant", new J= Expression(new JCodeStatement("null"))); + servantField.setModifiers(Modifier.PRIVATE); + + JConstructor jcCon =3D jc.newConstructor((JParameter[]) null, = (Class[]) null); + jcCon.addStatement(new JCodeStatement("super();")); + + // Replaced with the method in the RemoteObject parent class + //addMethodRegisterMethod(jc); + + addMethodGetIds(jc); + + // Not used anymore + //addMethodGetSkeleton(jc); + + addMethodGetObjectRef(jc, riClass); + + JMethod jmInvoke =3D jc.newMethod(new JReturnType(void.class), + "invoke", + new JParameter[]{new JParamete= r(String.class, "methodName"), + new JParamete= r(byte[].class, "objectKey"), + new JParamete= r(Adapter.class, "adapter"), + objInputVar, + objOutputVar}= , + (Class[]) null); + + jmInvoke.setModifier(Modifier.PUBLIC); + + JLocalVariable jvM =3D jmInvoke.newLocalVariable(Integer.class= , "m", new JExpression(new JCodeStatement("getMethodId(methodName); // (Int= eger)_methods.get(methodName)"))); + + JIfStatement jis =3D new JIfStatement(new JExpression(new JCod= eStatement(jvM.getName() + " =3D=3D null"))); + jis.addStatement(new JCodeStatement("throw new org.omg.CORBA.B= AD_OPERATION(methodName);")); + jmInvoke.addStatement(jis); + + jmInvoke.addStatement(new JCodeStatement("_servant =3D (" + ri= Class.getName() + ")adapter.getServant(); //instance;")); + + JIfStatement jis2 =3D new JIfStatement(new JExpression(new JCo= deStatement(jvM.getName() + ".intValue() < 0"))); + jis2.addStatement(new JCodeStatement("super.invoke( " + jvM.ge= tName() + ".intValue(), objectKey, adapter, input, output );")); + jmInvoke.addStatement(jis2); + + JTryCatchFinallyStatement tcfs =3D new JTryCatchFinallyStateme= nt(); + JTryStatement ts =3D tcfs.getTryStatement(); + + JSwitchStatement switchStmt =3D new JSwitchStatement(new JExpr= ession(new JCodeStatement("m.intValue()"))); + JCaseStatement caseStmt =3D null; + ts.addStatement(switchStmt); + + 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++) + { // Enter a new method id in the _methods hashtable. - jcCon.addStatement(new JCodeStatement("registerMethod( \""= + m[i].getName() + "\", " + i + ");")); + jcCon.addStatement(new JCodeStatement("registerMethod( \""= + mo[i].iiop_name + "\", " + i + ");")); =20 // Add a new case statement to the invoke swtich - cs =3D ss.newCase(new JExpression(new JCodeStatement("" + = i))); - cs.addStatement(new JCodeStatement(m[i].getName() + "(inpu= t,output);")); + caseStmt =3D switchStmt.newCase(new JExpression(new JCodeS= tatement("" + i))); + caseStmt.addStatement(new JCodeStatement(mo[i].iiop_name += "(input,output);")); =20 // Generate the method wrapper - addMethod(m[i], jc); + addMethod(mo[i], jc, go); } + + 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 - jg.generate(p); + 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); + } } =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() { @@ -429,62 +580,27 @@ return c; } =20 - 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]; - } - } - - Class riClass =3D Class.forName(ri); - - SkelCompiler sg =3D new SkelCompiler(riClass, go); + public static void main(String args[]) throws Exception { + GenOptions go =3D null; =20 - sg.setSimpleIDL(simpleIDL); + try + { + go =3D new GenOptions( "./skels", args ); + } + catch( GenWarning gw ) + { + gw.printStackTrace(); + } =20 - if (generate) { - if (go.isVerbose()) { - System.out.println("Generating: " + ri); - } + ClassLoader cl =3D ClassLoader.getSystemClassLoader(); + SkelCompiler sg =3D new SkelCompiler( go, cl ); =20 + if (go.isGenerate()) { sg.generate(); } =20 - if (compile) { - if (go.isVerbose()) { - System.out.println("Compiling: " + ri); - } - + if (go.isCompile()) { 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=3D159004&r2=3D159005 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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 Fri Mar 25 03:54:30 2005 @@ -23,56 +23,27 @@ import org.apache.geronimo.interop.rmi.iiop.RemoteObject; import org.apache.geronimo.interop.util.ThreadContext; =20 - public class SkelFactory { - protected static SkelFactory _sf =3D new SkelFactory(); + private static SkelFactory sf =3D new SkelFactory(); =20 protected SkelFactory() { } =20 public static SkelFactory getInstance() { - return _sf; + return sf; } =20 - // private data - - private static HashMap _skelClassMap; - - // internal methods + private static HashMap skelClassMap; =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); @@ -84,19 +55,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); } } } @@ -106,8 +77,11 @@ 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= =3D159004&r2=3D159005 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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 Fri Mar 25 03:54:30 2005 @@ -21,7 +21,22 @@ =20 =20 public class StubClass { - public Class stubClass; + private Class stubClass; + private Method getInstanceMethod; =20 - public Method getInstance; + public StubClass( Class stubClass, Method getInstanceMethod ) + { + this.stubClass =3D stubClass; + this.getInstanceMethod =3D getInstanceMethod; + } + + public Class getStubClass() + { + return stubClass; + } + + public Method getGetInstanceMethod() + { + return getInstanceMethod; + } } 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=3D159004&r2=3D159005 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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 Fri Mar 25 03:54:30 2005 @@ -18,93 +18,65 @@ package org.apache.geronimo.interop.rmi.iiop.compiler; =20 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; =20 +public class StubCompiler extends Compiler { + private final Log log =3D LogFactory.getLog(StubCompiler.class); =20 -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"; - } + private ValueTypeContext vtc =3D new ValueTypeContext(); =20 - 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(); -// } -// } -// } + 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(); + // } + // } + // } =20 //JParameter jpID =3D new JParameter( java.lang.String.class, "id"= ); JMethod jm =3D jc.newMethod(jrc, name, jparms, excepts); @@ -135,7 +107,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 ""; @@ -145,15 +117,15 @@ if (writeMethod !=3D null) { writeCall =3D writeMethod + "( " + jparms[i].getName() + "= )"; } else { - writeCall =3D "writeObject( " + _vtc.getValueTypeVarName(j= c, jparms[i]) + ", " + jparms[i].getName() + ")"; + writeCall =3D "writeObject( " + vtc.getValueTypeVarName(jc= , jparms[i]) + ", " + jparms[i].getName() + ")"; } =20 jbs.addStatement(new JCodeStatement(jlvOutput.getName() + "." = + writeCall + ";")); } =20 - jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(t= his, \"" + name + "\", " + jlvKey.getName() + ", $retry);")); + jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(t= his, \"" + iiopMethodName + "\", " + 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();= ")); @@ -171,7 +143,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 + ";")); @@ -191,200 +163,167 @@ jfs.addStatement(tcfs); } =20 - // public methods - - public void addMethod_is_a(JClass jc) { + protected void addMethod_is_a(JClass jc) { JParameter jpID =3D 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); =20 } =20 - public void addMethod(Method m, JClass jc) { + protected void addMethod(MethodOverload mo, JClass jc) { + Method m =3D mo.method; + String name =3D m.getName(); JParameter[] sparms =3D getMethodParms(m); =20 - addMethod(jc, new JReturnType(m.getReturnType()), + addMethod(jc, mo.iiop_name, new JReturnType(m.getReturnType()), name, sparms, m.getExceptionTypes()); =20 } =20 - 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; - } - } - } - - Method m[] =3D null; + public void generate() throws GenException { + GenOptions go =3D getGenOptions(); + List interfaces =3D go.getInterfaces(); + Iterator intf =3D null; =20 - if (myOpsMethods =3D=3D null) { - m =3D myMethods; - } else { - 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); + if (interfaces !=3D null) { + intf =3D interfaces.iterator(); } =20 - return m; - } - - public void generate() - throws Exception { - _vtc.clear(); + JavaGenerator jg =3D new JavaGenerator(genOptions); =20 - if (_simpleIDL) { - _inStreamName =3D "getSimpleInputStream"; - _outStreamName =3D "getSimpleOutputStream"; + if (go.isSimpleIdl()) { + inStreamName =3D "getSimpleInputStream"; + outStreamName =3D "getSimpleOutputStream"; + } else { + inStreamName =3D "getInputStream"; + outStreamName =3D "getOutputStream"; } =20 - JavaGenerator jg =3D new JavaGenerator(_genOptions); - - String className; - JPackage p =3D new JPackage(JavaClass.getNamePrefix(_stubClassName= )); - className =3D JavaClass.getNameSuffix(_stubClassName); + String riClassName =3D ""; + Class riClass =3D null; + String stubClassName =3D ""; + JPackage pkg =3D null; =20 - JClass jc =3D p.newClass(className); - jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRef"); - jc.setExtends("ObjectRef"); - jc.addImplements(_riClass.getName()); + while (intf !=3D null && intf.hasNext() ) { + // Clear the value type cache. + vtc.clear(); =20 - JField idsField =3D jc.newField(String[].class, "_ids", new JExpre= ssion(new JCodeStatement("{ \"" + _riClass.getName() + "\", \"RMI:" + _riCl= ass.getName() + ":0000000000000000\"}")), true); + riClassName =3D (String)intf.next(); + stubClassName =3D JavaClass.addPackageSuffix(riClassName, "iio= p_stubs") + "_Stub"; =20 - JConstructor jcCon =3D jc.newConstructor((JParameter[]) null, (Cla= ss[]) null); - jcCon.addStatement(new JCodeStatement("super();")); + try { + riClass =3D getClassLoader().loadClass( riClassName ); + } catch (Exception ex) { + throw new GenException( "Generate Stubs Failed:", ex ); + } =20 - addMethod_is_a(jc); + 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 ); + } =20 - Method m[] =3D null; - m =3D getMethods(); - for (int i =3D 0; m !=3D null && i < m.length; i++) { - addMethod(m[i], jc); + 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 ); + } } =20 - jg.generate(p); + 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); + } } =20 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 - public Class getStubClass() { - System.out.println("StubCompiler.getStubClass(): riClass: " + _riC= lass); + Set pkg =3D packages.keySet(); + Iterator pkgIt =3D pkg.iterator(); + String stubPkg =3D ""; =20 - if (_stubClass =3D=3D null) { - try { - _stubClass =3D 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 + */ =20 - try { - if (_stubClass =3D=3D null) { - generate(); - compile(); - _stubClass =3D Class.forName(_stubClassName); - } - } catch (Exception e) { - e.printStackTrace(); - } - } + GenOptions go =3D getGenOptions(); + String classpath =3D adjustPath(go.getClasspath()); + String srcpath =3D adjustPath(go.getGenSrcDir()); =20 - return _stubClass; - } + String filesToCompile =3D ""; + String javacCmd =3D ""; =20 - 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]); - } - } + 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"); =20 - 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); - } + System.out.println("Compiling Package: " + filesToCompile); =20 - Class riClass =3D Class.forName(intfName); - StubCompiler sg =3D new StubCompiler(riClass, go); - sg.setSimpleIDL(simpleidl); + javacCmd =3D "javac -d " + go.getGenClassDir() + + ( go.isCompileDebug() ? " -g" : "" ) + + " -classpath " + classpath + " " + + " -sourcepath " + srcpath + " " + filesToCompi= le; =20 - if (generate) { - sg.generate(); - } + System.out.println( "Lauching: " + javacCmd ); =20 - if (compile) { - sg.compile(); - } + ProcessUtil pu =3D ProcessUtil.getInstance(); + pu.setEcho(System.out); + pu.run(javacCmd, (String[]) null, "./" ); + } + } =20 - if (loadclass) { - Class c =3D sg.getStubClass(); - System.out.println("StubClass: " + c); - } + public static void main(String args[]) throws Exception { + GenOptions go =3D null; + + try + { + go =3D new GenOptions( "./stubs", args ); + } + catch( GenWarning gw ) + { + gw.printStackTrace(); } =20 - // sg.setSimpleIDL( true ); - // sg.generate( "org.apache.geronimo.interop.rmi.iiop.NameServiceO= perations"); - } + ClassLoader cl =3D ClassLoader.getSystemClassLoader(); + StubCompiler sg =3D new StubCompiler( go, cl ); + + if (go.isGenerate()) { + sg.generate(); + } =20 + if (go.isCompile()) { + sg.compile(); + } + } } 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=3D159004&r2=3D159005 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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 Fri Mar 25 03:54:30 2005 @@ -24,34 +24,29 @@ 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 data - - private static HashMap _stubClassMap; - - // internal methods + private static HashMap stubClassMap; =20 protected void init() { - _stubClassMap =3D new HashMap(); + stubClassMap =3D new HashMap(); } =20 protected Class loadStub(Class remoteInterface) { @@ -76,9 +71,9 @@ // Try generating stub class now. // =20 - StubCompiler stubCompiler =3D new StubCompiler(remoteInterface= ); - System.out.println("StubFactory.loadStub(): stubCompiler: " + = stubCompiler); - sc =3D stubCompiler.getStubClass(); + //StubCompiler stubCompiler =3D new StubCompiler(remoteInterfa= ce); + //System.out.println("StubFactory.loadStub(): stubCompiler: " = + stubCompiler); + //sc =3D stubCompiler.getStubClass(); System.out.println("StubFactory.loadStub(): sc: " + sc); } =20 @@ -99,20 +94,18 @@ 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); } } }