axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http AxisServlet.java
Date Fri, 07 Dec 2001 20:17:15 GMT
gdaniels    01/12/07 12:17:15

  Modified:    java/src/org/apache/axis/server Tag: alpha-3 AxisServer.java
                        AxisServerFactory.java
               java/src/org/apache/axis/transport/http Tag: alpha-3
                        AxisServlet.java
  Added:       java/src/org/apache/axis/server Tag: alpha-3
                        DefaultAxisServerFactory.java
                        JNDIAxisServerFactory.java
  Log:
  Merge AxisServerFactory changes over to alpha-3 branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.50.2.1  +28 -0     xml-axis/java/src/org/apache/axis/server/AxisServer.java
  
  Index: AxisServer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
  retrieving revision 1.50
  retrieving revision 1.50.2.1
  diff -u -r1.50 -r1.50.2.1
  --- AxisServer.java	2001/12/05 00:27:18	1.50
  +++ AxisServer.java	2001/12/07 20:17:15	1.50.2.1
  @@ -68,6 +68,8 @@
   import org.apache.axis.utils.AxisClassLoader;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.log4j.Category;
  +
  +import java.util.Map;
   /**
    *
    * @author Doug Davis (dug@us.ibm.com)
  @@ -77,6 +79,32 @@
   {
       static Category category =
               Category.getInstance(AxisServer.class.getName());
  +
  +    private static AxisServerFactory factory = null;
  +    
  +    public static AxisServer getServer(Map environment) throws AxisFault
  +    {
  +        if (factory == null) {
  +            String factoryClassName = System.getProperty("axis.ServerFactory");
  +            if (factoryClassName != null) {
  +                try {
  +                    Class factoryClass = Class.forName(factoryClassName);
  +                    if (AxisServerFactory.class.isAssignableFrom(factoryClass))
  +                        factory = (AxisServerFactory)factoryClass.newInstance();
  +                } catch (Exception e) {
  +                    // If something goes wrong here, should we just fall
  +                    // through and use the default one?
  +                    e.printStackTrace(System.err);
  +                }
  +            }
  +            
  +            if (factory == null) {
  +                factory = new DefaultAxisServerFactory();
  +            }
  +        }
  +        
  +        return factory.getServer(environment);                
  +    }
   
       /**
        * the AxisClient to be used by outcalling Services
  
  
  
  1.2.2.1   +4 -106    xml-axis/java/src/org/apache/axis/server/AxisServerFactory.java
  
  Index: AxisServerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- AxisServerFactory.java	2001/12/03 18:17:09	1.2
  +++ AxisServerFactory.java	2001/12/07 20:17:15	1.2.2.1
  @@ -7,115 +7,13 @@
   
   import javax.naming.InitialContext;
   import javax.naming.NamingException;
  +import java.util.Map;
   
   /**
  - * Helper class for obtaining AxisServers, which hides the complexity
  - * of JNDI accesses, etc.
  - *
  - * !!! QUESTION : Does this class need to play any ClassLoader tricks?
  - * 
    * @author Glen Daniels (gdaniels@macromedia.com)
    */ 
   
  -public class AxisServerFactory {
  -    private static FileProvider defaultConfigProvider =
  -                           new FileProvider(Constants.SERVER_CONFIG_FILE);
  -
  -    /**
  -     * Obtain an AxisServer reference, using JNDI if possible, otherwise
  -     * creating one using the standard Axis configuration pattern.  If we
  -     * end up creating one and do have JNDI access, bind it to the passed
  -     * name so we find it next time.
  -     *
  -     * @param name the JNDI name we're interested in
  -     * @param configProvider a ConfigurationProvider which should be used
  -     *                       to configure any engine we end up creating, or
  -     *                       null to use the default configuration pattern.
  -     */
  -    static public AxisServer getServer(String name,
  -                                       ConfigurationProvider configProvider)
  -        throws AxisFault
  -    {
  -        AxisServer server = null;
  -        InitialContext context = null;
  -
  -        // First, and foremost, if a configProvider is passed in
  -        //  ALWAYS use that...
  -        if (configProvider != null) {
  -            return createNewServer(configProvider);
  -        }
  -
  -        // First check to see if JNDI works
  -        // !!! Might we need to set up context parameters here?
  -        try {
  -            context = new InitialContext();
  -        } catch (NamingException e) {
  -        }
  -        
  -        if (context != null) {
  -            // We've got JNDI, so try to find an AxisServer at the
  -            // specified name.
  -            try {
  -                server = (AxisServer)context.lookup(name);
  -            } catch (NamingException e) {
  -                // Didn't find it.
  -                server = createNewServer(configProvider);
  -                try {
  -                    context.bind(name, server);
  -                } catch (NamingException e1) {
  -                    // !!! Couldn't do it, what should we do here?
  -                }
  -            }
  -        } else {
  -            server = createNewServer(configProvider);
  -        }
  -
  -        return server;
  -    }
  -
  -    /**
  -     * Do the actual work of creating a new AxisServer, using the passed
  -     * configuration provider, or going through the default configuration
  -     * steps if null is passed.
  -     *
  -     * @return a shiny new AxisServer, ready for use.
  -     */
  -    static private AxisServer createNewServer(ConfigurationProvider provider)
  -    {
  -        // Just use the passed provider if there is one.
  -        if (provider != null) {
  -            return new AxisServer(provider);
  -        }
  -
  -        // Default configuration steps...
  -        //
  -        // 1. Check for a system property telling us which Configuration
  -        //    Provider to use.  If we find it, try creating one.
  -        String configClass = System.getProperty("axis.configProviderClass");
  -        if (configClass != null) {
  -            // Got one - so try to make it (which means it had better have
  -            // a default constructor - may make it possible later to pass in
  -            // some kind of environmental parameters...)
  -            try {
  -                Class cls = Class.forName(configClass);
  -                provider = (ConfigurationProvider)cls.newInstance();
  -            } catch (ClassNotFoundException e) {
  -                // Fall through???
  -            } catch (InstantiationException e) {
  -                // Fall through???
  -            } catch (IllegalAccessException e) {
  -                // Fall through???
  -            }
  -        }
  -
  -        // 2. If we couldn't make one above, use the default one.
  -        // !!! May want to add options here for getting another system
  -        //     property which is the config file name...
  -        if (provider == null) {
  -            provider = defaultConfigProvider;
  -        }
  -
  -        // 3. Create an AxisServer using the appropriate provider
  -        return new AxisServer(provider);
  -    }
  +public interface AxisServerFactory {    
  +    public AxisServer getServer(Map environment)
  +        throws AxisFault;
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +0 -0      xml-axis/java/src/org/apache/axis/server/DefaultAxisServerFactory.java
  
  Index: DefaultAxisServerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/DefaultAxisServerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  
  
  
  1.2.2.1   +0 -0      xml-axis/java/src/org/apache/axis/server/JNDIAxisServerFactory.java
  
  Index: JNDIAxisServerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/JNDIAxisServerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.67.2.2  +12 -8     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.67.2.1
  retrieving revision 1.67.2.2
  diff -u -r1.67.2.1 -r1.67.2.2
  --- AxisServlet.java	2001/12/06 18:41:09	1.67.2.1
  +++ AxisServlet.java	2001/12/07 20:17:15	1.67.2.2
  @@ -84,6 +84,8 @@
   import java.io.InputStream;
   import java.io.PrintWriter;
   import java.util.Enumeration;
  +import java.util.Map;
  +import java.util.HashMap;
   
   /**
    *
  @@ -140,11 +142,14 @@
                       new FileProvider(webInfPath,
                                        Constants.SERVER_CONFIG_FILE);
   
  -            // Obtain an AxisServer using the AxisServerFactory.  This will
  -            // first check JNDI to see if there's a server at the specified
  -            // name, which in this case is our WEB-INF path plus "/AxisServer".
  -            // (servlet 2.3 has a getServletContextName() API which might be
  -            // better used here)
  +            Map environment = new HashMap();
  +            environment.put("servletContext", getServletContext());
  +            environment.put("provider", provider);
  +
  +            // Obtain an AxisServer by using whatever AxisServerFactory is
  +            // registered.  The default one will just use the provider we
  +            // passed in, and presumably JNDI ones will use the ServletContext
  +            // to figure out a JNDI name to look up.
               //
               // The point of doing this rather than just creating the server
               // manually with the provider above is that we will then support
  @@ -152,9 +157,8 @@
               // container, and pre-registered in JNDI at deployment time.  It
               // also means we put the standard configuration pattern in one
               // place.
  -            getServletContext().setAttribute("AxisEngine",
  -                        AxisServerFactory.getServer(webInfPath + "/AxisServer",
  -                                                    provider));
  +            getServletContext().setAttribute("AxisEngine", 
  +                                             AxisServer.getServer(environment));
           }
           return (AxisServer)getServletContext().getAttribute("AxisEngine");
       }
  
  
  

Mime
View raw message