You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/04/07 17:50:27 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc TurbineXmlRpc.java TurbineXmlRpcService.java

henning     2003/04/07 08:50:27

  Modified:    src/java/org/apache/turbine/services/xmlrpc
                        TurbineXmlRpc.java TurbineXmlRpcService.java
  Log:
  - Factored out configuration object
  - some cleanup for imports and comments
  - added some debugging
  - using StringUtils
  
  Revision  Changes    Path
  1.7       +3 -1      jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpc.java
  
  Index: TurbineXmlRpc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpc.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TurbineXmlRpc.java	9 Mar 2003 03:06:35 -0000	1.6
  +++ TurbineXmlRpc.java	7 Apr 2003 15:50:27 -0000	1.7
  @@ -55,7 +55,9 @@
    */
   
   import java.io.InputStream;
  +
   import java.net.URL;
  +
   import java.util.Vector;
   
   import org.apache.turbine.services.TurbineServices;
  @@ -108,7 +110,7 @@
        * @exception TurbineException
        */
       public static Object executeAuthenticatedRpc(URL url, String username,
  -                                                 String password, String methodName, Vector params)
  +            String password, String methodName, Vector params)
               throws TurbineException
       {
           return getService().executeAuthenticatedRpc(url, username, password,
  
  
  
  1.19      +54 -37    jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java
  
  Index: TurbineXmlRpcService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TurbineXmlRpcService.java	9 Mar 2003 03:06:35 -0000	1.18
  +++ TurbineXmlRpcService.java	7 Apr 2003 15:50:27 -0000	1.19
  @@ -55,21 +55,31 @@
    */
   
   import java.io.InputStream;
  +
   import java.net.InetAddress;
   import java.net.Socket;
   import java.net.URL;
   import java.net.UnknownHostException;
  +
   import java.util.Iterator;
   import java.util.Vector;
  +
   import javax.servlet.ServletConfig;
   
   import org.apache.commons.configuration.Configuration;
  +
  +import org.apache.commons.lang.StringUtils;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +
   import org.apache.turbine.services.InitializationException;
   import org.apache.turbine.services.TurbineBaseService;
   import org.apache.turbine.services.xmlrpc.util.FileTransfer;
   import org.apache.turbine.util.TurbineException;
  +
  +import org.apache.xerces.parsers.SAXParser;
  +
   import org.apache.xmlrpc.WebServer;
   import org.apache.xmlrpc.XmlRpc;
   import org.apache.xmlrpc.XmlRpcClient;
  @@ -141,21 +151,24 @@
       public void init()
               throws InitializationException
       {
  +        Configuration conf = getConfiguration();
  +
           try
           {
               server = new XmlRpcServer();
   
               // setup JSSE System properties from secure.server.options
               Configuration secureServerOptions =
  -                    getConfiguration().subset("secure.server.option");
  +                    conf.subset("secure.server.option");
  +
               if (secureServerOptions != null)
               {
                   setSystemPropertiesFromConfiguration(secureServerOptions);
               }
   
               // Host and port information for the WebServer
  -            String addr = getConfiguration().getString("address", "0.0.0.0");
  -            port = getConfiguration().getInt("port", 0);
  +            String addr = conf.getString("address", "0.0.0.0");
  +            port = conf.getInt("port", 0);
   
               if (port != 0)
               {
  @@ -171,7 +184,9 @@
                       }
                   }
   
  -                if (getConfiguration().getBoolean("secure.server", false))
  +                log.debug("Port: " + port + ", Address: " + address);
  +
  +                if (conf.getBoolean("secure.server", false))
                   {
                       webserver = new SecureWebServer(port, address);
                   }
  @@ -182,24 +197,26 @@
               }
   
               // Set the XML driver to the correct SAX parser class
  -            String saxParserClass = getConfiguration().getString("parser",
  -                    "org.apache.xerces.parsers.SAXParser");
  +            String saxParserClass = 
  +                    conf.getString("parser", SAXParser.class.getName());
   
               XmlRpc.setDriver(saxParserClass);
   
               // Check if there are any handlers to register at startup
  -            for (Iterator keys = getConfiguration().getKeys("handler"); keys.hasNext();)
  +            for (Iterator keys = conf.getKeys("handler"); keys.hasNext();)
               {
  -                String handler = (String) keys.next();
  -                String handlerName = handler.substring(handler.indexOf(".") + 1);
  -                String handlerClass = getConfiguration().getString(handler);
  +                String handler      = (String) keys.next();
  +                String handlerName  = handler.substring(handler.indexOf('.')+1);
  +                String handlerClass = conf.getString(handler);
  +
  +                log.debug("Found Handler " + handler + " as " + handlerName + " / " + handlerClass);
  +
                   registerHandler(handlerName, handlerClass);
               }
   
  -            /*
  -             * Turn on paranoia for the webserver if requested.
  -             */
  -            boolean stateOfParanoia = getConfiguration().getBoolean("paranoid", false);
  +            // Turn on paranoia for the webserver if requested.
  +            boolean stateOfParanoia =
  +                    conf.getBoolean("paranoid", false);
   
               if (stateOfParanoia)
               {
  @@ -207,24 +224,21 @@
                   log.info(XmlRpcService.SERVICE_NAME +
                           ": Operating in a state of paranoia");
   
  -                /*
  -                 * Only set the accept/deny client lists if we
  -                 * are in a state of paranoia as they will just
  -                 * be ignored so there's no point in setting them.
  -                 */
  -
  -                /*
  -                 * Set the list of clients that can connect
  -                 * to the xmlrpc server. The accepted client list
  -                 * will only be consulted if we are paranoid.
  -                 */
  -                Vector acceptedClients = getConfiguration().getVector("acceptClient");
  +                // Only set the accept/deny client lists if we
  +                // are in a state of paranoia as they will just
  +                // be ignored so there's no point in setting them.
  +
  +                // Set the list of clients that can connect
  +                // to the xmlrpc server. The accepted client list
  +                // will only be consulted if we are paranoid.
  +                Vector acceptedClients =
  +                        conf.getVector("acceptClient");
   
                   for (int i = 0; i < acceptedClients.size(); i++)
                   {
                       String acceptClient = (String) acceptedClients.get(i);
   
  -                    if (acceptClient != null && !acceptClient.equals(""))
  +                    if (StringUtils.isNotEmpty(acceptClient))
                       {
                           webserver.acceptClient(acceptClient);
                           log.info(XmlRpcService.SERVICE_NAME +
  @@ -232,18 +246,16 @@
                       }
                   }
   
  -                /*
  -                 * Set the list of clients that can connect
  -                 * to the xmlrpc server. The denied client list
  -                 * will only be consulted if we are paranoid.
  -                 */
  -                Vector deniedClients = getConfiguration().getVector("denyClient");
  +                // Set the list of clients that can connect
  +                // to the xmlrpc server. The denied client list
  +                // will only be consulted if we are paranoid.
  +                Vector deniedClients = conf.getVector("denyClient");
   
                   for (int i = 0; i < deniedClients.size(); i++)
                   {
                       String denyClient = (String) deniedClients.get(i);
   
  -                    if (denyClient != null && !denyClient.equals(""))
  +                    if (StringUtils.isNotEmpty(denyClient))
                       {
                           webserver.denyClient(denyClient);
                           log.info(XmlRpcService.SERVICE_NAME +
  @@ -293,7 +305,7 @@
        * Create System properties using the key-value pairs in a given
        * Configuration.  This is used to set system properties and the
        * URL https connection handler needed by JSSE to enable SSL
  -     * between XMLRPC client and server.
  +     * between XML-RPC client and server.
        *
        * @param configuration the Configuration defining the System
        * properties to be set
  @@ -336,6 +348,11 @@
           }
   
           server.addHandler(handlerName, handler);
  +        
  +        log.debug("Registered Handler " + handlerName + " as " 
  +                + handler.getClass().getName() 
  +                + ", Server: " + server 
  +                + ", Webserver: " + webserver);
       }
   
       /**
  @@ -543,7 +560,7 @@
       }
   
       /**
  -     * Method to allow a client to get a file to a server.
  +     * Method to allow a client to get a file from a server.
        *
        * @param serverURL
        * @param sourceLocationProperty
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org