|
Nux 1.6 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
Method Summary | |
---|---|
InputStream |
getResourceAsStream(String resourceName)
Returns an input stream for reading the specified resource. |
Method Detail |
---|
InputStream getResourceAsStream(String resourceName) throws IOException
resourceName
- the resource name (e.g. a path or URL or some other form of
identifier)
null
if the resource could not be found
IOException
- if an I/O error occurred
|
Nux 1.6 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |