Nux 1.6

nux.xom.pool
Interface ResourceResolver


public interface ResourceResolver

Returns an input stream for a given named resource, for example a path or URL or some other form of identifier. Thus, a resource might be read from the web, a classpath, a jar file, a war file, a JDBC database, a JNDI context/data source, or similar.

An implementation might use ClassLoader.getResourceAsStream(String) or Class.getResourceAsStream(String) or ServletContext.getResourceAsStream(String) or a combination of these approaches, as deemed appropriate for the application-specific deployment/container environment, for example as follows:

 ResourceResolver myResolver = new ResourceResolver() {
     public InputStream getResourceAsStream(String resourceName) {
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         if (loader == null) { // there may not be a context class loader
             loader = MyClazz.class.getClassLoader();
         }
         return loader.getResourceAsStream(resourceName);
     }
 };
 
Here is some related help.

Author:
whoschek.AT.lbl.DOT.gov, $Author: hoschek3 $

Method Summary
 InputStream getResourceAsStream(String resourceName)
          Returns an input stream for reading the specified resource.
 

Method Detail

getResourceAsStream

InputStream getResourceAsStream(String resourceName)
                                throws IOException
Returns an input stream for reading the specified resource.

Parameters:
resourceName - the resource name (e.g. a path or URL or some other form of identifier)
Returns:
An input stream for reading the resource, or null if the resource could not be found
Throws:
IOException - if an I/O error occurred

Nux 1.6