Package com.sodius.oslc.server.util
Class LocalResourceDispatcher
- java.lang.Object
-
- com.sodius.oslc.server.util.LocalResourceDispatcher
-
public class LocalResourceDispatcher extends Object
Handy class to identify requests to local resources and to dispatch them properly.- Since:
- 3.3.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Responsedispatch(URI uri)Dispatch a request to a local resource.booleanisLocalRequest(URI uri)Determines whether a URI corresponds to a local resource.static LocalResourceDispatcherof(HttpServletRequest request, HttpServletResponse response)Creates an instance for a given HTTP request and response.
-
-
-
Method Detail
-
of
public static LocalResourceDispatcher of(HttpServletRequest request, HttpServletResponse response)
Creates an instance for a given HTTP request and response.- Parameters:
request- the HTTP request.response- the HTTP response.- Returns:
- the corresponding instance.
-
isLocalRequest
public boolean isLocalRequest(URI uri)
Determines whether a URI corresponds to a local resource.- Parameters:
uri- the resource URI.- Returns:
trueifuricorresponds to a local resource;falseotherwise.
-
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_REDIRECToption is enabled;nullotherwise. - Throws:
ServletException- if request cannot be dispatched.IOException- if some I/O exception occurs.
-
-