hammant     02/01/04 01:35:31

  Modified:    armi     PROPOSAL
               armi/src/java/org/apache/commons/armi/client/impl
                        ObjectStreamInvocationHandler.java
               armi/src/java/org/apache/commons/armi/client/impl/direct
                        DirectInvocationHandler.java
               armi/src/java/org/apache/commons/armi/generator
                        PrimarySourceGenerator.java
               armi/src/java/org/apache/commons/armi/generator/ant
                        ArmiInterfaceTask.java
               armi/src/java/org/apache/commons/armi/server ArmiServer.java
               armi/src/java/org/apache/commons/armi/server/impl
                        AbstractServer.java
  Added:       armi/src/java/org/apache/commons/armi/server
                        ArmiClassRetrievalException.java
                        ClassRetriever.java
               armi/src/java/org/apache/commons/armi/server/impl
                        BaseMobileClassRetriever.java
                        JarFileClassRetriever.java
  Log:
  ARMI cat get proxys from jar files now.
  
  Revision  Changes    Path
  1.10      +12 -5     jakarta-commons-sandbox/armi/PROPOSAL
  
  Index: PROPOSAL
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/PROPOSAL,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PROPOSAL  3 Jan 2002 10:53:48 -0000       1.9
  +++ PROPOSAL  4 Jan 2002 09:35:30 -0000       1.10
  @@ -45,8 +45,15 @@
     - Classes providing client side implementation of the transported 
       interface(s) can be either on the client side or the server side (and 
       duly transported) at time of lookup.
  +    
  +6) Choice of castability of generated proxy class.
   
  -6) Suspendable/Resumable service.
  +  - To suit remote facilities that are happy with refection and do 
  +    not need to cast to an interface to use a bean (I am thinking of 
  +    beanshell) the proxy class can be generated without specifying
  +    that it implements the interface(s).
  +
  +7) Suspendable/Resumable service.
   
     - The Server supports suspend() and resume().  With the current impl this 
       replies in a timely fashion to the client that the client should try
  @@ -54,24 +61,24 @@
       trys the requets again.  A server could cycle through suspended and back
       to resumed will not affect the client except for the a delay.
   
  -7) Recovering transport
  +8) Recovering transport
   
     - ARMI tries to recover its transports should they fail.
     
  -8) Event API
  +9) Event API
   
     - For suspensions, abnormal ends of connection etc, there is a listener 
       that can be set that will allow actions to be taken.  Abnormally 
       terminated connections will by default try to be reconnected, the 
       listener can decide if, how many, and how often the retries occur.
   
  -9) Unpublishable and republishable API
  +10) Unpublishable and republishable API
     
     - The server is able to unpublish a service.  In conjuction with 
       suspend()/resume() a service can be republished, upgraded etc
       whilst in use, or just offlined.
   
  -10) Startable API for Server
  +11) Startable API for Server
   
     - The server implements and acts upon start() and stop() methods.
   
  
  
  
  1.7       +4 -5      
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java
  
  Index: ObjectStreamInvocationHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ObjectStreamInvocationHandler.java        3 Jan 2002 10:49:37 -0000       1.6
  +++ ObjectStreamInvocationHandler.java        4 Jan 2002 09:35:31 -0000       1.7
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v
 1.6 2002/01/03 10:49:37 hammant Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/01/03 10:49:37 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v
 1.7 2002/01/04 09:35:31 hammant Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/01/04 09:35:31 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,6 @@
   import org.apache.commons.armi.common.NotPublishedReply;
   import org.apache.commons.armi.common.NotPublishedException;
   import org.apache.commons.armi.common.PublishedNameRequest;
  -import org.apache.commons.armi.common.ProblemReply;
   import org.apache.commons.armi.client.ArmiConnectionListener;
   
   import java.io.IOException;
  @@ -86,7 +85,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public abstract class ObjectStreamInvocationHandler extends 
