protected String resolveResourceContextPath(HttpServletRequest request, String resource) {
        final String resourceContextPath = this.getResourceServerContextPath();
        
        this.logger.debug("Attempting to locate resource serving webapp with context path: {}", resourceContextPath);
        
        //Try to resolve the 
        final ServletContext resourceContext = this.servletContext.getContext(resourceContextPath);
        if (resourceContext == null || !resourceContextPath.equals(resourceContext.getContextPath())) {
            this.logger.warn("Could not find resource serving webapp under context path {} ensure the resource server is deployed and cross context dispatching is enable for this web application", resourceContextPath);
            return request.getContextPath();
        }
        
        this.logger.debug("Found resource serving webapp at: {}", resourceContextPath);
        
        URL url = null;
        try {
            url = resourceContext.getResource(resource);
        }
        catch (MalformedURLException e) {
            //Ignore
        }
        
        if (url == null) {
            this.logger.debug("Resource serving webapp {} doesn't contain resource {} Falling back to the local resource.", resourceContextPath, resource);
            return request.getContextPath();
        }
        
        this.logger.debug("Resource serving webapp {} contains resource {} Using resource server.", resourceContextPath, resource);
        return resourceContextPath;
    }
protected String resolveResourceContextPath ( HttpServletRequest request , String resource ) { final String resourceContextPath = this . getResourceServerContextPath ( ) ; this . logger . debug ( "Attempting to locate resource serving webapp with context path: {}" , resourceContextPath ) ; final ServletContext resourceContext = this . servletContext . getContext ( resourceContextPath ) ; if ( resourceContext == null || ! resourceContextPath . equals ( resourceContext . getContextPath ( ) ) ) { this . logger . warn ( "Could not find resource serving webapp under context path {} ensure the resource server is deployed and cross context dispatching is enable for this web application" , resourceContextPath ) ; return request . getContextPath ( ) ; } this . logger . debug ( "Found resource serving webapp at: {}" , resourceContextPath ) ; URL url = null ; try { url = resourceContext . getResource ( resource ) ; } catch ( MalformedURLException e ) { } if ( url == null ) { this . logger . debug ( "Resource serving webapp {} doesn't contain resource {} Falling back to the local resource." , resourceContextPath , resource ) ; return request . getContextPath ( ) ; } this . logger . debug ( "Resource serving webapp {} contains resource {} Using resource server." , resourceContextPath , resource ) ; return resourceContextPath ; }
If the resource serving servlet context is available and the resource
is available in the context, create a URL to the resource in that context.
If not, create a local URL for the requested resource.