Milyn-Commons Version 0.6

org.milyn.resource
Class ServletResourceLocator

java.lang.Object
  extended byorg.milyn.resource.ServletResourceLocator
All Implemented Interfaces:
ContainerResourceLocator, ExternalResourceLocator

public class ServletResourceLocator
extends java.lang.Object
implements ContainerResourceLocator

Servlet resource locator.

Author:
tfennelly

Constructor Summary
ServletResourceLocator(javax.servlet.ServletConfig config, ExternalResourceLocator externalResourceLocator)
          Public constructor.
 
Method Summary
 java.io.InputStream getResource(java.lang.String uri)
          Get a resource stream through the Servlet container.
 java.io.InputStream getResource(java.lang.String configName, java.lang.String defaultUri)
          Get a resource stream through the Servlet container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletResourceLocator

public ServletResourceLocator(javax.servlet.ServletConfig config,
                              ExternalResourceLocator externalResourceLocator)
Public constructor.

Parameters:
config - The ServletConfig instance.
externalResourceLocator - Resource locator for resources outside the Servlet context.
Method Detail

getResource

public java.io.InputStream getResource(java.lang.String configName,
                                       java.lang.String defaultUri)
                                throws java.lang.IllegalArgumentException,
                                       java.io.IOException
Get a resource stream through the Servlet container.

If a Servlet configuration (see ServletParamUtils.getParameterValue(String, ServletConfig)) exists for "configName" the method uses use the config value, otherwise it use the "defaultUri" value provided. Calls getResource(String) to get the resource stream.

Specified by:
getResource in interface ContainerResourceLocator
Parameters:
configName - The container configuration entry name whose value specifies the location of the resource.
defaultUri - The default location for the resource.
Returns:
The InputStream associated with resource.
Throws:
java.io.IOException - Unable to get the resource stream.
java.lang.IllegalArgumentException - Illegal argument. Check the cause exception for more information.

getResource

public java.io.InputStream getResource(java.lang.String uri)
                                throws java.lang.IllegalArgumentException,
                                       java.io.IOException
Get a resource stream through the Servlet container.

Loads the resource through the first successfull call of:

Specified by:
getResource in interface ExternalResourceLocator
Parameters:
uri - The location of the resource to be located.
Returns:
The InputStream associated with the org.milyn.resource.
Throws:
java.lang.IllegalArgumentException - Illegal argument. Check the cause exception for more information.
java.io.IOException - Unable to get the org.milyn.resource stream.

Milyn-Commons Version 0.6