axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http AdminServlet.java AxisServlet.java
Date Thu, 07 Feb 2002 13:46:36 GMT
glyn        02/02/07 05:46:36

  Modified:    java/samples/transport/tcp GetQuote.java
               java/src/org/apache/axis Constants.java
                        EngineConfigurationFactory.java
               java/src/org/apache/axis/client Service.java
                        ServiceFactory.java
               java/src/org/apache/axis/configuration
                        DefaultEngineConfigurationFactory.java
               java/src/org/apache/axis/transport/http AdminServlet.java
                        AxisServlet.java
  Log:
  Make DefaultEngineConfigurationFactory the standard way to obtain
  engine configurations. This is overrideable and configurable via
  Java system properties. Further flexibility in how configurations
  are built may be required in the future, but it should now be
  possible to implemented them using localised changes.
  
  Constants.CLIENT_CONFIG_FILE and Constants.SERVER_CONFIG_FILE are
  replaced by *private* constants in DefaultEngineConfigurationFactory
  since no other Axis code should need to know these values.
  
  Revision  Changes    Path
  1.18      +8 -7      xml-axis/java/samples/transport/tcp/GetQuote.java
  
  Index: GetQuote.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/GetQuote.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- GetQuote.java	28 Jan 2002 18:22:59 -0000	1.17
  +++ GetQuote.java	7 Feb 2002 13:46:35 -0000	1.18
  @@ -56,10 +56,10 @@
   package samples.transport.tcp ;
   
   import org.apache.axis.AxisFault;
  +import org.apache.axis.EngineConfiguration;
   import org.apache.axis.SimpleTargetedChain;
  -import org.apache.axis.Constants;
   import org.apache.axis.configuration.SimpleProvider;
  -import org.apache.axis.configuration.FileProvider;
  +import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
   import org.apache.axis.client.Call;
   import org.apache.axis.client.Service;
   import org.apache.axis.client.Transport;
  @@ -96,13 +96,14 @@
           String namespace = "urn:xmltoday-delayed-quotes";
           symbol = args[0] ;
   
  -        SimpleProvider provider =
  -                new SimpleProvider(
  -                        new FileProvider(Constants.CLIENT_CONFIG_FILE));
  +        EngineConfiguration defaultConfig =
  +            (new DefaultEngineConfigurationFactory()).
  +            getClientEngineConfig();
  +        SimpleProvider config = new SimpleProvider(defaultConfig);
           SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
  -        provider.deployTransport("tcp", c);
  +        config.deployTransport("tcp", c);
   
  -        Service service = new Service(provider);
  +        Service service = new Service(config);
           Call call = (Call)service.createCall();
           
           call.setTransport(new TCPTransport());
  
  
  
  1.52      +0 -3      xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Constants.java	4 Feb 2002 23:34:09 -0000	1.51
  +++ Constants.java	7 Feb 2002 13:46:36 -0000	1.52
  @@ -420,7 +420,4 @@
       public static final String MC_CONFIGPATH = "configPath";
       // MessageContext param for the IP of the calling client
       public static final String MC_REMOTE_ADDR = "remoteaddr";
  -
  -    public static final String SERVER_CONFIG_FILE = "server-config.wsdd";
  -    public static final String CLIENT_CONFIG_FILE = "client-config.wsdd";
   }
  
  
  
  1.3       +9 -0      xml-axis/java/src/org/apache/axis/EngineConfigurationFactory.java
  
  Index: EngineConfigurationFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/EngineConfigurationFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EngineConfigurationFactory.java	6 Feb 2002 15:27:43 -0000	1.2
  +++ EngineConfigurationFactory.java	7 Feb 2002 13:46:36 -0000	1.3
  @@ -56,6 +56,7 @@
   package org.apache.axis;
   
   import javax.xml.rpc.namespace.QName;
  +import javax.servlet.ServletContext;
   
   /**
    * EngineConfigurationFactory is an interface used to construct
  @@ -83,4 +84,12 @@
        * @return a server EngineConfiguration
        */
       public EngineConfiguration getServerEngineConfig();
  +
  +    /**
  +     * Get a default server engine configuration in a servlet environment.
  +     *
  +     * @param ctx a ServletContext
  +     * @return a server EngineConfiguration
  +     */
  +    public EngineConfiguration getServerEngineConfig(ServletContext ctx);
   }
  
  
  
  1.40      +2 -3      xml-axis/java/src/org/apache/axis/client/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- Service.java	5 Feb 2002 16:22:39 -0000	1.39
  +++ Service.java	7 Feb 2002 13:46:36 -0000	1.40
  @@ -57,9 +57,8 @@
   
   import javax.wsdl.extensions.soap.SOAPAddress;
   import org.apache.axis.AxisEngine;
  -import org.apache.axis.Constants;
   import org.apache.axis.EngineConfiguration;
  -import org.apache.axis.configuration.FileProvider;
  +import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.XMLUtils;
   import org.apache.axis.utils.AxisClassLoader;
  @@ -110,7 +109,7 @@
       private boolean             maintainSession = false ;
   
       private EngineConfiguration config =
  -            new FileProvider(Constants.CLIENT_CONFIG_FILE);
  +        (new DefaultEngineConfigurationFactory()).getClientEngineConfig();
   
       Definition getWSDLDefinition() {
           return( wsdlDefinition );
  
  
  
  1.5       +58 -4     xml-axis/java/src/org/apache/axis/client/ServiceFactory.java
  
  Index: ServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/ServiceFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServiceFactory.java	5 Feb 2002 19:37:48 -0000	1.4
  +++ ServiceFactory.java	7 Feb 2002 13:46:36 -0000	1.5
  @@ -1,9 +1,63 @@
  +/*
  +* The Apache Software License, Version 1.1
  +*
  +*
  +* Copyright (c) 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 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.client;
   
   import org.apache.axis.EngineConfiguration;
   import org.apache.axis.AxisFault;
  -import org.apache.axis.Constants;
  -import org.apache.axis.configuration.FileProvider;
  +import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
   
   import javax.naming.InitialContext;
   import javax.naming.NamingException;
  @@ -18,8 +72,8 @@
    */ 
   
   public class ServiceFactory {
  -    private static FileProvider defaultEngineConfig =
  -                           new FileProvider(Constants.CLIENT_CONFIG_FILE);
  +    private static EngineConfiguration defaultEngineConfig =
  +        (new DefaultEngineConfigurationFactory()).getClientEngineConfig();
       private static ThreadLocal threadDefaultConfig = new ThreadLocal();
   
       public static void setThreadDefaultConfig(EngineConfiguration config)
  
  
  
  1.3       +41 -2     xml-axis/java/src/org/apache/axis/configuration/DefaultEngineConfigurationFactory.java
  
  Index: DefaultEngineConfigurationFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/configuration/DefaultEngineConfigurationFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultEngineConfigurationFactory.java	6 Feb 2002 15:27:43 -0000	1.2
  +++ DefaultEngineConfigurationFactory.java	7 Feb 2002 13:46:36 -0000	1.3
  @@ -59,6 +59,11 @@
   import org.apache.axis.EngineConfiguration;
   import org.apache.axis.Constants;
   
  +import javax.servlet.ServletContext;
  +
  +import java.io.File;
  +import java.io.InputStream;
  +
   /**
    * This is a default implementation of EngineConfigurationFactory.
    * It is user-overrideable by a system property without affecting
  @@ -73,6 +78,8 @@
    * @author Glyn Normington (glyn@apache.org)
    */
   public class DefaultEngineConfigurationFactory implements EngineConfigurationFactory {
  +    private static final String CLIENT_CONFIG_FILE = "client-config.wsdd";
  +    private static final String SERVER_CONFIG_FILE = "server-config.wsdd";
   
       private EngineConfigurationFactory userFactory = null;
   
  @@ -99,12 +106,12 @@
   
           clientConfigFile = System.getProperty("axis.ClientConfigFile");
           if (clientConfigFile == null) {
  -            clientConfigFile = Constants.CLIENT_CONFIG_FILE;
  +            clientConfigFile = CLIENT_CONFIG_FILE;
           }
   
           serverConfigFile = System.getProperty("axis.ServerConfigFile");
           if (serverConfigFile == null) {
  -            serverConfigFile = Constants.SERVER_CONFIG_FILE;
  +            serverConfigFile = SERVER_CONFIG_FILE;
           }
           
       }
  @@ -132,6 +139,38 @@
               return new FileProvider(serverConfigFile);
           } else {
               return userFactory.getServerEngineConfig();
  +        }
  +    }
  +
  +    /**
  +     * Get a default server engine configuration in a servlet environment.
  +     *
  +     * @param ctx a ServletContext
  +     * @return a server EngineConfiguration
  +     */
  +    public EngineConfiguration getServerEngineConfig(ServletContext ctx) {
  +        if (userFactory == null) {
  +            /*
  +             * Use the WEB-INF directory (so the config files can't get
  +             * snooped by a browser)
  +             */
  +            String webInfPath = ctx.getRealPath("/WEB-INF");
  + 
  +            FileProvider config = null ;
  +
  +            if (!(new File(webInfPath,
  +                           SERVER_CONFIG_FILE)).exists()){
  +                InputStream is = null ;
  +                is = ctx.getResourceAsStream("/WEB-INF/"+
  +                                                 SERVER_CONFIG_FILE);
  +                if (is != null) config = new FileProvider(is);
  +            }
  +            if ( config == null )
  +                config = new FileProvider(webInfPath,
  +                                          SERVER_CONFIG_FILE);
  +            return config;
  +        } else {
  +            return userFactory.getServerEngineConfig(ctx);
           }
       }
   }
  
  
  
  1.12      +10 -10    xml-axis/java/src/org/apache/axis/transport/http/AdminServlet.java
  
  Index: AdminServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AdminServlet.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AdminServlet.java	8 Nov 2001 21:43:59 -0000	1.11
  +++ AdminServlet.java	7 Feb 2002 13:46:36 -0000	1.12
  @@ -55,11 +55,12 @@
   
   package org.apache.axis.transport.http ;
   
  -import org.apache.axis.configuration.FileProvider;
  +import org.apache.axis.EngineConfiguration;
  +import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
   import org.apache.axis.server.AxisServer;
   import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.Constants;
   
  +import javax.servlet.ServletContext;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
  @@ -77,16 +78,15 @@
    */
   public class AdminServlet extends HttpServlet {
       public AxisServer getEngine() {
  -        if (getServletContext().getAttribute("AxisEngine") == null) {
  -            // Set the base path for the AxisServer to our WEB-INF directory
  -            // (so the config files can't get snooped by a browser)
  -            FileProvider provider =
  -                    new FileProvider(getServletContext().getRealPath("/WEB-INF"),
  -                                     Constants.SERVER_CONFIG_FILE);
  +        ServletContext context = getServletContext();
  +        if (context.getAttribute("AxisEngine") == null) {
  +            EngineConfiguration config =
  +                (new DefaultEngineConfigurationFactory()).
  +                getServerEngineConfig(context);
   
  -            getServletContext().setAttribute("AxisEngine", new AxisServer(provider));
  +            context.setAttribute("AxisEngine", new AxisServer(config));
           }
  -        return (AxisServer)getServletContext().getAttribute("AxisEngine");
  +        return (AxisServer)context.getAttribute("AxisEngine");
       }
   
       public void doGet(HttpServletRequest req, HttpServletResponse res)
  
  
  
  1.77      +7 -17     xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- AxisServlet.java	5 Feb 2002 16:25:39 -0000	1.76
  +++ AxisServlet.java	7 Feb 2002 13:46:36 -0000	1.77
  @@ -61,7 +61,7 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.EngineConfiguration;
  -import org.apache.axis.configuration.FileProvider;
  +import org.apache.axis.configuration.DefaultEngineConfigurationFactory;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPFaultElement;
   import org.apache.axis.security.servlet.ServletSecurityProvider;
  @@ -82,7 +82,7 @@
   import java.io.ByteArrayInputStream;
   import java.io.File;
   import java.io.IOException;
  -import java.io.InputStream;
  +
   import java.io.PrintWriter;
   import java.util.Enumeration;
   import java.util.Map;
  @@ -161,20 +161,10 @@
   
           if (context.getAttribute("AxisEngine") == null) {
               String webInfPath = context.getRealPath("/WEB-INF");
  -            // Set the base path for the AxisServer to our WEB-INF directory
  -            // (so the config files can't get snooped by a browser)
  -            FileProvider provider = null ;
  -
  -            if (!(new File(webInfPath,
  -                           Constants.SERVER_CONFIG_FILE)).exists()){
  -                InputStream is = null ;
  -                is = context.getResourceAsStream("/WEB-INF/"+
  -                                                 Constants.SERVER_CONFIG_FILE);
  -                if ( is != null ) provider = new FileProvider(is);
  -            }
  -            if ( provider == null )
  -                provider = new FileProvider(webInfPath,
  -                                            Constants.SERVER_CONFIG_FILE);
  +
  +            EngineConfiguration config =
  +                (new DefaultEngineConfigurationFactory()).
  +                getServerEngineConfig(context);
   
               Map environment = new HashMap();
               environment.put("servletContext", context);
  @@ -183,7 +173,7 @@
               if(null != webInfPath){
                   environment.put("servlet.realpath",  webInfPath + File.separator + "attachments");
               }
  -            environment.put(EngineConfiguration.PROPERTY_NAME, provider);
  +            environment.put(EngineConfiguration.PROPERTY_NAME, config);
   
               // Obtain an AxisServer by using whatever AxisServerFactory is
               // registered.  The default one will just use the provider we
  
  
  

Mime
View raw message