org.milyn.resource
Class ServletResourceLocator

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

public class ServletResourceLocator
extends Object
implements ContainerResourceLocator

Servlet resource locator.

Author:
tfennelly

Constructor Summary
ServletResourceLocator(javax.servlet.ServletConfig config, ExternalResourceLocator externalResourceLocator)
          Public constructor.
 
Method Summary
 URI getBaseURI()
          Get the base URI for the locator instance.
 InputStream getResource(String uri)
          Get a resource stream through the Servlet container.
 InputStream getResource(String configName, 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 InputStream getResource(String configName,
                               String defaultUri)
                        throws IllegalArgumentException,
                               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:
IllegalArgumentException - Illegal argument. Check the cause exception for more information.
IOException - Unable to get the resource stream.

getResource

public InputStream getResource(String uri)
                        throws IllegalArgumentException,
                               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:
IllegalArgumentException - Illegal argument. Check the cause exception for more information.
IOException - Unable to get the org.milyn.resource stream.

getBaseURI

public URI getBaseURI()
Description copied from interface: ContainerResourceLocator
Get the base URI for the locator instance.

Specified by:
getBaseURI in interface ContainerResourceLocator
Returns:
The base URI for the locator instance.


Copyright © 2018. All rights reserved.