@Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (requestPath != null && requestPath.contains("BLC")) { Matcher matcher = pattern.matcher(requestPath); if (matcher.find()) { requestPath = matcher.group(1) + "BLC.js"; Resource resource = chain.resolveResource(request, "BLC.js", locations); if (resource == null) { requestPath = matcher.group(1) + "BLC.js"; resource = chain.resolveResource(request, requestPath, locations); } try { resource = convertResource(resource, requestPath); } catch (IOException ioe) { LOG.error("Exception modifying " + BLC_JS_NAME, ioe); } return resource; } } return chain.resolveResource(request, requestPath, locations); }
@Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { Resource resource = chain.resolveResource(request, requestPath, locations); if (requestPath.equalsIgnoreCase(BLC_SYSTEM_PROPERTY_FILE)) { try { resource = convertResource(resource, requestPath); } catch (IOException ioe) { LOG.error("Exception modifying " + BLC_SYSTEM_PROPERTY_FILE, ioe); } } return resource; }
@Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (resourceCachingEnabled) { Resource resource = super.resolveResourceInternal(request, requestPath, locations, chain); if (logger.isDebugEnabled()) { if (resource == null) { logger.debug("Cache resolver, returned a null resource " + requestPath); } else if (!resource.exists()) { logger.debug("Cache resolver, returned a resource that doesn't exist " + requestPath + " - " + resource); } } return resource; } else { return chain.resolveResource(request, requestPath, locations); } }
@Override protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (resourceCachingEnabled) { String key = RESOLVED_URL_PATH_CACHE_KEY_PREFIX_NULL + resourceUrlPath; Object nullResource = getCache().get(key, Object.class); if (nullResource != null) { if (logger.isTraceEnabled()) { logger.trace(String.format("Found null reference url path match for '%s'", resourceUrlPath)); } return null; } else { String response = super.resolveUrlPathInternal(resourceUrlPath, locations, chain); if (response == null) { if (logger.isTraceEnabled()) { logger.trace(String.format("Putting resolved null reference url path in cache for '%s'", resourceUrlPath)); } getCache().put(key, NULL_REFERENCE); } return response; } } else { return chain.resolveUrlPath(resourceUrlPath, locations); } }
@Override protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (resourceVersioningEnabled && !bundlingService.checkForRegisteredBundleFile(resourceUrlPath)) { String result = super.resolveUrlPathInternal(resourceUrlPath, locations, chain); // Spring's default version handler will return null if it doesn't have a strategy // for that resource - that seems incorrect. Overriding here. if (result == null) { return chain.resolveUrlPath(resourceUrlPath, locations); } else { return result; } } else { return chain.resolveUrlPath(resourceUrlPath, locations); } }
@Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (requestPath != null) { if (isBundleFile(requestPath)) { Resource bundle = bundlingService.resolveBundleResource(requestPath); logTraceInformation(bundle); if (bundle != null && bundle.exists()) { return bundle; } } } return chain.resolveResource(request, requestPath, locations); }
protected void createBundleIfNeeded(final String versionedBundleName, final List<String> filePaths, final ResourceResolverChain resolverChain, final List<Resource> locations) { if (!createdBundles.containsKey(versionedBundleName)) { keyLockManager.executeLocked(versionedBundleName, new LockCallback() { @Override public void doInLock() { Resource bundleResource = createdBundles.get(versionedBundleName); if (bundleResource == null || !bundleResource.exists()) { bundleResource = createBundle(versionedBundleName, filePaths, resolverChain, locations); if (bundleResource != null) { saveBundle(bundleResource); } } Resource savedResource = readBundle(versionedBundleName); createdBundles.put(versionedBundleName, savedResource); } }); } }
@Override public String resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain) { Resource resolvedResource = resolve(resourcePath, locations); if (resolvedResource == null) { return null; } try { return resolvedResource.getURL().toString(); } catch (IOException e) { return resolvedResource.getFilename(); } }
@Override public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { // Delegate to the chain if the request is not for ruildBuilder-options.js if(!requestPath.equalsIgnoreCase(RULE_BUILDER_OPTIONS_JS_PATH)){ return chain.resolveResource(request,requestPath,locations); } // aggregate option values for all registered RuleBuilderEnumOptionsExtensionListener StringBuilder sb = new StringBuilder(); for (RuleBuilderEnumOptionsExtensionListener listener : listeners) { sb.append(listener.getOptionValues()).append("\r\n"); } return new GeneratedResource(sb.toString().getBytes(),requestPath) ; }
@Override public String resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain) { if(resourcePath != RULE_BUILDER_OPTIONS_JS_PATH){ return chain.resolveUrlPath(resourcePath,locations); } return RULE_BUILDER_OPTIONS_JS_PATH; }
@Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (resourceVersioningEnabled && !bundlingService.checkForRegisteredBundleFile(requestPath)) { return super.resolveResourceInternal(request, requestPath, locations, chain); } else { return chain.resolveResource(request, requestPath, locations); } }
@Override protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (resourceUrlPath.contains(BLC_JS_NAME)) { Site site = BroadleafRequestContext.getBroadleafRequestContext().getNonPersistentSite(); if (site != null && site.getId() != null) { return addVersion(resourceUrlPath, "-"+site.getId()); } else { return resourceUrlPath; } } return chain.resolveUrlPath(resourceUrlPath, locations); }
@Override protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) { if (resourceUrlPath != null) { if (isBundleFile(resourceUrlPath)) { return resourceUrlPath; } } return chain.resolveUrlPath(resourceUrlPath, locations); }
@Override public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { return new ClassPathResource("public/index.html", this.getClass().getClassLoader()); }
@Override public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { return resolve(requestPath, locations); }
@Override public String resolveUrlPath(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) { // resolveUrlPathする前に、必要があればminifyする AssetsFunction.tryUpdate(resourceUrlPath); return super.resolveUrlPath(resourceUrlPath, locations, chain); }
@Override protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) { return chain.resolveUrlPath(resourceUrlPath, locations); }
@Override protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) { return chain.resolveResource(request, requestPath, locations); }
@Override public String resolveBundleResourceName(String requestedBundleName, String mappingPrefix, List<String> files) { ResourceHttpRequestHandler resourceRequestHandler = findResourceHttpRequestHandler(requestedBundleName); if (resourceRequestHandler != null && CollectionUtils.isNotEmpty(files)) { ResourceResolverChain resolverChain = new BroadleafDefaultResourceResolverChain( resourceRequestHandler.getResourceResolvers()); List<Resource> locations = resourceRequestHandler.getLocations(); StringBuilder combinedPathString = new StringBuilder(); List<String> filePaths = new ArrayList<String>(); for (String file : files) { String resourcePath = resolverChain.resolveUrlPath(file, locations); if (resourcePath == null) { // can't find the exact name specified in the bundle, try it with the mappingPrefix resourcePath = resolverChain.resolveUrlPath(mappingPrefix + file, locations); } if (resourcePath != null) { filePaths.add(resourcePath); combinedPathString.append(resourcePath); } else { LOG.warn(new StringBuilder().append("Could not resolve resource path specified in bundle as [") .append(file) .append("] or as [") .append(mappingPrefix + file) .append("]. Skipping file.") .toString()); } } int version = Math.abs(combinedPathString.toString().hashCode()); String versionedBundleName = mappingPrefix + addVersion(requestedBundleName, "-" + String.valueOf(version)); createBundleIfNeeded(versionedBundleName, filePaths, resolverChain, locations); return versionedBundleName; } else { if (LOG.isWarnEnabled()) { LOG.warn(""); } return null; } }