@Veto public class ResourceProvider extends Object implements Serializable
The ResourceProvider allows dynamic loading of managed resources. For example:
@Inject
void readXml(ResourceProvider provider, String fileName)
{
InputStream webXml = provider.loadResourceStream(fileName);
}
If you know the name of the resource you are loading at development time you
can inject it directly using the @
qualifier.
Resource
If a input stream is loaded, it will be automatically closed when the InputStream goes out of scope. If a URL is used to create an input stream, the application is responsible for closing it. For this reason it is recommended that managed input streams are used where possible.
Resource,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
Properties |
loadPropertiesBundle(String name)
Load a properties bundle.
|
Collection<Properties> |
loadPropertiesBundles(String name)
Load all properties bundles known to the resource loader by name.
|
URL |
loadResource(String name)
Load a resource.
|
Collection<URL> |
loadResources(String name)
Load all resources known to the resource loader by name.
|
Collection<InputStream> |
loadResourcesStreams(String name)
Load all resources known to the resource loader by name.
|
InputStream |
loadResourceStream(String name)
Load a resource.
|
public InputStream loadResourceStream(String name)
Load a resource.
The resource loaders will be searched in precedence order, the first result found being returned. The default search order is:
However extensions may extend this list.
name - the resource to loadnull if no resource can be loadedRuntimeException - if an error occurs loading the resourcepublic Collection<InputStream> loadResourcesStreams(String name)
Load all resources known to the resource loader by name.
By default, Solder will search:
However extensions may extend this list.
name - the resource to loadRuntimeException - if an error occurs loading the resourcepublic URL loadResource(String name)
Load a resource.
The resource loaders will be searched in precedence order, the first result found being returned. The default search order is:
However extensions may extend this list.
name - the resource to loadnull if no
resource can be loadedRuntimeException - if an error occurs loading the resourcepublic Collection<URL> loadResources(String name)
Load all resources known to the resource loader by name.
By default, Solder will search:
However extensions may extend this list.
name - the resource to loadRuntimeException - if an error occurs loading the resourcepublic Properties loadPropertiesBundle(String name)
Load a properties bundle.
The resource loaders will be searched in precedence order, the first result found being returned. The default search order is:
However extensions may extend this list.
name - the name of the properties bundle to loadRuntimeException - if an error occurs loading the resourcepublic Collection<Properties> loadPropertiesBundles(String name)
Load all properties bundles known to the resource loader by name.
By default, Solder will search:
However extensions may extend this list.
name - the name of the properties bundle to loadRuntimeException - if an error occurs loading the properties bundleCopyright © 2012 Seam Framework. All Rights Reserved.