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/armi/src/java/org/apache/commons/armi/test DirectTest.java PipeTest.java RmiClientTest.java SocketClientTest.java
Date Sun, 30 Dec 2001 00:42:10 GMT
hammant     01/12/29 16:42:10

  Modified:    armi     PROPOSAL test.xml
               armi/src/java/org/apache/commons/armi/client
                        ArmiFactory.java
               armi/src/java/org/apache/commons/armi/server/impl
                        AbstractServer.java
               armi/src/java/org/apache/commons/armi/test DirectTest.java
                        PipeTest.java RmiClientTest.java
                        SocketClientTest.java
  Added:       armi/src/java/org/apache/commons/armi/client/impl
                        ClientClassArmiFactory.java
                        DefaultBlockingArmiFactory.java
                        ServerClassArmiFactory.java
                        TransportedClassLoader.java
               armi/src/java/org/apache/commons/armi/common ClassReply.java
                        ClassRequest.java RequestFailedReply.java
               armi/src/java/org/apache/commons/armi/generator
                        PrimarySourceGenerator.java
                        SecondarySourceGenerator.java
               armi/src/java/org/apache/commons/armi/generator/ant
                        ArmiClassInternTask.java ArmiInterfaceTask.java
               armi/src/java/org/apache/commons/armi/server/impl
                        BaseMobileClass.java
  Removed:     armi/src/java/org/apache/commons/armi/client/impl
                        DefaultArmiFactory.java
               armi/src/java/org/apache/commons/armi/generator
                        SourceGenerator.java
               armi/src/java/org/apache/commons/armi/generator/ant
                        ArmiTask.java
  Log:
  Proxy Classes (can be) forwarded to client from server now.
  
  Revision  Changes    Path
  1.2       +4 -0      jakarta-commons-sandbox/armi/PROPOSAL
  
  Index: PROPOSAL
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/PROPOSAL,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PROPOSAL	29 Dec 2001 01:35:22 -0000	1.1
  +++ PROPOSAL	30 Dec 2001 00:42:10 -0000	1.2
  @@ -49,6 +49,10 @@
   
     - Later we will allow server to pass forward implementation class
       definitions as opposed to just newInstance() them as at present.
  +    
  +3) This is not of any use for EJB Home/Remote interfaces.  The container 
  +   maker chooses the transport for use that container, not the bean coder.
  +   This is intended for other client server solutions.
   
   Initial commiters:
   
  
  
  
  1.2       +95 -19    jakarta-commons-sandbox/armi/test.xml
  
  Index: test.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/test.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- test.xml	28 Dec 2001 18:08:37 -0000	1.1
  +++ test.xml	30 Dec 2001 00:42:10 -0000	1.2
  @@ -3,7 +3,7 @@
   
   <!--
           "Alt (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: test.xml,v 1.1 2001/12/28 18:08:37 hammant Exp $
  +        $Id: test.xml,v 1.2 2001/12/30 00:42:10 hammant Exp $
   -->
   
   
  @@ -40,14 +40,29 @@
     </path>
     
     <!-- For running of tests -->
  -  <path id="test2.classpath">
  +  <path id="testA.classpath">
       <pathelement location="${build.home}/classes"/>
       <pathelement location="${build.home}/classes2"/>
     </path>  
  +  
  +  <path id="testB1.classpath">
  +    <pathelement location="${build.home}/classes"/>
  +    <pathelement location="${build.home}/classes3"/>
  +  </path>    
  +    
  +  <path id="testB2.classpath">
  +    <pathelement location="${build.home}/classes"/>
  +  </path>    
  +  
  +  
   
  -  <taskdef name="armi" classname="org.apache.commons.armi.generator.ant.ArmiTask">
  +  <taskdef name="armiinterfaces" classname="org.apache.commons.armi.generator.ant.ArmiInterfaceTask">
       <classpath refid="compile.classpath" />
  -  </taskdef>   
  +  </taskdef>
  +  
  +  <taskdef name="armiclassintern" classname="org.apache.commons.armi.generator.ant.ArmiClassInternTask">
  +    <classpath refid="compile.classpath" />
  +  </taskdef>
   
   
   <!-- ========== Executable Targets ======================================== -->
  @@ -58,16 +73,24 @@
       <mkdir dir="${build.home}/classes2"/>  
       <delete>
         <fileset dir="${build.home}/classes2" includes="*" defaultexcludes="no"/>
  -    </delete>     
  +    </delete>
       <mkdir dir="${build.home}/genjava"/>
       <delete>
         <fileset dir="${build.home}/genjava" includes="*" defaultexcludes="no"/>
  -    </delete>     
  +    </delete>
  +    <mkdir dir="${build.home}/genjava2"/>
  +    <delete>
  +      <fileset dir="${build.home}/genjava2" includes="*" defaultexcludes="no"/>
  +    </delete>
  +    <mkdir dir="${build.home}/classes3"/>  
  +    <delete>
  +      <fileset dir="${build.home}/classes3" includes="*" defaultexcludes="no"/>
  +    </delete>
     </target>
   
     <target name="generate" depends="prepare">
        
  -    <armi genname="Hello" gendir="${build.home}/genjava" 
  +    <armiinterfaces genname="Hello" gendir="${build.home}/genjava" 
           interfaces="org.apache.commons.armi.test.TestInterface" />
   
       <javac  srcdir="${build.home}/genjava"
  @@ -78,42 +101,95 @@
             <classpath refid="compile.classpath"/>
       </javac>
     
  +    <armiclassintern genname="Hello" gendir="${build.home}/genjava2" 
  +        encapsulated="${build.home}/classes2/ArmiGeneratedHello.class" />  
  +
  +    <javac  srcdir="${build.home}/genjava2"
  +               destdir="${build.home}/classes3"
  +                 debug="${compile.debug}"
  +           deprecation="${compile.deprecation}"
  +              optimize="${compile.optimize}">
  +          <classpath refid="compile.classpath"/>
  +    </javac>
  +
  +  
  +  </target>
  +
  +  <target name="test1a-serve">
  +    <java classname="org.apache.commons.armi.test.SocketServerTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>
  +  
  +  <target name="test1a-client" depends="generate">
  +    <java classname="org.apache.commons.armi.test.SocketClientTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
     </target>
   
  -  <target name="test1-serve">
  +  <target name="test2a" depends="generate">
  +    <java classname="org.apache.commons.armi.test.PipeTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>
  +
  +  <target name="test3a-serve">
  +    <java classname="org.apache.commons.armi.test.RmiServerTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>
  +  
  +  <target name="test3a-client" depends="generate">
  +    <java classname="org.apache.commons.armi.test.RmiClientTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>
  +
  +  <target name="test4a" depends="generate">
  +    <java classname="org.apache.commons.armi.test.DirectTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>
  +
  +  <target name="test1b-serve">
       <java classname="org.apache.commons.armi.test.SocketServerTest" fork="true">
  -      <classpath refid="test2.classpath"/>
  +      <classpath refid="testB1.classpath"/>
       </java>      
     </target>
     
  -  <target name="test1-client" depends="generate">
  +  <target name="test1b-client" depends="generate">
       <java classname="org.apache.commons.armi.test.SocketClientTest" fork="true">
  -      <classpath refid="test2.classpath"/>
  +      <classpath refid="testB2.classpath"/>
  +      <arg value="S"/>
       </java>      
     </target>
   
  -  <target name="test2" depends="generate">
  +  <target name="test2b" depends="generate">
       <java classname="org.apache.commons.armi.test.PipeTest" fork="true">
  -      <classpath refid="test2.classpath"/>
  +      <classpath refid="testB1.classpath"/>
  +      <arg value="S"/>
       </java>      
     </target>
   
  -  <target name="test3-serve">
  +  <target name="test3b-serve">
       <java classname="org.apache.commons.armi.test.RmiServerTest" fork="true">
  -      <classpath refid="test2.classpath"/>
  +      <classpath refid="testB1.classpath"/>
       </java>      
     </target>
     
  -  <target name="test3-client" depends="generate">
  +  <target name="test3b-client" depends="generate">
       <java classname="org.apache.commons.armi.test.RmiClientTest" fork="true">
  -      <classpath refid="test2.classpath"/>
  +      <classpath refid="testB2.classpath"/>
  +      <arg value="S"/>
       </java>      
     </target>
   
  -  <target name="test4" depends="generate">
  +  <target name="test4b" depends="generate">
       <java classname="org.apache.commons.armi.test.DirectTest" fork="true">
  -      <classpath refid="test2.classpath"/>
  +      <classpath refid="testB1.classpath"/>
  +      <arg value="S"/>
       </java>      
     </target>
  +
   
   </project>
  
  
  
  1.2       +14 -7     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java
  
  Index: ArmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArmiFactory.java	28 Dec 2001 18:08:37 -0000	1.1
  +++ ArmiFactory.java	30 Dec 2001 00:42:10 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java,v 1.1 2001/12/28 18:08:37 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:37 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java,v 1.2 2001/12/30 00:42:10 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/30 00:42:10 $
    *
    * ====================================================================
    *
  @@ -63,7 +63,7 @@
   
   
   
  -import org.apache.commons.armi.client.impl.DefaultArmiFactory;
  +import org.apache.commons.armi.client.impl.ClientClassArmiFactory;
   import org.apache.commons.armi.common.ArmiConnectionException;
   
   
  @@ -72,11 +72,18 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class ArmiFactory {
   
  -    private static ArmiFactory mDefaultArmiFactory;
  +    private static transient ArmiFactory mDefaultArmiFactory;
  +
  +    public static synchronized void setDefaultArmiFactory(ArmiFactory armiFactory) {
  +        // set once.
  +        if (mDefaultArmiFactory == null) {
  +            mDefaultArmiFactory = armiFactory;
  +        }
  +    }
   
       /**
        * Method getDefaultArmiFactory
  @@ -88,7 +95,7 @@
       public static synchronized ArmiFactory getDefaultArmiFactory() {
   
           if (mDefaultArmiFactory == null) {
  -            mDefaultArmiFactory = new DefaultArmiFactory();
  +            mDefaultArmiFactory = new ClientClassArmiFactory();
           }
   
           return mDefaultArmiFactory;
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ClientClassArmiFactory.java
  
  Index: ClientClassArmiFactory.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ClientClassArmiFactory.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.client.impl;
  
  import org.apache.commons.armi.client.ArmiFactory;
  import org.apache.commons.armi.client.ArmiHostContext;
  import org.apache.commons.armi.common.ArmiConnectionException;
  
  /**
   * Class ClientClassArmiFactory
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ClientClassArmiFactory extends ArmiFactory {
  
      /**
       * Method lookup
       *
       *
       * @param hostContext
       * @param publishedServiceName
       *
       * @return
       *
       * @throws ArmiConnectionException
       *
       */
      public Object lookup(ArmiHostContext hostContext, String publishedServiceName)
              throws ArmiConnectionException {
  
          try {
              Class clazz = Class.forName("ArmiGenerated" + publishedServiceName);
              BaseServedObject bo = (BaseServedObject) clazz.newInstance();
  
              bo.armiSetInvocationHandler(hostContext.getInvocationHandler());
              bo.armiSetPublishedObjectName(publishedServiceName);
  
              return bo;
          } catch (ClassNotFoundException cnfe) {
              throw new ArmiConnectionException("Generated class not found during lookup : "
                                                + cnfe.getMessage());
          } catch (InstantiationException ie) {
              throw new ArmiConnectionException("Generated class not instantiable during lookup : "
                                                + ie.getMessage());
          } catch (IllegalAccessException iae) {
              throw new ArmiConnectionException("Illegal access to generated class during lookup : "
                                                + iae.getMessage());
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/DefaultBlockingArmiFactory.java
  
  Index: DefaultBlockingArmiFactory.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/DefaultBlockingArmiFactory.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.client.impl;
  
  import org.apache.commons.armi.client.ArmiFactory;
  import org.apache.commons.armi.client.ArmiHostContext;
  import org.apache.commons.armi.common.ArmiConnectionException;
  
  
  /**
   * Class DefaultBlockingArmiFactory
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultBlockingArmiFactory extends ArmiFactory {
  
      /**
       * Method lookup
       *
       *
       * @param hostContext
       * @param publishedServiceName
       *
       * @return
       *
       * @throws ArmiConnectionException
       *
       */
      public Object lookup(ArmiHostContext hostContext, String publishedServiceName)
              throws ArmiConnectionException {
              throw new ArmiConnectionException("The default ArmiFactory is disabled");
  
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ServerClassArmiFactory.java
  
  Index: ServerClassArmiFactory.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ServerClassArmiFactory.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.client.impl;
  
  
  import org.apache.commons.armi.client.ArmiFactory;
  import org.apache.commons.armi.client.ArmiHostContext;
  import org.apache.commons.armi.common.ClassReply;
  import org.apache.commons.armi.common.ArmiConnectionException;
  import org.apache.commons.armi.common.ClassRequest;
  
  import java.util.HashMap;
  
  
  /**
   * Class ServerClassArmiFactory
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ServerClassArmiFactory extends ArmiFactory {
  
      private HashMap mPublishedServiceClassLoaders = new HashMap();
  
      /**
       * Method lookup
       *
       *
       * @param hostContext
       * @param publishedServiceName
       *
       * @return
       *
       * @throws ArmiConnectionException
       *
       */
      public Object lookup(ArmiHostContext hostContext, String publishedServiceName)
              throws ArmiConnectionException {
          try {
              TransportedClassLoader tcl = null;
              if (mPublishedServiceClassLoaders.containsKey(publishedServiceName)) {
                  tcl = (TransportedClassLoader) mPublishedServiceClassLoaders.get(publishedServiceName);
              } else {
                  ClassReply cr = (ClassReply) hostContext.getInvocationHandler().handleInvocation(new ClassRequest(publishedServiceName));
                  tcl = new TransportedClassLoader("ArmiGenerated" + publishedServiceName, cr.getClassBytes());
                  tcl.initialize();
                  mPublishedServiceClassLoaders.put(publishedServiceName, tcl);
              }
              BaseServedObject bo = (BaseServedObject) tcl.loadClass("ArmiGenerated" + publishedServiceName).newInstance();
              System.out.println("CL=" + bo.getClass().getClassLoader().getClass().getName());
              bo.armiSetInvocationHandler(hostContext.getInvocationHandler());
              bo.armiSetPublishedObjectName(publishedServiceName);
              return bo;
          } catch (ClassNotFoundException cnfe) {
              throw new ArmiConnectionException("Generated class not found during lookup : "
                                                + cnfe.getMessage());
          } catch (InstantiationException ie) {
              throw new ArmiConnectionException("Generated class not instantiable during lookup : "
                                                + ie.getMessage());
          } catch (IllegalAccessException iae) {
              throw new ArmiConnectionException("Illegal access to generated class during lookup : "
                                                + iae.getMessage());
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/TransportedClassLoader.java
  
  Index: TransportedClassLoader.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/TransportedClassLoader.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.client.impl;
  
  public final class TransportedClassLoader extends ClassLoader {
  
      private final transient byte[] mClassBytes;
      private final transient String mClassName;
  
      public TransportedClassLoader(String className, byte[] classBytes) {
          mClassBytes = classBytes;
          mClassName = className;
      }
  
      public void initialize() {
          this.defineClass(mClassName, mClassBytes, 0, mClassBytes.length);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassReply.java
  
  Index: ClassReply.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassReply.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.common;
  
  
  
  /**
   * Class ClassReply
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ClassReply extends ArmiReply {
  
      private final byte[] mClassBytes;
  
      /**
       * Constructor ClassReply
       *
       *
       * @param classBytes
       *
       */
      public ClassReply(byte[] classBytes) {
          this.mClassBytes = classBytes;
      }
  
      /**
       * Method getClassBytes
       *
       *
       * @return
       *
       */
      public byte[] getClassBytes() {
          return mClassBytes;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassRequest.java
  
  Index: ClassRequest.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassRequest.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.common;
  
  
  /**
   * Class ClassRequest
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ClassRequest extends ArmiRequest {
  
      private final String mPublishedObjectName;
  
      /**
       * Constructor ClassRequest
       *
       *
       * @param publishedObjectName
       *
       */
      public ClassRequest(String publishedObjectName) {
          mPublishedObjectName = publishedObjectName;
      }
  
      /**
       * Method getPublishedObjectName
       *
       *
       * @return
       *
       */
      public String getPublishedObjectName() {
          return mPublishedObjectName;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/RequestFailedReply.java
  
  Index: RequestFailedReply.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/RequestFailedReply.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.common;
  
  
  
  /**
   * Class RequestFailedReply
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class RequestFailedReply extends ArmiReply {
  
      private final String mFailureReason;
  
      /**
       * Constructor RequestFailedReply
       *
       *
       * @param failureReason
       *
       */
      public RequestFailedReply(String failureReason) {
          this.mFailureReason = failureReason;
      }
  
      /**
       * Method getFailureReason
       *
       *
       * @return
       *
       */
      public String getFailureReason() {
          return mFailureReason;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java
  
  Index: PrimarySourceGenerator.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.generator;
  
  
  
  import org.apache.commons.armi.common.AbstractMethodHandler;
  import org.apache.commons.armi.test.TestInterface;
  
  import java.lang.reflect.Method;
  
  import java.util.Vector;
  
  import java.io.PrintWriter;
  import java.io.FileOutputStream;
  import java.io.FileNotFoundException;
  
  
  /**
   * Class PrimarySourceGenerator
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class PrimarySourceGenerator extends AbstractMethodHandler {
  
      private String[] mInterfacesToExpose;
      private String mGenDir;
      private String mGenName;
      private PrintWriter mClassSource;
  
      /**
       * Method setInterfacesToExpose
       *
       *
       * @param interfacesToExpose
       *
       */
      public void setInterfacesToExpose(String[] interfacesToExpose) {
          mInterfacesToExpose = interfacesToExpose;
      }
  
      /**
       * Method setGenDir
       *
       *
       * @param genDir
       *
       */
      public void setGenDir(String genDir) {
          mGenDir = genDir;
      }
  
      /**
       * Method setGenName
       *
       *
       * @param genName
       *
       */
      public void setGenName(String genName) {
          this.mGenName = genName;
      }
  
      /**
       * Method generate
       *
       *
       */
      public void generate() {
  
          // methdos could be in more than one interface.
          Vector methodsDone = new Vector();
  
          try {
              mClassSource = new PrintWriter(new FileOutputStream(mGenDir + "\\ArmiGenerated"
                                                                  + mGenName + ".java"));
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
  
          mClassSource
              .print("public final class ArmiGenerated" + mGenName
                     + " extends org.apache.commons.armi.client.impl.BaseServedObject implements ");
          generateInterfaceList();
          mClassSource.println(" { ");
          mClassSource.println("  public ArmiGenerated" + mGenName + "() {");
          mClassSource.print("    super(new Class[] {");
          generateInterfaceList2();
          mClassSource.println("});");
          mClassSource.println("  }");
  
          for (int x = 0; x < mInterfacesToExpose.length; x++) {
              Class clazz = null;
  
              try {
                  clazz = Class.forName(mInterfacesToExpose[x]);
              } catch (ClassNotFoundException e) {
                  e.printStackTrace();
              }
  
              Method[] methods = clazz.getMethods();
  
              for (int y = 0; y < methods.length; y++) {
                  Method method = methods[y];
                  String methodSignature = getMethodSignature(method);
  
                  if (!methodsDone.contains(methodSignature)) {
                      methodsDone.add(methodSignature);
  
                      String rClass = method.getReturnType().getName();
                      String mName = method.getName();
  
                      mClassSource.print("  public " + rClass + " " + mName + " (");
  
                      Class[] argTypes = method.getParameterTypes();
  
                      for (int i = 0; i < argTypes.length; i++) {
                          String cn = argTypes[i].getName();
  
                          generateParameter(cn, argTypes, i);
                      }
  
                      mClassSource.print(") ");
  
                      Class[] throwsTypes = method.getExceptionTypes();
  
                      for (int i = 0; i < throwsTypes.length; i++) {
                          generateThrows(i, throwsTypes);
                      }
  
                      mClassSource.println("{");
                      mClassSource.println("    Object[] args = new Object[" + argTypes.length
                                           + "];");
  
                      for (int i = 0; i < argTypes.length; i++) {
                          String cn = argTypes[i].getName();
  
                          generateAssignLine(cn, i);
                      }
  
                      mClassSource.println("    try {");
  
                      if (rClass.equals("void")) {
                          mClassSource.println("      armiProcessVoidRequest(\""
                                               + methodSignature.toString() + "\",args);");
                      } else {
                          mClassSource.println("      Object retVal = armiProcessObjectRequest(\""
                                               + methodSignature.toString() + "\",args);");
                          generateReturnLine(rClass);
                      }
  
                      mClassSource.println("    } catch (Throwable t) {");
  
                      throwsTypes = method.getExceptionTypes();
  
                      for (int i = 0; i < throwsTypes.length; i++) {
                          generateThrowHandler(i, throwsTypes);
                      }
  
                      mClassSource.println("      if (t instanceof RuntimeException) { ");
                      mClassSource.println("        throw (RuntimeException) t;");
                      mClassSource.println("      } else if (t instanceof Error) { ");
                      mClassSource.println("        throw (Error) t;");
                      mClassSource.println("      } else { ");
                      mClassSource.println(
                          "        throw new org.apache.commons.armi.common.ArmiInvocationException(\"Should never get here\" + t.getMessage()); ");
                      mClassSource.println("      }");
                      mClassSource.println("    }");
                      mClassSource.println("  }");
                  }
              }
          }
  
          mClassSource.print("}");
          mClassSource.close();
      }
  
      private void generateThrowHandler(int i, Class[] throwsTypes) {
  
          if (i == 0) {
              mClassSource.println("      if (t instanceof " + throwsTypes[i].getName() + ") { ");
          } else {
              mClassSource.println("      } else if (t instanceof " + throwsTypes[i].getName()
                                   + ") { ");
          }
  
          mClassSource.println("        throw (" + throwsTypes[i].getName() + ") t;");
  
          if (i + 1 == throwsTypes.length) {
              mClassSource.print("      } else");
          }
      }
  
      private void generateThrows(int i, Class[] throwsTypes) {
  
          if (i == 0) {
              mClassSource.print("throws ");
          }
  
          mClassSource.print(throwsTypes[i].getName());
  
          if (i + 1 < throwsTypes.length) {
              mClassSource.print(", ");
          }
      }
  
      private void generateInterfaceList2() {
  
          for (int x = 0; x < mInterfacesToExpose.length; x++) {
              mClassSource.print(mInterfacesToExpose[x] + ".class");
  
              if (x + 1 < mInterfacesToExpose.length) {
                  mClassSource.print(", ");
              }
          }
      }
  
      private void generateInterfaceList() {
  
          for (int x = 0; x < mInterfacesToExpose.length; x++) {
              mClassSource.print(mInterfacesToExpose[x]);
  
              if (x + 1 < mInterfacesToExpose.length) {
                  mClassSource.print(", ");
              }
          }
      }
  
      private void generateParameter(String cn, Class[] argTypes, int i) {
  
          if (cn.startsWith("L")) {
              mClassSource.print(argTypes[i].getName());
          } else if (cn.startsWith("[L")) {
              mClassSource.print(argTypes[i].getName() + "[]");
          } else if (cn.equals("[B")) {
              mClassSource.print("byte[]");
          } else if (cn.equals("[C")) {
              mClassSource.print("char[]");
          } else if (cn.equals("[D")) {
              mClassSource.print("double[]");
          } else if (cn.equals("[F")) {
              mClassSource.print("float[]");
          } else if (cn.equals("[I")) {
              mClassSource.print("int[]");
          } else if (cn.equals("[J")) {
              mClassSource.print("long[]");
          } else if (cn.equals("[S")) {
              mClassSource.print("short[]");
          } else if (cn.equals("[Z")) {
              mClassSource.print("boolean[]");
          } else {
              mClassSource.print(cn);
          }
  
          mClassSource.print(" v" + i);
  
          if (i + 1 < argTypes.length) {
              mClassSource.print(", ");
          }
      }
  
      private void generateAssignLine(String cn, int i) {
  
          if (cn.equals("int")) {
              mClassSource.println("    args[" + i + "] = new Integer(v" + i + ");");
          } else if (cn.equals("short")) {
              mClassSource.println("    args[" + i + "] = new Short(v" + i + ");");
          } else if (cn.equals("float")) {
              mClassSource.println("    args[" + i + "] = new Float(v" + i + ");");
          } else if (cn.equals("double")) {
              mClassSource.println("    args[" + i + "] = new Double(v" + i + ");");
          } else if (cn.equals("long")) {
              mClassSource.println("    args[" + i + "] = new Long(v" + i + ");");
          } else if (cn.equals("char")) {
              mClassSource.println("    args[" + i + "] = new Character(v" + i + ");");
          } else if (cn.equals("boolean")) {
              mClassSource.println("    args[" + i + "] = new Boolean(v" + i + ");");
          } else if (cn.equals("byte")) {
              mClassSource.println("    args[" + i + "] = new Byte(v" + i + ");");
          } else {
              mClassSource.println("    args[" + i + "] = v" + i + ";");
          }
      }
  
      private void generateReturnLine(String rClass) {
  
          if (rClass.equals("boolean")) {
              mClassSource.println("      return ((Boolean) retVal).booleanValue();");
          } else if (rClass.equals("integer")) {
              mClassSource.println("      return ((Integer) retVal).intValue();");
          } else if (rClass.equals("short")) {
              mClassSource.println("      return ((Short) retVal).shortValue();");
          } else if (rClass.equals("float")) {
              mClassSource.println("      return ((Float) retVal).floatValue();");
          } else if (rClass.equals("double")) {
              mClassSource.println("      return ((Double) retVal).doubleValue();");
          } else if (rClass.equals("long")) {
              mClassSource.println("      return ((Long) retVal).longValue();");
          } else if (rClass.equals("char")) {
              mClassSource.println("      return ((Character) retVal).charValue();");
          } else if (rClass.equals("byte")) {
              mClassSource.println("      return ((Byte) retVal).byteValue();");
          } else {
              mClassSource.println("      return (" + rClass + ") retVal;");
          }
      }
  
      /**
       * Method main
       *
       *
       * @param args
       *
       */
      public static void main(String[] args) {
  
          PrimarySourceGenerator gen = new PrimarySourceGenerator();
  
          gen.setGenName("Hello");
          gen.setGenDir("C:\\Apache-CVS\\jakarta-commons\\armi\\build\\genjava");
          gen.setInterfacesToExpose(new String[]{ TestInterface.class.getName() });
          gen.generate();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/SecondarySourceGenerator.java
  
  Index: SecondarySourceGenerator.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/SecondarySourceGenerator.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.generator;
  
  import org.apache.commons.armi.common.AbstractMethodHandler;
  
  import java.io.File;
  import java.io.PrintWriter;
  import java.io.IOException;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  
  
  /**
   * Class SecondarySourceGenerator
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class SecondarySourceGenerator extends AbstractMethodHandler {
  
      private File mFile;
      private String mGenDir;
      private String mGenName;
      private PrintWriter mClassSource;
  
      /**
       * Method setEncapsulated
       *
       *
       * @param file
       *
       */
      public void setEncapsulated(File file) {
          mFile = file;
      }
  
      /**
       * Method setGenDir
       *
       *
       * @param genDir
       *
       */
      public void setGenDir(String genDir) {
          mGenDir = genDir;
      }
  
      /**
       * Method setGenName
       *
       *
       * @param genName
       *
       */
      public void setGenName(String genName) {
          this.mGenName = genName;
      }
  
      /**
       * Method generate
       *
       *
       */
      public void generate() {
  
          byte[] clazzbytes = null;
  
          try {
              mClassSource = new PrintWriter(new FileOutputStream(mGenDir + "\\ArmiGenerated"
                                                                  + mGenName + ".java"));
  
              FileInputStream fis = new FileInputStream(mFile);
              int size = fis.available();
              System.out.println("Size=" + size);
              clazzbytes = new byte[size];
              fis.read(clazzbytes);
              fis.close();
  
          } catch (IOException ioe) {
              ioe.printStackTrace();
          }
  
          mClassSource
              .println("public final class ArmiGenerated" + mGenName
                     + " extends org.apache.commons.armi.server.impl.BaseMobileClass { ");
          mClassSource.println("  public byte[] getClassBytes() { ");
          mClassSource.println("    return new byte[] { ");
          mClassSource.print("      ");
          for (int x = 0; x < clazzbytes.length; x++) {
              mClassSource.print("(byte) "+byteToHexString(clazzbytes[x]));
              if (x+1 < clazzbytes.length) {
                  mClassSource.print(",");
              }
              if (x % 5 == 1) {
                  mClassSource.print("\n      ");
              }
          }
          mClassSource.println("");
          mClassSource.println("    };");
          mClassSource.println("  }");
          mClassSource.print("}");
          mClassSource.close();
      }
  
      public String byteToHexString(byte b) {
          int i = (int) b;
          String st = Integer.toHexString( i < 0 ? i + 256 : i ).toUpperCase();
          if(st.length() == 1) {
              return "0x0" + st;
          } else {
             return "0x" + st;
          }
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiClassInternTask.java
  
  Index: ArmiClassInternTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiClassInternTask.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.generator.ant;
  
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.BuildException;
  import org.apache.commons.armi.generator.SecondarySourceGenerator;
  
  import java.io.File;
  
  public class ArmiClassInternTask extends Task {
  
      private File mGeneratedClass;
      private String mGenDir;
      private String mGenName;
  
      public ArmiClassInternTask() {
      }
  
      public void setEncapsulated(File generatedClass) {
          mGeneratedClass = generatedClass;
      }
  
      public void setGendir(String genDir) {
          mGenDir = genDir;
      }
  
      public void setGenname(String genName) {
          this.mGenName = genName;
      }
  
  
      public void execute() throws BuildException {
          if (mGeneratedClass == null) {
              throw new BuildException("Specify at the class that we are interning");
          }
          if (mGenDir == null) {
              throw new BuildException("Specify the directory to generate Java source in");
          }
          if (mGenName == null) {
              throw new BuildException("Specify the name to use for lookup");
          }
          SecondarySourceGenerator sg = new SecondarySourceGenerator();
          sg.setGenDir(mGenDir);
          sg.setGenName(mGenName);
          sg.setEncapsulated(mGeneratedClass);
          sg.generate();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java
  
  Index: ArmiInterfaceTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.generator.ant;
  
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.util.FileUtils;
  import org.apache.commons.armi.generator.PrimarySourceGenerator;
  
  import java.util.StringTokenizer;
  import java.util.Vector;
  
  public class ArmiInterfaceTask extends Task {
  
      private String[] mInterfacesToExpose;
      private String mGenDir;
      private String mGenName;
  
      public ArmiInterfaceTask() {
      }
  
      public void setInterfaces(String interfacesToExpose) {
          StringTokenizer st = new StringTokenizer(interfacesToExpose, ",");
          Vector strings = new Vector();
          while (st.hasMoreTokens()) {
              strings.add(st.nextToken().trim());
          }
          mInterfacesToExpose = new String[strings.size()];
          strings.copyInto(mInterfacesToExpose);
  
  
      }
  
      public void setGendir(String genDir) {
          mGenDir = genDir;
      }
  
      public void setGenname(String genName) {
          this.mGenName = genName;
      }
  
  
      public void execute() throws BuildException {
          if (mInterfacesToExpose == null) {
              throw new BuildException("Specify at least one interface to expose");
          }
          if (mGenDir == null) {
              throw new BuildException("Specify the directory to generate Java source 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.setInterfacesToExpose(mInterfacesToExpose);
          sg.generate();
      }
  }
  
  
  
  1.2       +28 -7     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractServer.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ AbstractServer.java	30 Dec 2001 00:42:10 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v 1.2 2001/12/30 00:42:10 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/30 00:42:10 $
    *
    * ====================================================================
    *
  @@ -70,6 +70,11 @@
   import org.apache.commons.armi.common.AbstractMethodHandler;
   import org.apache.commons.armi.common.MethodRequest;
   import org.apache.commons.armi.common.ExceptionReply;
  +import org.apache.commons.armi.common.ClassRequest;
  +import org.apache.commons.armi.common.ArmiConnectionException;
  +import org.apache.commons.armi.common.ClassReply;
  +import org.apache.commons.armi.common.RequestFailedReply;
  +import org.apache.commons.armi.client.impl.BaseServedObject;
   
   import java.lang.reflect.Method;
   
  @@ -82,7 +87,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class AbstractServer extends AbstractMethodHandler implements ArmiServer {
   
  @@ -152,10 +157,26 @@
               MethodRequest mr = (MethodRequest) request;
               String as = mr.getPublishedObjectName();
               ArmiInvocationHandler ih = (ArmiInvocationHandler) publishedObjects.get(as);
  -
               return ih.handleInvocation(mr);
  +        } else if (request instanceof ClassRequest) {
  +            try {
  +                ClassRequest cr = (ClassRequest) request;
  +                String publishedServiceName = cr.getPublishedObjectName();
  +                Class clazz = Class.forName("ArmiGenerated" + publishedServiceName);
  +                BaseMobileClass bmc = (BaseMobileClass) clazz.newInstance();
  +                return new ClassReply(bmc.getClassBytes());
  +            } catch (ClassNotFoundException cnfe) {
  +                return new RequestFailedReply("Generated class not found during lookup : "
  +                                                  + cnfe.getMessage());
  +            } catch (InstantiationException ie) {
  +                return new RequestFailedReply("Generated class not instantiable during lookup : "
  +                                                  + ie.getMessage());
  +            } catch (IllegalAccessException iae) {
  +                return new RequestFailedReply("Illegal access to generated class during lookup : "
  +                                                  + iae.getMessage());
  +            }
  +        } else {
  +            return new RequestFailedReply("Unknown request :" + request.getClass().getName());
           }
  -
  -        return null;
       }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/BaseMobileClass.java
  
  Index: BaseMobileClass.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/BaseMobileClass.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2001/12/30 00:42:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "Commons", 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.armi.server.impl;
  
  public abstract class BaseMobileClass {
  
      public abstract byte[] getClassBytes();
  
  }
  
  
  
  1.2       +10 -5     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java
  
  Index: DirectTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DirectTest.java	28 Dec 2001 18:08:39 -0000	1.1
  +++ DirectTest.java	30 Dec 2001 00:42:10 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:39 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.2 2001/12/30 00:42:10 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/30 00:42:10 $
    *
    * ====================================================================
    *
  @@ -70,6 +70,7 @@
   import org.apache.commons.armi.client.ArmiHostContext;
   import org.apache.commons.armi.client.ArmiFactory;
   import org.apache.commons.armi.client.impl.direct.DirectArmiHostContext;
  +import org.apache.commons.armi.client.impl.ServerClassArmiFactory;
   
   
   /**
  @@ -77,7 +78,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class DirectTest {
   
  @@ -92,6 +93,10 @@
        */
       public static void main(String[] args) throws Exception {
   
  +        if (args[0].equals("S")) {
  +            ArmiFactory.setDefaultArmiFactory(new ServerClassArmiFactory());
  +        }
  +
           DirectServer ds = new DirectServer();
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
  @@ -108,7 +113,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.1 $
  +     * @version $Revision: 1.2 $
        */
       static class DirectTestClient implements Runnable {
   
  
  
  
  1.2       +10 -5     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java
  
  Index: PipeTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PipeTest.java	28 Dec 2001 18:08:39 -0000	1.1
  +++ PipeTest.java	30 Dec 2001 00:42:10 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:39 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.2 2001/12/30 00:42:10 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/30 00:42:10 $
    *
    * ====================================================================
    *
  @@ -69,6 +69,7 @@
   import org.apache.commons.armi.client.ArmiFactory;
   import org.apache.commons.armi.common.ArmiConnectionException;
   import org.apache.commons.armi.client.impl.piped.PipedArmiHostContext;
  +import org.apache.commons.armi.client.impl.ServerClassArmiFactory;
   
   import java.io.IOException;
   
  @@ -78,7 +79,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class PipeTest {
   
  @@ -93,6 +94,10 @@
        */
       public static void main(String[] args) throws Exception {
   
  +        if (args[0].equals("S")) {
  +            ArmiFactory.setDefaultArmiFactory(new ServerClassArmiFactory());
  +        }
  +
           PipedServer ps = new PipedServer();
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
  @@ -109,7 +114,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.1 $
  +     * @version $Revision: 1.2 $
        */
       static class PipedTestClient implements Runnable {
   
  
  
  
  1.2       +9 -4      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java
  
  Index: RmiClientTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RmiClientTest.java	28 Dec 2001 18:08:39 -0000	1.1
  +++ RmiClientTest.java	30 Dec 2001 00:42:10 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:39 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v 1.2 2001/12/30 00:42:10 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/30 00:42:10 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,7 @@
   import org.apache.commons.armi.client.ArmiHostContext;
   import org.apache.commons.armi.client.ArmiFactory;
   import org.apache.commons.armi.client.impl.rmi.RmiArmiHostContext;
  +import org.apache.commons.armi.client.impl.ServerClassArmiFactory;
   
   
   /**
  @@ -73,7 +74,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class RmiClientTest {
   
  @@ -87,6 +88,10 @@
        *
        */
       public static void main(String[] args) throws Exception {
  +
  +        if (args[0].equals("S")) {
  +            ArmiFactory.setDefaultArmiFactory(new ServerClassArmiFactory());
  +        }
   
           ArmiHostContext arhc = new RmiArmiHostContext("127.0.0.1", 4321);
           TestInterface ti = (TestInterface) ArmiFactory.getDefaultArmiFactory().lookup(arhc,
  
  
  
  1.2       +9 -4      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java
  
  Index: SocketClientTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SocketClientTest.java	28 Dec 2001 18:08:39 -0000	1.1
  +++ SocketClientTest.java	30 Dec 2001 00:42:10 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:39 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v 1.2 2001/12/30 00:42:10 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/12/30 00:42:10 $
    *
    * ====================================================================
    *
  @@ -67,6 +67,7 @@
   import org.apache.commons.armi.client.ArmiFactory;
   import org.apache.commons.armi.common.ArmiConnectionException;
   import org.apache.commons.armi.client.impl.socket.PlainSocketArmiHostContext;
  +import org.apache.commons.armi.client.impl.ServerClassArmiFactory;
   
   import java.io.IOException;
   
  @@ -76,7 +77,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class SocketClientTest {
   
  @@ -90,6 +91,10 @@
        *
        */
       public static void main(String[] args) throws Exception {
  +
  +        if (args[0].equals("S")) {
  +            ArmiFactory.setDefaultArmiFactory(new ServerClassArmiFactory());
  +        }
   
           ArmiHostContext arhc = new PlainSocketArmiHostContext("127.0.0.1", 1234);
           TestInterface ti = (TestInterface) ArmiFactory.getDefaultArmiFactory().lookup(arhc,
  
  
  

--
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