ArmiClientInvocationHandler {
   
  
  
  
  1.7       +4 -5      
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java
  
  Index: DirectInvocationHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DirectInvocationHandler.java      3 Jan 2002 10:49:37 -0000       1.6
  +++ DirectInvocationHandler.java      4 Jan 2002 09:35:31 -0000       1.7
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v
 1.6 2002/01/03 10:49:37 hammant Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/01/03 10:49:37 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v
 1.7 2002/01/04 09:35:31 hammant Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/01/04 09:35:31 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,6 @@
   import org.apache.commons.armi.common.NotPublishedException;
   import org.apache.commons.armi.common.PublishedNameRequest;
   import org.apache.commons.armi.common.ArmiInvocationException;
  -import org.apache.commons.armi.common.ProblemReply;
   import org.apache.commons.armi.common.MethodRequest;
   import org.apache.commons.armi.client.impl.ArmiClientInvocationHandler;
   import org.apache.commons.armi.client.ArmiConnectionListener;
  @@ -83,7 +82,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public final class DirectInvocationHandler extends ArmiClientInvocationHandler {
   
  
  
  
  1.2       +10 -22    
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java
  
  Index: PrimarySourceGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PrimarySourceGenerator.java       30 Dec 2001 00:42:10 -0000      1.1
  +++ PrimarySourceGenerator.java       4 Jan 2002 09:35:31 -0000       1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $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 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java,v
 1.2 2002/01/04 09:35:31 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/04 09:35:31 $
    *
    * ====================================================================
    *
  @@ -80,7 +80,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class PrimarySourceGenerator extends AbstractMethodHandler {
   
  @@ -125,9 +125,11 @@
       /**
        * Method generate
        *
  +     * @param withImplInterfaces to indicate whether the resulting
  +     * bean should be castable to the prescribed interfaces or not.
        *
        */
  -    public void generate() {
  +    public void generate(boolean beanOnly) {
   
           // methdos could be in more than one interface.
           Vector methodsDone = new Vector();
  @@ -141,8 +143,11 @@
   
           mClassSource
               .print("public final class ArmiGenerated" + mGenName
  -                   + " extends org.apache.commons.armi.client.impl.BaseServedObject 
implements ");
  -        generateInterfaceList();
  +                   + " extends org.apache.commons.armi.client.impl.BaseServedObject 
");
  +        if (!beanOnly) {
  +            mClassSource.print("implements ");
  +            generateInterfaceList();
  +        }
           mClassSource.println(" { ");
           mClassSource.println("  public ArmiGenerated" + mGenName + "() {");
           mClassSource.print("    super(new Class[] {");
  @@ -364,22 +369,5 @@
           } 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.2       +8 -3      
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java
  
  Index: ArmiInterfaceTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArmiInterfaceTask.java    30 Dec 2001 00:42:10 -0000      1.1
  +++ ArmiInterfaceTask.java    4 Jan 2002 09:35:31 -0000       1.2
  @@ -1,7 +1,7 @@
   /*
  - * $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 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java,v
 1.2 2002/01/04 09:35:31 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/04 09:35:31 $
    *
    * ====================================================================
    *
  @@ -73,6 +73,7 @@
       private String[] mInterfacesToExpose;
       private String mGenDir;
       private String mGenName;
  +    private boolean mBeanOnly;
   
       public ArmiInterfaceTask() {
       }
  @@ -93,6 +94,10 @@
           mGenDir = genDir;
       }
   
  +    public void setBeanonly(String yesNo) {
  +        mBeanOnly = yesNo.equals("yes");
  +    }
  +
       public void setGenname(String genName) {
           this.mGenName = genName;
       }
  @@ -112,6 +117,6 @@
           sg.setGenDir(mGenDir);
           sg.setGenName(mGenName);
           sg.setInterfacesToExpose(mInterfacesToExpose);
  -        sg.generate();
  +        sg.generate(mBeanOnly);
       }
   }
  
  
  
  1.5       +15 -4     
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java
  
  Index: ArmiServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ArmiServer.java   3 Jan 2002 10:49:37 -0000       1.4
  +++ ArmiServer.java   4 Jan 2002 09:35:31 -0000       1.5
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v
 1.4 2002/01/03 10:49:37 hammant Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/01/03 10:49:37 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v
 1.5 2002/01/04 09:35:31 hammant Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/01/04 09:35:31 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version * $Revision: 1.4 $
  + * @version * $Revision: 1.5 $
    */
   public interface ArmiServer {
   
  @@ -119,6 +119,17 @@
        */
       void replacePublished(Object oldImpl, String asName, Object withImpl) throws 
ArmiPublicationException;
   
  +
  +    /**
  +     * Method setClassRetriever
  +     *
  +     *
  +     * @param classRetriever
  +     *
  +     * @return
  +     *
  +     */
  +    void setClassRetriever(ClassRetriever classRetriever);
   
       /**
        * Method processRequest
  
  
  
  1.1                  
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiClassRetrievalException.java
  
  Index: ArmiClassRetrievalException.java
  ===================================================================
  
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiClassRetrievalException.java,v
 1.1 2002/01/04 09:35:31 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/04 09:35:31 $
   *
   * ====================================================================
   *
   * 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 [EMAIL PROTECTED]
   *
   * 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;
  
  
  
  import java.io.Serializable;
  
  
  /**
   * Class ArmiClassRetrievalException
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class ArmiClassRetrievalException extends Exception {
  
  
      /**
       * Constructor ArmiClassRetrievalException
       *
       *
       * @param s
       *
       */
      public ArmiClassRetrievalException(String reason) {
          super(reason);
      }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ClassRetriever.java
  
  Index: ClassRetriever.java
  ===================================================================
  
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ClassRetriever.java,v
 1.1 2002/01/04 09:35:31 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/04 09:35:31 $
   *
   * ====================================================================
   *
   * 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 [EMAIL PROTECTED]
   *
   * 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;
  
  
  public interface ClassRetriever {
  
      byte[] getBytes(String publishedName) throws ArmiClassRetrievalException;
  
  }
  
  
  
  1.8       +24 -17    
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractServer.java       3 Jan 2002 10:49:38 -0000       1.7
  +++ AbstractServer.java       4 Jan 2002 09:35:31 -0000       1.8
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v
 1.7 2002/01/03 10:49:38 hammant Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/01/03 10:49:38 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v
 1.8 2002/01/04 09:35:31 hammant Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/01/04 09:35:31 $
    *
    * ====================================================================
    *
  @@ -79,6 +79,8 @@
   import org.apache.commons.armi.common.TryLaterReply;
   import org.apache.commons.armi.common.NotPublishedReply;
   import org.apache.commons.armi.common.SuspendedReply;
  +import org.apache.commons.armi.server.ArmiClassRetrievalException;
  +import org.apache.commons.armi.server.ClassRetriever;
   
   import java.lang.reflect.Method;
   
  @@ -92,13 +94,14 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements 
ArmiServer {
   
       private HashMap mPublishedObjects = new HashMap();
       private boolean mSuspend = false;
       private Vector mConnections = new Vector();
  +    private ClassRetriever mClassRetriever = new BaseMobileClassRetriever();
   
       protected static final int SHUTTINGDOWN = 11;
       protected static final int STARTED = 22;
  @@ -203,6 +206,20 @@
       }
   
       /**
  +     * Method setClassRetriever
  +     *
  +     *
  +     * @param classRetriever
  +     *
  +     * @return
  +     *
  +     */
  +    public void setClassRetriever(ClassRetriever classRetriever) {
  +        mClassRetriever = classRetriever;
  +    }
  +
  +
  +    /**
        * Method processRequest
        *
        *
  @@ -228,19 +245,9 @@
           } 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());
  +                return new 
ClassReply(mClassRetriever.getBytes(cr.getPublishedObjectName()));
  +            } catch (ArmiClassRetrievalException e) {
  +                return new RequestFailedReply(e.getMessage());
               }
           } else {
               return new RequestFailedReply("Unknown request :" + 
request.getClass().getName());
  
  
  
  1.1                  
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/BaseMobileClassRetriever.java
  
  Index: BaseMobileClassRetriever.java
  ===================================================================
  
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/BaseMobileClassRetriever.java,v
 1.1 2002/01/04 09:35:31 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/04 09:35:31 $
   *
   * ====================================================================
   *
   * 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 [EMAIL PROTECTED]
   *
   * 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;
  
  
  
  import org.apache.commons.armi.server.ArmiClassRetrievalException;
  import org.apache.commons.armi.server.ClassRetriever;
  
  
  /**
   * Class BaseMobileClassRetriever
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class BaseMobileClassRetriever implements ClassRetriever {
  
      /**
       * Method getBytes
       *
       *
       * @param publishedName
       *
       * @return
       *
       * @throws ArmiClassRetrievalException
       *
       */
      public byte[] getBytes(String publishedName) throws ArmiClassRetrievalException {
  
          try {
              Class clazz = Class.forName("ArmiGenerated" + publishedName);
              BaseMobileClass bmc = (BaseMobileClass) clazz.newInstance();
  
              return bmc.getClassBytes();
          } catch (ClassNotFoundException cnfe) {
              throw new ArmiClassRetrievalException("Generated class not found during 
lookup : "
                                               + cnfe.getMessage());
          } catch (InstantiationException ie) {
              throw new ArmiClassRetrievalException("Generated class not instantiable 
during lookup : "
                                               + ie.getMessage());
          } catch (IllegalAccessException iae) {
              throw new ArmiClassRetrievalException("Illegal access to generated class 
during lookup : "
                                               + iae.getMessage());
          }
      }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/JarFileClassRetriever.java
  
  Index: JarFileClassRetriever.java
  ===================================================================
  
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/JarFileClassRetriever.java,v
 1.1 2002/01/04 09:35:31 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/04 09:35:31 $
   *
   * ====================================================================
   *
   * 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 [EMAIL PROTECTED]
   *
   * 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;
  
  
  
  import org.apache.commons.armi.server.ArmiClassRetrievalException;
  import org.apache.commons.armi.server.ClassRetriever;
  
  import java.net.URLClassLoader;
  import java.net.URL;
  import java.net.MalformedURLException;
  
  import java.io.File;
  import java.io.InputStream;
  import java.io.ByteArrayInputStream;
  
  
  /**
   * Class JarFileClassRetriever
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class JarFileClassRetriever implements ClassRetriever {
  
      private URLClassLoader mURLClassLoader;
  
      /**
       * Constructor JarFileClassRetriever
       *
       *
       * @param urlOfJarFile
       *
       */
      public JarFileClassRetriever(URL urlOfJarFile) {
          mURLClassLoader = new URLClassLoader(new URL[]{ urlOfJarFile });
      }
  
      /**
       * Constructor JarFileClassRetriever
       *
       *
       * @param urlsOfJarFiles
       *
       */
      public JarFileClassRetriever(URL[] urlsOfJarFiles) {
          mURLClassLoader = new URLClassLoader(urlsOfJarFiles);
      }
  
      /**
       * Constructor JarFileClassRetriever
       *
       *
       * @param pathsOfJarFiles
       *
       * @throws MalformedURLException
       *
       */
      public JarFileClassRetriever(String[] pathsOfJarFiles) throws 
MalformedURLException {
  
          URL[] urls = new URL[pathsOfJarFiles.length];
  
          for (int i = 0; i < pathsOfJarFiles.length; i++) {
              urls[i] = new File(pathsOfJarFiles[i]).toURL();
          }
  
          mURLClassLoader = new URLClassLoader(urls);
      }
  
      /**
       * Constructor JarFileClassRetriever
       *
       *
       * @param pathOfJarFile
       *
       * @throws MalformedURLException
       *
       */
      public JarFileClassRetriever(String pathOfJarFile) throws MalformedURLException {
          mURLClassLoader = new URLClassLoader(new URL[]{ new 
File(pathOfJarFile).toURL() });
      }
  
      /**
       * Method getBytes
       *
       *
       * @param publishedName
       *
       * @return
       *
       * @throws ArmiClassRetrievalException
       *
       */
      public byte[] getBytes(String publishedName) throws ArmiClassRetrievalException {
  
          try {
              URL rsc = mURLClassLoader.findResource(publishedName);
              InputStream is = rsc.openStream();
              byte[] bytes = new byte[is.available()];
  
              is.read(bytes);
  
              return bytes;
          } catch (java.io.IOException e) {
              throw new ArmiClassRetrievalException("Generated class not found in Jar 
on server");
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to