You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by du...@apache.org on 2001/02/20 23:51:30 UTC

cvs commit: xml-axis/java/src/org/apache/axis/utils AxisClassLoader.java Admin.java

dug         01/02/20 14:51:30

  Modified:    java/src/org/apache/axis/handlers JWSProcessor.java
                        MsgDispatchHandler.java RPCDispatchHandler.java
               java/src/org/apache/axis/registries SupplierRegistry.java
               java/src/org/apache/axis/server SimpleAxisEngine.java
               java/src/org/apache/axis/utils Admin.java
  Added:       java/src/org/apache/axis/utils AxisClassLoader.java
  Log:
  Needed to add AxisClassLoader so that when the *.jws file is updated
  we'll load the new class - default ClassLoader didn't do this.
  Also - fixed a bug in the Admin - it was using a local copy of
  the registries so changes we not seen by the AxisEngine unti the
  servlet was restarted.
  
  Revision  Changes    Path
  1.2       +5 -4      xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
  
  Index: JWSProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JWSProcessor.java	2001/02/20 14:24:53	1.1
  +++ JWSProcessor.java	2001/02/20 22:51:29	1.2
  @@ -56,8 +56,9 @@
   
   import java.io.* ;
   
  -import org.apache.axis.*;
  -import org.apache.axis.utils.Debug;
  +import org.apache.axis.* ;
  +import org.apache.axis.utils.Debug ;
  +import org.apache.axis.utils.AxisClassLoader ;
   
   /** 
    * This handler will use the JWSFileName property of the MsgContext to
  @@ -132,11 +133,11 @@
   
         /* Load the class */
         /******************/
  -      ClassLoader cl = ClassLoader.getSystemClassLoader();
         String clsName = f2.getName();
         clsName = clsName.substring( 0, clsName.length()-4 );
         Debug.Print( 2, "ClsName: " + clsName );
  -      Class c = cl.loadClass( clsName );
  +
  +      (new AxisClassLoader()).registerClass( clsName, cFile );
   
         /* Create a new RPCDispatchHandler - this will be the "service"   */
         /* that we invoke.                                                */
  
  
  
  1.5       +7 -6      xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java
  
  Index: MsgDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MsgDispatchHandler.java	2001/02/12 01:11:14	1.4
  +++ MsgDispatchHandler.java	2001/02/20 22:51:29	1.5
  @@ -91,17 +91,18 @@
       Debug.Print( 2, "MethodName: " + methodName );
   
       try {
  -      Class        cls    = Class.forName(clsName);
  -      Object       obj    = cls.newInstance();
  -      Class[]      argClasses = new Class[2];
  -      Object[]     argObjects = new Object[2];
  +      AxisClassLoader cl     = new AxisClassLoader();
  +      Class           cls    = cl.loadClass(clsName);
  +      Object          obj    = cls.newInstance();
  +      Class[]         argClasses = new Class[2];
  +      Object[]        argObjects = new Object[2];
   
         Message       reqMsg  = msgContext.getIncomingMessage();
         SOAPEnvelope  reqEnv  = (SOAPEnvelope) reqMsg.getAs("SOAPEnvelope");
         SOAPBody      reqBody = reqEnv.getFirstBody();
     
  -      argClasses[0] = Class.forName("org.apache.axis.MessageContext");
  -      argClasses[1] = Class.forName("org.w3c.dom.Document");
  +      argClasses[0] = cl.loadClass("org.apache.axis.MessageContext");
  +      argClasses[1] = cl.loadClass("org.w3c.dom.Document");
         argObjects[0] = (Object) msgContext ;
         argObjects[1] = (Object) reqBody.getAsDocument();
   
  
  
  
  1.13      +8 -7      xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java
  
  Index: RPCDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RPCDispatchHandler.java	2001/02/20 14:24:53	1.12
  +++ RPCDispatchHandler.java	2001/02/20 22:51:29	1.13
  @@ -85,12 +85,13 @@
         /* SOAPBody as an RPCBody and process it accordingly.        */
         /*************************************************************/
         int          i ;
  -      Class        cls    = Class.forName(clsName);
  -      Object       obj    = cls.newInstance();
  -      Message      inMsg  = msgContext.getIncomingMessage();
  -      SOAPEnvelope env    = (SOAPEnvelope) inMsg.getAs("SOAPEnvelope");
  -      Vector       bodies = env.getAsRPCBody();
  -      SOAPEnvelope resEnv = null ;
  +      AxisClassLoader cl     = new AxisClassLoader();
  +      Class           cls    = cl.loadClass(clsName); 
  +      Object          obj    = cls.newInstance();
  +      Message         inMsg  = msgContext.getIncomingMessage();
  +      SOAPEnvelope    env    = (SOAPEnvelope) inMsg.getAs("SOAPEnvelope");
  +      Vector          bodies = env.getAsRPCBody();
  +      SOAPEnvelope    resEnv = null ;
   
         /* Loop over each entry in the SOAPBody - each one is a different */
         /* RPC call.                                                      */
  @@ -110,7 +111,7 @@
           Class[]  argClasses = new Class[ args.size() ];
           Object[] argValues  = new Object[ args.size()];
           for ( i = 0 ; i < args.size() ; i++ ) {
  -          argClasses[i] = Class.forName("java.lang.String") ;
  +          argClasses[i] = cl.loadClass("java.lang.String") ;
             argValues[i]  = ((RPCArg)args.get(i)).getValue() ; // only String 4now
           }
     
  
  
  
  1.3       +1 -1      xml-axis/java/src/org/apache/axis/registries/SupplierRegistry.java
  
  Index: SupplierRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/SupplierRegistry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SupplierRegistry.java	2001/02/15 13:30:01	1.2
  +++ SupplierRegistry.java	2001/02/20 22:51:29	1.3
  @@ -116,7 +116,7 @@
        * Given a 'key' return the corresponding Handler
        */
       public Handler find(String key) {
  -        Debug.Print( 2, "Enter: SupplierRegistry::find" );
  +        Debug.Print( 2, "Enter: SupplierRegistry::find(" + key + ")" );
           if ( suppliers == null ) {
             Debug.Print( 2, "Exit: SupplierRegistry::find - suppliers is null" );
             return( null );
  
  
  
  1.20      +1 -0      xml-axis/java/src/org/apache/axis/server/SimpleAxisEngine.java
  
  Index: SimpleAxisEngine.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/SimpleAxisEngine.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SimpleAxisEngine.java	2001/02/17 18:02:17	1.19
  +++ SimpleAxisEngine.java	2001/02/20 22:51:30	1.20
  @@ -115,6 +115,7 @@
   
           /** Make sure later Handlers can get this directly.
           */
  +        msgContext.setProperty(Constants.HANDLER_REGISTRY, hr);
           msgContext.setProperty(Constants.SERVICE_REGISTRY, sr);
   
           /** We must have a Target Service to continue.  This tells us which 
  
  
  
  1.13      +8 -5      xml-axis/java/src/org/apache/axis/utils/Admin.java
  
  Index: Admin.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Admin.java	2001/02/14 21:35:28	1.12
  +++ Admin.java	2001/02/20 22:51:30	1.13
  @@ -104,6 +104,8 @@
   
     public Document AdminService(MessageContext msgContext, Document xml) {
       Debug.Print( 1, "Enter: Admin:AdminService" );
  +    hr = (HandlerRegistry)msgContext.getProperty(Constants.HANDLER_REGISTRY);
  +    sr = (HandlerRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
       process( xml );
       Document doc = new DocumentImpl();
       Element  root = doc.createElement( "Admin" );
  @@ -120,7 +122,8 @@
     public void process(Element root) {
       try {
         init();
  -      String  action = root.getTagName();
  +      ClassLoader   cl     = new AxisClassLoader();
  +      String        action = root.getTagName();
   
         if ( !action.equals("deploy") && !action.equals("undeploy") ) 
           Error( "Root element must be 'deploy' or 'undeploy'" );
  @@ -159,18 +162,18 @@
               Supplier supplier;
   
               if ("factory".equals(lifeCycle)) {
  -              supplier = new FactorySupplier(Class.forName(cls), new Hashtable());
  +              supplier = new FactorySupplier(cl.loadClass(cls), new Hashtable());
               } else if ("static".equals(lifeCycle)) {
  -              supplier = new SimpleSupplier((Handler)Class.forName(cls).newInstance());
  +              supplier = new SimpleSupplier((Handler)cl.loadClass(cls).newInstance());
               } else {
                 // Default to static for now
  -              supplier = new SimpleSupplier((Handler)Class.forName(cls).newInstance());
  +              supplier = new SimpleSupplier((Handler)cl.loadClass(cls).newInstance());
               }
               
               ((SupplierRegistry)hr).add(name, supplier);
             } else {
               h = hr.find( name );
  -            if ( h == null ) h = (Handler) Class.forName(cls).newInstance();
  +            if ( h == null ) h = (Handler) cl.loadClass(cls).newInstance();
               getOptions( elem, h );
               hr.add( name, h );
             }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/utils/AxisClassLoader.java
  
  Index: AxisClassLoader.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" 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 name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * 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.axis.utils ;
  
  import java.io.* ;
  import java.util.Hashtable ;
  
  public class AxisClassLoader extends ClassLoader {
    static Hashtable list = null ;
  
    public AxisClassLoader() {
      super();
    }
  
    public synchronized void registerClass( String name, String classFile )
        throws FileNotFoundException, IOException
    {
      if ( list == null ) list = new Hashtable();
  
      FileInputStream       fis  = new FileInputStream( classFile );
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      byte buf[] = new byte[1024];
      for(int i = 0; (i = fis.read(buf)) != -1; )
        baos.write(buf, 0, i);
      fis.close();
      baos.close();
  
      byte[] data = baos.toByteArray();
      Class  cls  = defineClass( name, data, 0, data.length );
      list.put( name, cls );
    }
  
    public synchronized void deregisterClass( String name ) {
      if ( list != null )
        list.remove( name);
    }
  
    public Class loadClass(String name) throws ClassNotFoundException {
      Object obj ;
  
      if ( list != null ) {
        obj = list.get( name );
        if ( obj != null )
          return( (Class) obj );
      }
  
      return( findSystemClass(name) );
    }
  };