Class LocalResourceDispatcher


  • public class LocalResourceDispatcher
    extends Object
    Handy class to identify requests to local resources and to dispatch them properly.
    Since:
    3.3.0
    • Method Detail

      • isLocalRequest

        public boolean isLocalRequest​(URI uri)
        Determines whether a URI corresponds to a local resource.
        Parameters:
        uri - the resource URI.
        Returns:
        true if uri corresponds to a local resource; false otherwise.
      • dispatch

        public Response dispatch​(URI uri)
                          throws ServletException,
                                 IOException
        Dispatch a request to a local resource. This method removes the protocol and hostname of the given URI up the application context to ensure a local resource will be fetched.

        Note: RequestDispatcher forward does not work in some JAX-RS contexts (PRDOSLC-802, OSLCJIRA-1311) Current recommendations are: - When possible, clients should detect local resources on their own and make direct calls to them rather than go through the ProxyService - Apps that are not compatible with RequestDispatcher should use Options.enableProxyLocalRequestsRedirect(true)

        Parameters:
        uri - the local resource URI.
        Returns:
        a temporary redirect response if the Options.OPTION_ENABLE_PROXY_REDIRECT option is enabled; null otherwise.
        Throws:
        ServletException - if request cannot be dispatched.
        IOException - if some I/O exception occurs.