Class ApacheServer

  • All Implemented Interfaces:
    SampXmlRpcServer

    public class ApacheServer
    extends java.lang.Object
    implements SampXmlRpcServer
    SampXmlRpcServer implementation based on Apache XML-RPC library.
    Since:
    22 Aug 2008
    Author:
    Mark Taylor
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  ApacheServer.LabelledServer
      Convenience class which aggregates a WebServer and an endpoint.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.URL endpoint_  
      private java.util.List handlerList_  
      private WebServer webServer_  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ApacheServer()
      Constructs a new server starting up a new WebServer object.
      private ApacheServer​(ApacheServer.LabelledServer server)
      Private constructor used by all other constructors.
        ApacheServer​(WebServer webServer, int port)
      Constructs a new server based on a given WebServer object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHandler​(SampXmlRpcHandler handler)
      Adds a handler which can service certain XML-RPC methods.
      private static ApacheServer.LabelledServer createLabelledServer​(boolean isDaemon)
      Constructs a new LabelledServer object suitable for use with this server.
      private java.lang.Object doExecute​(java.lang.String fqMethod, java.util.Vector paramVec)
      Does the work for executing an XML-RPC request.
      java.net.URL getEndpoint()
      Returns the server's endpoint.
      private static java.net.URL getServerEndpoint​(int port)
      Returns the endpoint URL to use for an Apache server running on a given port.
      void removeHandler​(SampXmlRpcHandler handler)
      Removes a previously-added handler.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • webServer_

        private final WebServer webServer_
      • endpoint_

        private final java.net.URL endpoint_
      • handlerList_

        private final java.util.List handlerList_
    • Constructor Detail

      • ApacheServer

        private ApacheServer​(ApacheServer.LabelledServer server)
        Private constructor used by all other constructors. Uses the private LabelledServer class to aggregate the required information.
        Parameters:
        server - server with metadata
      • ApacheServer

        public ApacheServer​(WebServer webServer,
                            int port)
        Constructs a new server based on a given WebServer object. Responsibility for starting the WebServer and performing any other required configuration lies with the caller.
        Parameters:
        webServer - apache xmlrpc webserver object
        port - port number on which the server is running
      • ApacheServer

        public ApacheServer()
                     throws java.io.IOException
        Constructs a new server starting up a new WebServer object. The server runs in a daemon thread.
        Throws:
        java.io.IOException
    • Method Detail

      • getEndpoint

        public java.net.URL getEndpoint()
        Description copied from interface: SampXmlRpcServer
        Returns the server's endpoint.
        Specified by:
        getEndpoint in interface SampXmlRpcServer
        Returns:
        URL to which XML-RPC requests are POSTed
      • doExecute

        private java.lang.Object doExecute​(java.lang.String fqMethod,
                                           java.util.Vector paramVec)
                                    throws java.lang.Exception
        Does the work for executing an XML-RPC request.
        Parameters:
        fqMethod - fully qualified XML-RPC method name
        paramVec - Apache-style list of method parameters
        Throws:
        java.lang.Exception
      • createLabelledServer

        private static ApacheServer.LabelledServer createLabelledServer​(boolean isDaemon)
                                                                 throws java.io.IOException
        Constructs a new LabelledServer object suitable for use with this server.
        Parameters:
        isDaemon - whether the WebServer's main thread should run in daemon mode
        Throws:
        java.io.IOException
      • getServerEndpoint

        private static java.net.URL getServerEndpoint​(int port)
        Returns the endpoint URL to use for an Apache server running on a given port.
        Parameters:
        port - port number
        Returns:
        URL