commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test DirectTest.java PipeTest.java RmiServerTest.java SocketServerTest.java
Date Fri, 25 Jan 2002 16:40:14 GMT
hammant     02/01/25 08:40:14

  Modified:    altrmi   PROPOSAL build.xml tests.xml
               altrmi/src/java/org/apache/commons/altrmi/common
                        AbstractMethodHandler.java
               altrmi/src/java/org/apache/commons/altrmi/generator
                        PrimarySourceGenerator.java
               altrmi/src/java/org/apache/commons/altrmi/generator/ant
                        AltrmiInterfaceTask.java
               altrmi/src/java/org/apache/commons/altrmi/server
                        AltrmiPublisher.java AltrmiServer.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        AbstractServer.java
               altrmi/src/java/org/apache/commons/altrmi/test
                        DirectTest.java PipeTest.java RmiServerTest.java
                        SocketServerTest.java
  Added:       altrmi/src/java/org/apache/commons/altrmi/javacompiler
                        JavaCompiler.java SunJavaCompiler.java
               altrmi/src/java/org/apache/commons/altrmi/server
                        AltrmiProxyGenerator.java
  Removed:     altrmi/src/java/org/apache/commons/altrmi/generator
                        SecondarySourceGenerator.java
               altrmi/src/java/org/apache/commons/altrmi/generator/ant
                        AltrmiClassInternTask.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers
                        BaseMobileClass.java BaseMobileClassRetriever.java
  Log:
  inline compilation of proxys now possible
  
  Revision  Changes    Path
  1.11      +8 -6      jakarta-commons-sandbox/altrmi/PROPOSAL
  
  Index: PROPOSAL
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/PROPOSAL,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PROPOSAL	21 Jan 2002 21:19:49 -0000	1.10
  +++ PROPOSAL	25 Jan 2002 16:40:13 -0000	1.11
  @@ -9,13 +9,15 @@
   
   1) Any interface publishing
   
  -  - no forcing of extension of java.rmi.Remote
  -  - no forced declarations of "throws RemoteException"
  +  - Any object via the interfaces it publishes can be published remotely.
  +  - No transport lock-in :
  +    - No forcing of extension of java.rmi.Remote
  +    - No forced declarations of "throws java.rmi.RemoteException"
     
  -  * These two features are part of the reason why Graham Glass's 'Glue'
  -    product is so successful. His API goes several stages futher in that
  -    it pubishes APIs via SOAP so that any language in any location can
  -    use Glue published Java services.
  +    * These two features are part of the reason why Graham Glass's 'Glue'
  +      product is so successful. His API goes several stages futher in that
  +      it pubishes APIs via SOAP so that any language in any location can
  +      use Glue published Java services.
     
   2) Multiple transports
   
  
  
  
  1.3       +10 -5     jakarta-commons-sandbox/altrmi/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/build.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- build.xml	13 Jan 2002 19:25:20 -0000	1.2
  +++ build.xml	25 Jan 2002 16:40:13 -0000	1.3
  @@ -3,7 +3,7 @@
   
   <!--
           "Alternative (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: build.xml,v 1.2 2002/01/13 19:25:20 hammant Exp $
  +        $Id: build.xml,v 1.3 2002/01/25 16:40:13 hammant Exp $
   -->
   
   
  @@ -140,10 +140,14 @@
         <classpath refid="compile.classpath"/>
       </javac>
       
  +    <!-- includes="org/apache/commons/altrmi/server/impl/rmi/RmiAltrmiInovcationAdapter.class">
