Class CommandResolver

    • Field Detail

      • ur

        protected URIResolver ur
        The URI resolver which is wrapped, and which handles all non-command URIs.
      • VIEWERPROXY_COMMAND_NAME

        public static final String VIEWERPROXY_COMMAND_NAME
        Fake host used as hostname when doing commands.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CommandResolver

        public CommandResolver​(URIResolver ur)
        Constructor which sets the next resolver in the chain.
        Parameters:
        ur - The URIResolver that handles URIs that are not handled by this resolver.
    • Method Detail

      • setURIResolver

        public final void setURIResolver​(URIResolver anUr)
        Change the URI resolver which handles URIs that we don't handle here.
        Specified by:
        setURIResolver in interface URIResolverHandler
        Parameters:
        anUr - The URI resolver to handle unhandled URIs.
        Throws:
        ArgumentNotValid - if either argument is null.
      • lookup

        public final int lookup​(Request request,
                                Response response)
        Parses the given URI and executes commands for all command URLs. The possible commands are of the form http://<>/<>?<>=<>* where command and param are defined in the subclass.

        If uri is none of these, the uri and response are forwarded to the wrapped URI resolver.

        Specified by:
        lookup in interface URIResolver
        Parameters:
        request - The HTTP request we are working on
        response - HTTP response to generate effect on or to forward
        Returns:
        response code
      • executeCommand

        protected abstract boolean executeCommand​(Request request,
                                                  Response response)
        Abstract method for parsing of the URL and delegating to relevant methods. This should start by calling isCommandHostRequest.
        Parameters:
        request - The request to check
        response - The response to give command results to if it is a command
        Returns:
        Whether this was a command URL
      • isCommandHostRequest

        protected static boolean isCommandHostRequest​(Request request)
        Returns true if the request specifies the host that we're running on. Alternative specifications such as 'localhost' or '127.0.0.1' or an actual IP of this machine are not considered command hosts. Local hosts would only be command hosts if we happen to get a request from a browser running on this machine.
        Parameters:
        request - An HTTP request.
        Returns:
        True if the HTTP request specifies a URI that indicates this machine, false otherwise.