/** * Create a PropertySource based on Properties loaded from the given resource. * The name of the PropertySource will be generated based on the * {@link Resource#getDescription() description} of the given resource. */ public ResourcePropertySource(Resource resource) throws IOException { super(getNameForResource(resource), PropertiesLoaderUtils.loadProperties(new EncodedResource(resource))); this.resourceName = null; }
/** * Create a PropertySource having the given name based on Properties * loaded from the given encoded resource. */ public ResourcePropertySource(String name, EncodedResource resource) throws IOException { super(name, PropertiesLoaderUtils.loadProperties(resource)); this.resourceName = getNameForResource(resource.getResource()); }
public static Set<Resource> findMatchingResources( URL rootDirURL, String locationPattern, PathMatcher pathMatcher) throws IOException { Object root = VfsPatternUtils.findRoot(rootDirURL); PatternVirtualFileVisitor visitor = new PatternVirtualFileVisitor(VfsPatternUtils.getPath(root), locationPattern, pathMatcher); VfsPatternUtils.visit(root, visitor); return visitor.getResources(); } }
/** * Determine the Spring {@link ResourceLoader} to use for Hibernate metadata. * @return the ResourceLoader to use (never {@code null}) * @since 4.3 */ public ResourceLoader getResourceLoader() { if (this.resourcePatternResolver == null) { this.resourcePatternResolver = new PathMatchingResourcePatternResolver(); } return this.resourcePatternResolver; }
@Override public Resource[] getResources(String locationPattern) throws IOException { return this.resourcePatternResolver.getResources(locationPattern); }
@Test public void classpathWithPatternInJar() throws IOException { Resource[] resources = resolver.getResources("classpath:org/reactivestreams/*.class"); assertProtocolAndFilenames(resources, "jar", CLASSES_IN_REACTIVESTREAMS); }
@Override public org.springframework.core.env.PropertySource createPropertySource(String name, EncodedResource resource) throws IOException { Properties props = PropertiesLoaderUtils.loadProperties(resource); return new org.springframework.core.env.PropertySource<Properties>("my" + name, props) { @Override public Object getProperty(String name) { String value = props.getProperty(name); return (value != null ? value.toUpperCase() : null); } }; } }
/** * Specify a Spring {@link ResourceLoader} to use for Hibernate metadata. * @param resourceLoader the ResourceLoader to use (never {@code null}) */ @Override public void setResourceLoader(ResourceLoader resourceLoader) { this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }
/** * Load all properties from the specified class path resource * (in ISO-8859-1 encoding), using the default class loader. * <p>Merges properties if more than one resource of the same name * found in the class path. * @param resourceName the name of the class path resource * @return the populated Properties instance * @throws IOException if loading failed */ public static Properties loadAllProperties(String resourceName) throws IOException { return loadAllProperties(resourceName, null); }
/** * Return a potentially adapted variant of this {@link ResourcePropertySource}, * overriding the previously given name (if any) with the original resource name * (equivalent to the name generated by the name-less constructor variants). * @since 4.1 */ public ResourcePropertySource withResourceName() { if (this.resourceName == null) { return this; } return new ResourcePropertySource(this.resourceName, null, this.source); }
/** * Return the {@link org.springframework.core.io.Resource} to load the * script from. */ public final Resource getResource() { return this.resource.getResource(); }
static String getPath(Object resource) { String path = doGetPath(resource); return (path != null ? path : ""); }
/** * Create a new ResourceArrayPropertyEditor with a default * {@link PathMatchingResourcePatternResolver} and {@link StandardEnvironment}. * @see PathMatchingResourcePatternResolver * @see Environment */ public ResourceArrayPropertyEditor() { this(new PathMatchingResourcePatternResolver(), null, true); }
@Override public Resource[] getResources(String locationPattern) throws IOException { return this.resourcePatternResolver.getResources(locationPattern); }
@Test public void classpathStarWithPatternInJar() throws IOException { Resource[] resources = resolver.getResources("classpath*:org/reactivestreams/*.class"); assertProtocolAndFilenames(resources, "jar", CLASSES_IN_REACTIVESTREAMS); }
/** * Create a PropertySource having the given name based on Properties * loaded from the given encoded resource. */ public ResourcePropertySource(String name, Resource resource) throws IOException { super(name, PropertiesLoaderUtils.loadProperties(new EncodedResource(resource))); this.resourceName = getNameForResource(resource); }
/** * Create a PropertySource based on Properties loaded from the given resource. * The name of the PropertySource will be generated based on the * {@link Resource#getDescription() description} of the given resource. */ public ResourcePropertySource(EncodedResource resource) throws IOException { super(getNameForResource(resource.getResource()), PropertiesLoaderUtils.loadProperties(resource)); this.resourceName = null; }
public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List<String> locations) { this.locations = locations; this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }
private ResourcePatternResolver getResourcePatternResolver() { if (this.resourcePatternResolver == null) { this.resourcePatternResolver = new PathMatchingResourcePatternResolver(); } return this.resourcePatternResolver; }
public SortedResourcesFactoryBean(List<String> locations) { this.locations = locations; this.resourcePatternResolver = new PathMatchingResourcePatternResolver(); }