public ResourceKey apply(String from) { return create(from); } };
@Override public ResourceKey apply(Class<?> from) { ResourceKey key = ResourceKey.create(from.getName()); return key; } };
LibraryFunctionImplementation(String functionName, String resource, String library) { this.library = Collections.singleton(ResourceKey.create(resource, library)); this.functionName = functionName; }
LibraryFunctionImplementation(String functionName, String resource, String library) { this.library = Collections.singleton(ResourceKey.create(resource, library)); this.functionName = functionName; }
static <V> Map<ResourceKey, V> readMappings(Function<Entry<String, String>, V> producer, String mappingFileName) { Map<ResourceKey, V> result = Maps.newHashMap(); for (Entry<String, String> entry : PropertiesUtil.loadProperties(mappingFileName).entrySet()) { result.put(ResourceKey.create(entry.getKey()), producer.apply(entry)); } result = Collections.unmodifiableMap(result); return result; }
public MappedResourceData apply(Entry<String, String> from) { String resourceLocation = from.getValue(); Map<String, String> params = ResourceUtils.parseResourceParameters(resourceLocation); String resourceQualifier = extractParametersFromResourceName(resourceLocation); return new MappedResourceData(ResourceKey.create(resourceQualifier), params); } };
public ResourceKey apply(Resource from) { return ResourceKey.create(from.getName(), from.getLibrary()); } });
} catch (URISyntaxException e) { throw new IllegalStateException(String.format("Failed to parse requestPath '%s' for resource '%s': %s", resource.getRequestPath(), ResourceKey.create(resource), e.getMessage()), e);
public ResourceKey apply(Resource from) { return ResourceKey.create(from.getName(), from.getLibrary()); } });
writer.write(String.format("// resource: %s\n", ResourceKey.create(crc.getResource()))); writer.flush();
writer.write(String.format("/* resource: %s */\n", ResourceKey.create(crc.getResource()))); writer.flush();
private static LibraryFunction getScriptFromAnnotation(Class<?> javaClass) { if (javaClass.isAnnotationPresent(ClientSideScript.class)) { ClientSideScript clientSideScript = javaClass.getAnnotation(ClientSideScript.class); List<ResourceKey> resources = Lists.newArrayList(); for (ResourceDependency dependency : clientSideScript.resources()) { resources.add(ResourceKey.create(dependency.name(), dependency.library())); } return new LibraryFunctionImplementation(clientSideScript.function(), resources); } else { return NO_SCRIPT; } }
private static LibraryFunction getScriptFromAnnotation(Class<?> javaClass) { if (javaClass.isAnnotationPresent(ClientSideScript.class)) { ClientSideScript clientSideScript = javaClass.getAnnotation(ClientSideScript.class); List<ResourceKey> resources = Lists.newArrayList(); for (ResourceDependency dependency : clientSideScript.resources()) { resources.add(ResourceKey.create(dependency.name(), dependency.library())); } return new LibraryFunctionImplementation(clientSideScript.function(), resources); } else { return NO_SCRIPT; } }
public String imageUrl(String resourceName) { if ("plain".equals(getName())){ return "none"; } FacesContext facesContext = FacesContext.getCurrentInstance(); Resource resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, IMAGE_LIBRARY); String resourcePath; if (resource != null) { resourcePath = resource.getRequestPath(); } else { resourcePath = "RES_NOT_FOUND"; LOG.warn("Unable to find or serve resource '" + ResourceKey.create(resourceName, IMAGE_LIBRARY) + "'"); } return String.format("url(%s)", resourcePath); }
@Override public void init() { final Map<ResourceKey, ResourceMapping> result = Maps.newHashMap(); final List<String> mappingFiles = PropertiesMappingConfiguration.getMappingFiles(); for (String mappingFile : mappingFiles) { if (classpathResourceExistsForLocation(mappingFile)) { for (Entry<String, String> entry : PropertiesUtil.loadProperties(mappingFile).entrySet()) { final ResourceKey resourceKey = ResourceKey.create(entry.getKey()); final ResourcePath resourceLocation = new ResourcePath(entry.getValue()); result.put(resourceKey, new LocationBasedResourceMapping(resourceLocation)); } } else { if (!isDefaultStaticResourceMappingLocation(mappingFile)) { LOGGER.warn("Resource mapping is configured to load non-existent resource: '" + mappingFile + "'"); } } } mappings = result; }
private void scanResourcesRoot(VirtualFile file) { if (file == null) { return; } Collection<VirtualFile> children = file.getChildren(); for (VirtualFile child : children) { if (child.isFile()) { resources.add(ResourceKey.create(child.getName())); } else { String libraryName = child.getName(); VirtualFile libraryDir = ResourceUtil.getLatestVersion(child, true); if (libraryDir != null) { scanLibrary(libraryName, "", libraryDir); } } } }