org.jboss.seam.solder.resourceLoader
Class ResourceLoaderManager

java.lang.Object
  extended by org.jboss.seam.solder.resourceLoader.ResourceLoaderManager

public class ResourceLoaderManager
extends Object

ResourceLoaderManager discovers and instantiates all ResourceLoaders defined. It also provides accesss to these resources, either as URLs or InputStreams.

If you are working in a CDI managed environment, you should use ResourceProvider instead, as it provides automatic, contextual management of resources. If you are outside a CDI managed environment, then instantiating ResourceLoaderManager provides access to the same resources.

Author:
Pete Muir, Stuart Douglas
See Also:
ResourceLoader, ResourceProvider

Constructor Summary
ResourceLoaderManager()
          Instantiate a new instance, loading any resource loaders from the service loader, and sorting them by precedence.
 
Method Summary
 Properties getPropertiesBundle(String name)
           Load a properties bundle by name.
 Collection<Properties> getPropertiesBundles(String name)
           Load all properties bundles known to the resource loader by name.
 URL getResource(String name)
           Load a resource by name.
 InputStream getResourceAsStream(String name)
           Load a resource by name.
 Iterable<ResourceLoader> getResourceLoaders()
          The discovered ResourceLoader instances.
 Collection<URL> getResources(String name)
           Load all resources known to the resource loader by name.
 Collection<InputStream> getResourcesAsStream(String name)
           Load all resources known to the resource loader by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLoaderManager

public ResourceLoaderManager()
Instantiate a new instance, loading any resource loaders from the service loader, and sorting them by precedence.

Method Detail

getResourceLoaders

public Iterable<ResourceLoader> getResourceLoaders()
The discovered ResourceLoader instances.

Returns:
the resource loaders

getResource

public URL getResource(String name)

Load a resource by name.

The resource loaders will be searched in precedence order, the first result found being returned.

Parameters:
name - the resource to load
Returns:
a URL pointing to the resource, or null if no resource can be loaded
Throws:
RuntimeException - if an error occurs loading the resource

getPropertiesBundle

public Properties getPropertiesBundle(String name)

Load a properties bundle by name.

The resource loaders will be searched in precedence order, the first result found being returned.

Parameters:
name - the name of the properties bundle to load
Returns:
a set of properties, or an empty set if no properties bundle can be loaded
Throws:
RuntimeException - if an error occurs loading the properties bundle

getPropertiesBundles

public Collection<Properties> getPropertiesBundles(String name)

Load all properties bundles known to the resource loader by name.

Parameters:
name - the name of the properties bundle to load
Returns:
a collection of properties bundles pointing to the resources, or an empty collection if no resources are found
Throws:
RuntimeException - if an error occurs loading the properties bundles

getResourceAsStream

public InputStream getResourceAsStream(String name)

Load a resource by name.

The resource loaders will be searched in precedence order, the first result found being returned.

Parameters:
name - the resource to load
Returns:
an InputStream providing access to the resource, or null if no resource can be loaded
Throws:
RuntimeException - if an error occurs loading the resource

getResources

public Collection<URL> getResources(String name)

Load all resources known to the resource loader by name.

Parameters:
name - the resource to load
Returns:
a collection of URLs pointing to the resources, or an empty collection if no resources are found
Throws:
RuntimeException - if an error occurs loading the resource

getResourcesAsStream

public Collection<InputStream> getResourcesAsStream(String name)

Load all resources known to the resource loader by name.

Parameters:
name - the resource to load
Returns:
a collection of input streams pointing to the resources, or an empty collection if no resources are found
Throws:
RuntimeException - if an error occurs loading the resource


Copyright © 2008-2010 Seam Framework. All Rights Reserved.