public ResourceKey apply(String from) { return create(from); } };
/** * Factory method for creating resource key from single resource qualifier in format library:resource */ public static ResourceKey create(String resourceQualifier) { return new ResourceKey(extractResourceName(resourceQualifier), extractLibraryName(resourceQualifier)); }
ResourcesRendererCallable(ResourceKey resourceKey) { this.resourceKey = resourceKey; // when packaging JSF's JavaScript implementation, use uncompressed version // as double compression may lead in inability to use it if (packName != null && ResourceConstants.JSF_COMPRESSED.equals(resourceKey)) { this.resourceKey = ResourceConstants.JSF_UNCOMPRESSED; } }
/** * Creates a relative resource path from given {@link ResourceKey} */ public ResourcePath(ResourceKey key) { this.resourcePath = key.getResourceName(); if (key.getLibraryName() != null && !key.getLibraryName().isEmpty()) { this.resourcePath = key.getLibraryName() + "/" + key.getResourceName(); } }
/** * Factory method for creating resource key from resource and library name */ public static ResourceKey create(String resourceName, String libraryName) { return new ResourceKey(resourceName, libraryName); }
@Override public String getLibraryName() { return resourceKey.getLibraryName(); }
@Override public String getResourceName() { return resourceKey.getResourceName(); }
@Override public String getResourceKey() { return resourceKey.toString(); }
/** * Returns the qualified name of resourceKey in format libraryName:resourceName. * * @param resourceKey the resourceKey * @return the qualified name of resourceKey in format libraryName:resourceName. */ public static String getResourceQualifier(ResourceKey resourceKey) { return COLON_JOINER.join(resourceKey.getLibraryName(), resourceKey.getResourceName()); }
@Override public ResourceLibrary getResourceLibrary(String name, String library) { ResourceKey resourceKey = new ResourceKey(name, library); try { return instances.get(resourceKey); } catch (ExecutionException e) { throw new FacesException(String.format("Can't resolve resource library %s", resourceKey), e); } }
@Override public ResourceMapping mapResource(ResourceKey resourceKey) { String library = Strings.nullToEmpty(resourceKey.getLibraryName()); if (RESOURCE_LIBRARIES_TO_MAP.contains(library)) { return new ResourceServletMapping(resourceKey); } else { return null; } } }
private boolean shouldSkipResourceRenderingForSkin(String skin) { if ("plain".equals(skin)) { // detect whether the mime-type of the given resource path denotes image File resourceFileName = new File(resourceKey.getResourceName()); String mimeType = MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(resourceFileName); if (mimeType.startsWith("image/")) { log.debug(String.format("Skipped rendering of %s as it is image that isn't required by skin %s", resourceKey, skin)); return true; } } return false; } }
@Override public ResourceKey apply(Class<?> from) { ResourceKey key = ResourceKey.create(from.getName()); return key; } };
@Override public boolean isResourceRenderered(FacesContext facesContext, ResourceKey resourceKey) { Map<Object, Object> contextMap = facesContext.getAttributes(); String key = resourceKey.getResourceName() + resourceKey.getLibraryName(); return contextMap.containsKey(key); }
public Resource createResource(String resourceName, String libraryName, String contentType) { ResourceKey resourceKey = new ResourceKey(resourceName, libraryName); Resource resource = createMappedResource(resourceKey); if (resource != null) { return resource; } else { return createDynamicResource(resourceKey, true); } }
LibraryFunctionImplementation(String functionName, String resource, String library) { this.library = Collections.singleton(ResourceKey.create(resource, library)); this.functionName = functionName; }
@Override public void markResourceRendered(FacesContext facesContext, ResourceKey resourceKey) { final String mimeType = facesContext.getExternalContext().getMimeType(resourceKey.getResourceName()); try { if (MimeType.STYLESHEET.contains(mimeType)) { markStylesheetAsRendered .invoke(null, facesContext, resourceKey.getLibraryName(), resourceKey.getResourceName()); } else if (MimeType.SCRIPT.contains(mimeType)) { markScriptAsRendered.invoke(null, facesContext, resourceKey.getLibraryName(), resourceKey.getResourceName()); } } catch (Exception e) { ResourceTrackerForMyFaces.handleException(e); } }
@Override public ResourceKey apply(ResourceDependency resourceDependency) { return new ResourceKey(resourceDependency.name(), resourceDependency.library()); } };
LibraryFunctionImplementation(String functionName, String resource, String library) { this.library = Collections.singleton(ResourceKey.create(resource, library)); this.functionName = functionName; }
private Resource createCompiledCSSResource(ResourceKey resourceKey) { Resource sourceResource = defaultHandler.createResource(resourceKey.getResourceName(), resourceKey.getLibraryName(), "text/plain"); if (sourceResource != null) { return new CompiledCSSResource(sourceResource); } return null; }