-->
  +    
  +    <echo>rmic?</echo>
       <rmic base="${build.home}/classes"
  -          includes="org/apache/commons/altrmi/server/impl/rmi/RmiAltrmiInovcationAdapter.class">
  +          includes="org/apache/commons/altrmi/common/RmiAltrmiInovcationHandler.class">
           <classpath refid="compile.classpath" />    
  -    </rmic>    
  +    </rmic>
  +    <echo>rmic!</echo>
       
     </target>
   
  @@ -216,8 +220,9 @@
               basedir="${build.home}/classes"
              manifest="src/conf/MANIFEST-generator.MF">
         <include name="org/apache/commons/altrmi/generator/**"/>
  -    </jar>    
  -    
  +      <include name="org/apache/commons/altrmi/compiler/**"/>
  +    </jar> 
  +               
     </target>
   
   </project>
  
  
  
  1.2       +16 -9     jakarta-commons-sandbox/altrmi/tests.xml
  
  Index: tests.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/tests.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- tests.xml	21 Jan 2002 15:38:20 -0000	1.1
  +++ tests.xml	25 Jan 2002 16:40:13 -0000	1.2
  @@ -3,7 +3,7 @@
   
   <!--
           "Alt (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: tests.xml,v 1.1 2002/01/21 15:38:20 hammant Exp $
  +        $Id: tests.xml,v 1.2 2002/01/25 16:40:13 hammant Exp $
   -->
   
   
  @@ -61,10 +61,6 @@
       <classpath refid="compile.classpath" />
     </taskdef>
     
  -  <taskdef name="altrmiclassintern" classname="org.apache.commons.altrmi.generator.ant.AltrmiClassInternTask">
  -    <classpath refid="compile.classpath" />
  -  </taskdef>
  -
   
   <!-- ========== Executable Targets ======================================== -->
   
  @@ -91,10 +87,16 @@
   
     <target name="generate" depends="prepare">
        
  -    <altrmiinterfaces genname="Hello" gendir="${build.home}/genjava" 
  +    <altrmiinterfaces genname="Hello" srcgendir="${build.home}/genjava" 
  +        classgendir="${build.home}/classes2" 
           classesorinterfaces="org.apache.commons.altrmi.test.TestInterface" 
  -        additionalfacades="org.apache.commons.altrmi.test.TestInterface2"/>
  +        additionalfacades="org.apache.commons.altrmi.test.TestInterface2">
  +      <classpath>
  +        <pathelement location="${build.home}/classes"/>
  +      </classpath>
  +    </altrmiinterfaces>        
   
  +    <!--
       <javac  srcdir="${build.home}/genjava"
                  destdir="${build.home}/classes2"
                    debug="${compile.debug}"
  @@ -102,6 +104,8 @@
                 optimize="${compile.optimize}">
             <classpath refid="compile.classpath"/>
       </javac>
  +    
  +
     
       <altrmiclassintern gendir="${build.home}/genjava2" 
           sourceclassdir="${build.home}/classes2/"
  @@ -114,7 +118,8 @@
                 optimize="${compile.optimize}">
             <classpath refid="compile.classpath"/>
       </javac>
  -
  +    
  +    -->
     
     </target>
   
  @@ -217,13 +222,15 @@
       <java classname="org.apache.commons.altrmi.test.SocketServerTest" fork="true">
         <classpath refid="testB1.classpath"/>
         <arg value="S"/>
  +      <arg value="ObjectStream"/>      
       </java>      
     </target>
     
  -  <target name="clientb-client" depends="generate">
  +  <target name="socketb-client" depends="generate">
       <java classname="org.apache.commons.altrmi.test.SocketClientTest" fork="true">
         <classpath refid="testB2.classpath"/>
         <arg value="S"/>
  +      <arg value="ObjectStream"/>
       </java>      
     </target>
   
  
  
  
  1.3       +2 -11     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AbstractMethodHandler.java
  
  Index: AbstractMethodHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AbstractMethodHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractMethodHandler.java	18 Jan 2002 11:03:20 -0000	1.2
  +++ AbstractMethodHandler.java	25 Jan 2002 16:40:13 -0000	1.3
  @@ -20,7 +20,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class AbstractMethodHandler {
   
  @@ -47,16 +47,7 @@
   
       protected String encodeClassName(String className) {
   
  -        StringBuffer sb = new StringBuffer();
  +        return className.replace('.','$');
   
  -        for (int i = 0; i < className.length(); i++) {
  -            char ch = className.charAt(i);
  -
  -            if (Character.isLetter(ch) | Character.isDigit(ch)) {
  -                sb.append(ch);
  -            }
  -        }
  -
  -        return sb.toString();
       }
   }
  
  
  
  1.7       +53 -14    jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/PrimarySourceGenerator.java
  
  Index: PrimarySourceGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/PrimarySourceGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PrimarySourceGenerator.java	16 Jan 2002 11:32:20 -0000	1.6
  +++ PrimarySourceGenerator.java	25 Jan 2002 16:40:13 -0000	1.7
  @@ -12,6 +12,7 @@
   
   import org.apache.commons.altrmi.common.AbstractMethodHandler;
   import org.apache.commons.altrmi.test.TestInterface;
  +import org.apache.commons.altrmi.javacompiler.JavaCompiler;
   
   import java.lang.reflect.Method;
   
  @@ -29,13 +30,15 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class PrimarySourceGenerator extends AbstractMethodHandler {
   
       private String[] mClassesOrInterfacesToExpose;
       private String[] mAdditionalFacades;
  -    private String mGenDir;
  +    protected String mSrcGenDir;
  +    protected String mClassGenDir;
  +    protected String mClasspath;
       private String mGenName;
       private PrintWriter mClassSource;
   
  @@ -49,6 +52,13 @@
       public void setClassOrInterfacesToExpose(String[] classesOrInterfacesToExpose) {
           mClassesOrInterfacesToExpose = classesOrInterfacesToExpose;
       }
  +    public void setClassOrInterfacesToExpose(Class[] classesOrInterfacesToExpose) {
  +        mClassesOrInterfacesToExpose = new String[classesOrInterfacesToExpose.length];
  +        for (int i = 0; i < classesOrInterfacesToExpose.length; i++) {
  +            Class facade = classesOrInterfacesToExpose[i];
  +            mClassesOrInterfacesToExpose[i] = facade.getName();
  +        }
  +    }
   
       /**
        * Method setClassOrInterfacesToExpose
  @@ -61,16 +71,24 @@
       public void setAdditionalfacades(String[] additionalFacades) {
           mAdditionalFacades = additionalFacades;
       }
  +    public void setAdditionalfacades(Class[] additionalFacades) {
  +        mAdditionalFacades = new String[additionalFacades.length];
  +        for (int i = 0; i < additionalFacades.length; i++) {
  +            Class facade = additionalFacades[i];
  +            mAdditionalFacades[i] = facade.getName();
  +        }
  +    }
   
  -    /**
  -     * Method setGenDir
  -     *
  -     *
  -     * @param genDir
  -     *
  -     */
  -    public void setGenDir(String genDir) {
  -        mGenDir = genDir;
  +    public void setSrcGenDir(String srcGenDir) {
  +        mSrcGenDir = srcGenDir;
  +    }
  +
  +    public void setClasspath(String classpath) {
  +        mClasspath = classpath;
  +    }
  +
  +    public void setClassGenDir(String classGenDir) {
  +        mClassGenDir = classGenDir;
       }
   
       /**
  @@ -91,7 +109,7 @@
        * @param cL
        *
        */
  -    public void generate(ClassLoader cL) throws SourceGenerationException {
  +    public void generateSrc(ClassLoader cL) throws SourceGenerationException {
   
           // The lookupable service class source.
           makeSource(cL, "Main", mClassesOrInterfacesToExpose);
  @@ -107,6 +125,27 @@
           }
       }
   
  +    public void generateClass(ClassLoader cL) {
  +        JavaCompiler jc = JavaCompiler.getDefaultCompiler();
  +        jc.setOutputDir(mClassGenDir);
  +        //jc.setCompilerPath();
  +        jc.addClassPath(mClassGenDir);
  +        jc.addClassPath(mClasspath);
  +        jc.addDefaultClassPath();
  +        jc.doCompile(mSrcGenDir + File.separator + "AltrmiGenerated" + mGenName + "_Main.java");
  +        jc.doCompile(mSrcGenDir + File.separator + "AltrmiGenerated2" + mGenName + "_Main.java");
  +        System.out.println(jc.getCompilerMessage());
  +
  +        if (mAdditionalFacades != null) {
  +            for (int i = 0; i < mAdditionalFacades.length; i++) {
  +                String classname = encodeClassName(mAdditionalFacades[i]);
  +                jc.doCompile(mSrcGenDir + File.separator + "AltrmiGenerated" + mGenName
+ "_" + classname + ".java");
  +                jc.doCompile(mSrcGenDir + File.separator + "AltrmiGenerated2" + mGenName
+ "_" + classname + ".java");
  +            }
  +        }
  +
  +    }
  +
       /**
        * Method makeSource
        *
  @@ -124,7 +163,7 @@
           // methdos could be in more than one interface.
           Vector methodsDone = new Vector();
   
  -        String filename = mGenDir + File.separator + "AltrmiGenerated" + mGenName + "_"
+ name + ".java";
  +        String filename = mSrcGenDir + File.separator + "AltrmiGenerated" + mGenName +
"_" + name + ".java";
           try {
               mClassSource = new PrintWriter(new FileOutputStream(filename));
           } catch (FileNotFoundException e) {
  @@ -264,7 +303,7 @@
       public void makeSource2(ClassLoader cL, String name, String[] classOrInterfacesToExpose)
               throws SourceGenerationException {
   
  -        String filename = mGenDir + File.separator + "AltrmiGenerated2" + mGenName + "_"
+ name + ".java";
  +        String filename = mSrcGenDir + File.separator + "AltrmiGenerated2" + mGenName +
"_" + name + ".java";
           try {
               PrintWriter class2Source = new PrintWriter(new FileOutputStream(filename));
   
  
  
  
  1.4       +24 -9     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ant/AltrmiInterfaceTask.java
  
  Index: AltrmiInterfaceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ant/AltrmiInterfaceTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AltrmiInterfaceTask.java	13 Jan 2002 00:13:53 -0000	1.3
  +++ AltrmiInterfaceTask.java	25 Jan 2002 16:40:13 -0000	1.4
  @@ -18,12 +18,14 @@
   
   import java.util.StringTokenizer;
   import java.util.Vector;
  +import java.io.File;
   
   public class AltrmiInterfaceTask extends Task {
   
       protected String[] mClassOrInterfacesToExpose;
       protected String[] mAdditionalFacades;
  -    protected String mGenDir;
  +    protected String mSrcGenDir;
  +    protected String mClassGenDir;
       protected String mGenName;
       protected Path classpath;
   
  @@ -50,8 +52,15 @@
           strings.copyInto(mAdditionalFacades);
       }
   
  -    public void setGendir(String genDir) {
  -        mGenDir = genDir;
  +    public void setSrcgendir(String srcGenDir) {
  +        mSrcGenDir = srcGenDir.replace('/',File.separatorChar);
  +        mSrcGenDir = mSrcGenDir.replace('\\',File.separatorChar);
  +
  +    }
  +
  +    public void setClassgendir(String classGenDir) {
  +        mClassGenDir = classGenDir.replace('/',File.separatorChar);
  +        mClassGenDir = mClassGenDir.replace('\\',File.separatorChar);
       }
   
       public void setGenname(String genName) {
  @@ -81,18 +90,23 @@
           if (mClassOrInterfacesToExpose == null) {
               throw new BuildException("Specify at least one interface to expose");
           }
  -        if (mGenDir == null) {
  +        if (mSrcGenDir == null) {
               throw new BuildException("Specify the directory to generate Java source in");
           }
  +        if (mClassGenDir == null) {
  +            throw new BuildException("Specify the directory to generate Java classes in");
  +        }
           if (mGenName == null) {
               throw new BuildException("Specify the name to use for lookup");
           }
           PrimarySourceGenerator sg = new PrimarySourceGenerator();
  -        sg.setGenDir(mGenDir);
  -        sg.setGenName(mGenName);
  -        sg.setClassOrInterfacesToExpose(mClassOrInterfacesToExpose);
  -        sg.setAdditionalfacades(mAdditionalFacades);
           try {
  +            sg.setSrcGenDir(new File(mSrcGenDir).getAbsolutePath());
  +            sg.setClassGenDir(new File(mClassGenDir).getAbsolutePath());
  +            sg.setGenName(mGenName);
  +            sg.setClasspath(classpath.toString());
  +            sg.setClassOrInterfacesToExpose(mClassOrInterfacesToExpose);
  +            sg.setAdditionalfacades(mAdditionalFacades);
               ClassLoader cL = null;
               if (classpath != null) {
                   cL = new AntClassLoader(project, classpath);
  @@ -100,7 +114,8 @@
                   cL = this.getClass().getClassLoader();
               }
   
  -            sg.generate(cL);
  +            sg.generateSrc(cL);
  +            sg.generateClass(cL);
           } catch (SourceGenerationException sge) {
               throw new BuildException(sge.getMessage());
           }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/javacompiler/JavaCompiler.java
  
  Index: JavaCompiler.java
  ===================================================================
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.altrmi.javacompiler;
  
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.File;
  import java.net.URL;
  
  
  /**
   * If you want to plugin your own Java compiler, you probably want to
   * write a class that implements this interface.
   *
   * @author Anil K. Vijendran
   * @author Sam Ruby
   * @author Costin Manolache
   */
  public abstract class JavaCompiler {
  
      static String CPSEP = System.getProperty("path.separator");
      protected String classpath;
      protected String compilerPath = "jikes";
      protected String outdir;
      protected ByteArrayOutputStream out;
      protected boolean classDebugInfo = false;
  
      protected JavaCompiler() {
          reset();
      }
  
      /**
       * Specify where the compiler can be found
       */
      public void setCompilerPath(String compilerPath) {
  
          if (compilerPath != null) {
              this.compilerPath = compilerPath;
          }
      }
  
  
      /**
       * Set the class path for the compiler
       */
      public void setClasspath(String classpath) {
          this.classpath = classpath;
      }
  
      /**
       * Method addClassPath
       *
       *
       * @param path
       *
       */
      public void addClassPath(String path) {
  
          // XXX use StringBuffer
          classpath = classpath + CPSEP + path;
      }
  
      /**
       * Method addDefaultClassPath
       *
       *
       */
      public void addDefaultClassPath() {
          addClassPath(System.getProperty("java.class.path"));
      }
  
      /**
       * Set the output directory
       */
      public void setOutputDir(String outdir) {
          this.outdir = outdir;
      }
  
      // Removed - we manage ourself the buffer and return it as string.
      // It can be added later if someone really need that.
      //     /**
      //      * Set where you want the compiler output (messages) to go
      //      */
      //     public void setMsgOutput(OutputStream out) {
      //       this.out = out;
      //     }
  
      /**
       * Method getCompilerMessage
       *
       *
       * @return
       *
       */
      public String getCompilerMessage() {
          return out.toString();
      }
  
      /**
       * Set if you want debugging information in the class file
       */
      public void setClassDebugInfo(boolean classDebugInfo) {
          this.classDebugInfo = classDebugInfo;
      }
  
      /**
       * Method recycle
       *
       *
       */
      public void recycle() {}
  
      /** Reset all compilation state, but keep the settings.
       *  The compiler can be used again.
       */
      public void reset() {
          out = new ByteArrayOutputStream(256);
      }
  
      // -------------------- Compile method --------------------
  
      /** The main method - compile the source, using the previous settings.
       */
      public boolean compile(String source) {
  
          try {
              File f = new File(source);
  
              source = f.getCanonicalPath();
          } catch (IOException ex) {
              ex.printStackTrace();
          }
  
          return doCompile(source);
      }
  
      /**
       * Execute the compiler
       * @param source - file name of the source to be compiled
       */
      public abstract boolean doCompile(String source);
  
      // -------------------- Utils --------------------
  
      /**
       * Method getCompilerPluginClass
       *
       *
       * @param s
       *
       * @return
       *
       */
      public static Class getCompilerPluginClass(String s) {
  
          try {
              Class c = Class.forName(s);
  
              return c;
          } catch (Exception ex) {
              return null;
          }
      }
  
      /**
       * Method getDefaultCompiler
       *
       *
       * @return
       *
       */
      public static JavaCompiler getDefaultCompiler() {
          return new SunJavaCompiler();
      }
  
      //-------------------- Class path utils --------------------
  
      /** Create a classpath string from a URL[] ( used in URLClassLoader )
       */
      public static String extractClassPath(URL urls[]) {
  
          String separator = System.getProperty("path.separator", ":");
          String cpath = "";
  
          for (int i = 0; i < urls.length; i++) {
              URL cp = urls[i];
  
              if (cp == null) {
                  continue;
              }
  
              File f = new File(cp.getFile());
  
              if (cpath.length() > 0) {
                  cpath += separator;
              }
  
              cpath += f;
          }
  
          return cpath;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/javacompiler/SunJavaCompiler.java
  
  Index: SunJavaCompiler.java
  ===================================================================
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.altrmi.javacompiler;
  
  
  
  import java.io.OutputStream;
  
  import sun.tools.javac.Main;
  
  
  /**
   * The default compiler. This is the javac present in JDK 1.1.x and
   * JDK 1.2.
   *
   * At some point we need to make sure there is a class like this for
   * JDK 1.3, and other javac-like animals that people want to use.
   *
   * @author Anil K. Vijendran
   */
  public class SunJavaCompiler extends JavaCompiler {
  
      /**
       * Method doCompile
       *
       *
       * @param source
       *
       * @return
       *
       */
      public boolean doCompile(String source) {
  
          Main compiler = new Main(out, "jsp->javac");
          String[] args;
  
          if (classDebugInfo) {
              args = new String[] {
                  "-g", "-classpath", classpath, "-d", outdir, source
              };
          } else {
              args = new String[] {
                  "-classpath", classpath, "-d", outdir, source
              };
          }
  
          return compiler.compile(args);
      }
  }
  
  
  
  1.3       +1 -6      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiPublisher.java
  
  Index: AltrmiPublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiPublisher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AltrmiPublisher.java	21 Jan 2002 15:38:21 -0000	1.2
  +++ AltrmiPublisher.java	25 Jan 2002 16:40:13 -0000	1.3
  @@ -8,17 +8,12 @@
   package org.apache.commons.altrmi.server;
   
   
  -
  -import org.apache.commons.altrmi.common.AltrmiReply;
  -import org.apache.commons.altrmi.common.AltrmiRequest;
  -
  -
   /**
    * Interface AltrmiServer
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.2 $
  + * @version * $Revision: 1.3 $
    */
   public interface AltrmiPublisher {
   
  
  
  
  1.3       +2 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiServer.java
  
  Index: AltrmiServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AltrmiServer.java	14 Jan 2002 23:03:30 -0000	1.2
  +++ AltrmiServer.java	25 Jan 2002 16:40:13 -0000	1.3
  @@ -19,9 +19,9 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.2 $
  + * @version * $Revision: 1.3 $
    */
  -public interface AltrmiServer extends AltrmiPublisher {
  +public interface AltrmiServer extends AltrmiPublisher, AltrmiProxyGenerator {
   
       /**
        * Method setClassRetriever
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiProxyGenerator.java
  
  Index: AltrmiProxyGenerator.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.commons.altrmi.server;
  
  
  /**
   * Interface AltrmiProxyGenerator
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version * $Revision: 1.1 $
   */
  public interface AltrmiProxyGenerator {
  
      /**
       * Method generate
       *
       *
       * @param impl
       * @param asName
       * @param classOrInterfaceToExpose
       *
       */
      void generate(Object impl, String asName, Class classOrInterfaceToExpose) throws PublicationException;
  
      /**
       * Method generate
       *
       *
       * @param impl
       * @param asName
       * @param classOrInterfaceToExpose
       * @param additionalFacade
       *
       */
      void generate(Object impl, String asName, Class classOrInterfaceToExpose, Class additionalFacade)
throws PublicationException;
  
      /**
       * Method generate
       *
       *
       * @param impl
       * @param asName
       * @param classOrInterfaceToExpose
       * @param additionalFacades
       *
       */
      void generate(Object impl, String asName, Class classOrInterfaceToExpose, Class[] additionalFacades)
throws PublicationException;
  
  
      /**
       * Method generate
       *
       *
       * @param impl
       * @param asName
       * @param classesOrInterfacesToExpose
       *
       */
      void generate(Object impl, String asName, Class[] classesOrInterfacesToExpose) throws
PublicationException;
  
      /**
       * Method generate
       *
       *
       * @param impl
       * @param asName
       * @param classesOrInterfacesToExpose
       * @param additionalFacades
       *
       */
      void generate(Object impl, String asName, Class[] classesOrInterfacesToExpose, Class[]
additionalFacades) throws PublicationException;
  
  
  
  }
  
  
  
  1.11      +102 -2    jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractServer.java	21 Jan 2002 20:10:34 -0000	1.10
  +++ AbstractServer.java	25 Jan 2002 16:40:14 -0000	1.11
  @@ -39,14 +39,17 @@
   import org.apache.commons.altrmi.server.ClassRetriever;
   import org.apache.commons.altrmi.server.ServerInvocationHandler;
   import org.apache.commons.altrmi.server.AltrmiAuthenticator;
  -import org.apache.commons.altrmi.server.impl.classretrievers.BaseMobileClassRetriever;
   import org.apache.commons.altrmi.server.impl.classretrievers.NoClassRetriever;
  +import org.apache.commons.altrmi.generator.PrimarySourceGenerator;
  +import org.apache.commons.altrmi.generator.SourceGenerationException;
  +import org.apache.tools.ant.AntClassLoader;
   
   import java.lang.reflect.Method;
   
   import java.util.HashMap;
   import java.util.Vector;
   import java.util.Iterator;
  +import java.io.File;
   
   
   /**
  @@ -54,7 +57,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements AltrmiServer
{
   
  @@ -72,6 +75,9 @@
       protected static final int STOPPED = 33;
       protected static final int UNSTARTED = 44;
       protected int mState = UNSTARTED;
  +    private String mAltrmiClasspath;
  +    private String mClassGenDir;
  +    private String mSrcGenDir;
   
       /**
        * Method publish
  @@ -457,4 +463,98 @@
           return new Long((long) ((long) SESSION++ << 32) + (long) Math.round(Math.random()));
       }
   
  +    /**
  +     * Method generate
  +     *
  +     *
  +     * @param impl
  +     * @param asName
  +     * @param classOrInterfaceToExpose
  +     * @param additionalFacade
  +     *
  +     */
  +    public void generate(Object impl, String asName, Class classOrInterfaceToExpose, Class
additionalFacade) throws PublicationException {
  +        generate(impl, asName, classOrInterfaceToExpose, new Class[] {additionalFacade}
);
  +    }
  +
  +    /**
  +     * Method generate
  +     *
  +     *
  +     * @param impl
  +     * @param asName
  +     * @param classOrInterfaceToExpose
  +     * @param additionalFacades
  +     *
  +     */
  +    public void generate(Object impl, String asName, Class classOrInterfaceToExpose, Class[]
additionalFacades) throws PublicationException {
  +        generate(impl, asName, new Class[] { classOrInterfaceToExpose }, additionalFacades
);
  +    }
  +
  +    /**
  +     * Method generate
  +     *
  +     *
  +     * @param impl
  +     * @param asName
  +     * @param classesOrInterfacesToExpose
  +     *
  +     */
  +    public void generate(Object impl, String asName, Class[] classesOrInterfacesToExpose)
throws PublicationException {
  +        generate(impl, asName, classesOrInterfacesToExpose, new Class[0] );
  +    }
  +
  +    /**
  +     * Method generate
  +     *
  +     *
  +     * @param impl
  +     * @param asName
  +     * @param classOrInterfaceToExpose
  +     *
  +     */
  +    public void generate(Object impl, String asName, Class classOrInterfaceToExpose) throws
PublicationException {
  +        generate(impl, asName, new Class[] { classOrInterfaceToExpose } , new Class[0]
);
  +    }
  +
  +    public void setAltrmiClasspath(String altrmiClasspath) {
  +        mAltrmiClasspath = altrmiClasspath;
  +    }
  +
  +    public void setClassGenDir(String classGenDir) {
  +        mClassGenDir = classGenDir;
  +    }
  +
  +    public void setSrcGenDir(String srcGenDir) {
  +        mSrcGenDir = srcGenDir;
  +    }
  +
  +    /**
  +     * Method generate
  +     *
  +     *
  +     * @param impl
  +     * @param asName
  +     * @param classesOrInterfacesToExpose
  +     * @param additionalFacades
  +     *
  +     */
  +    public void generate(Object impl, String asName, Class[] classesOrInterfacesToExpose,
Class[] additionalFacades) throws PublicationException {
  +        PrimarySourceGenerator sg = new PrimarySourceGenerator();
  +        sg.setSrcGenDir(mSrcGenDir);
  +        sg.setClassGenDir(mClassGenDir);
  +        sg.setGenName(asName);
  +        sg.setClasspath(mAltrmiClasspath);
  +        sg.setClassOrInterfacesToExpose(classesOrInterfacesToExpose);
  +        sg.setAdditionalfacades(additionalFacades);
  +        ClassLoader cL = this.getClass().getClassLoader();
  +        try {
  +            sg.generateSrc(cL);
  +            sg.generateClass(cL);
  +        } catch (SourceGenerationException e) {
  +            e.printStackTrace();
  +            // TODO ?
  +        }
  +
  +    }
   }
  
  
  
  1.7       +4 -4      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DirectTest.java
  
  Index: DirectTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DirectTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DirectTest.java	21 Jan 2002 15:38:21 -0000	1.6
  +++ DirectTest.java	25 Jan 2002 16:40:14 -0000	1.7
  @@ -11,7 +11,7 @@
   
   import org.apache.commons.altrmi.server.impl.direct.DirectServer;
   import org.apache.commons.altrmi.server.impl.direct.DirectInovcationAdapter;
  -import org.apache.commons.altrmi.server.impl.classretrievers.BaseMobileClassRetriever;
  +import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
   import org.apache.commons.altrmi.common.AltrmiInvocationHandler;
   import org.apache.commons.altrmi.common.AltrmiConnectionException;
   import org.apache.commons.altrmi.client.AltrmiHostContext;
  @@ -28,7 +28,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class DirectTest {
   
  @@ -51,7 +51,7 @@
   
           DirectServer ds = new DirectServer();
           if (mServerOrClientFactory.equals("S")) {
  -            ds.setClassRetriever(new BaseMobileClassRetriever());
  +            ds.setClassRetriever(new JarFileClassRetriever("build/classes2"));
           }
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
  @@ -69,7 +69,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.6 $
  +     * @version $Revision: 1.7 $
        */
       static class DirectTestClient implements Runnable {
   
  
  
  
  1.7       +4 -4      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/PipeTest.java
  
  Index: PipeTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/PipeTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PipeTest.java	19 Jan 2002 13:30:19 -0000	1.6
  +++ PipeTest.java	25 Jan 2002 16:40:14 -0000	1.7
  @@ -11,7 +11,7 @@
   
   import org.apache.commons.altrmi.server.impl.piped.AbstractPipedServer;
   import org.apache.commons.altrmi.server.impl.piped.PipedObjectStreamServer;
  -import org.apache.commons.altrmi.server.impl.classretrievers.BaseMobileClassRetriever;
  +import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
   import org.apache.commons.altrmi.client.AltrmiHostContext;
   import org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
   import org.apache.commons.altrmi.client.AltrmiFactory;
  @@ -30,7 +30,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class PipeTest {
   
  @@ -53,7 +53,7 @@
   
           AbstractPipedServer ps = new PipedObjectStreamServer();
           if (mServerOrClientFactory.equals("S")) {
  -            ps.setClassRetriever(new BaseMobileClassRetriever());
  +            ps.setClassRetriever(new JarFileClassRetriever("build/classes2"));
           }
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
  @@ -71,7 +71,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.6 $
  +     * @version $Revision: 1.7 $
        */
       static class PipedTestClient implements Runnable {
   
  
  
  
  1.3       +3 -3      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/RmiServerTest.java
  
  Index: RmiServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/RmiServerTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RmiServerTest.java	14 Jan 2002 16:36:08 -0000	1.2
  +++ RmiServerTest.java	25 Jan 2002 16:40:14 -0000	1.3
  @@ -10,7 +10,7 @@
   
   
   import org.apache.commons.altrmi.server.impl.rmi.RmiServer;
  -import org.apache.commons.altrmi.server.impl.classretrievers.BaseMobileClassRetriever;
  +import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
   
   import java.io.IOException;
   
  @@ -20,7 +20,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class RmiServerTest {
   
  @@ -39,7 +39,7 @@
   
           RmiServer rs = new RmiServer("127.0.0.1", 4321);
           if (args[0].equals("S")) {
  -            rs.setClassRetriever(new BaseMobileClassRetriever());
  +            rs.setClassRetriever(new JarFileClassRetriever("build/classes2"));
           }
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
  
  
  
  1.7       +3 -3      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketServerTest.java
  
  Index: SocketServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketServerTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SocketServerTest.java	18 Jan 2002 17:33:07 -0000	1.6
  +++ SocketServerTest.java	25 Jan 2002 16:40:14 -0000	1.7
  @@ -12,7 +12,7 @@
   
   import org.apache.commons.altrmi.server.impl.socket.CompleteSocketObjectStreamServer;
   import org.apache.commons.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  -import org.apache.commons.altrmi.server.impl.classretrievers.BaseMobileClassRetriever;
  +import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
   import org.apache.commons.altrmi.server.impl.AbstractServer;
   
   import java.io.IOException;
  @@ -23,7 +23,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class SocketServerTest {
   
  @@ -57,7 +57,7 @@
           }
   
           if (args[0].equals("S")) {
  -            as.setClassRetriever(new BaseMobileClassRetriever());
  +            as.setClassRetriever(new JarFileClassRetriever("build/classes2"));
           }
   
           TestInterfaceImpl ti = new TestInterfaceImpl();
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message