javawebparts.servlet
Class ResourceStreamFromURL

java.lang.Object
  |
  +--javawebparts.servlet.ResourceStreamFromURL
All Implemented Interfaces:
ResourceStream

public class ResourceStreamFromURL
extends java.lang.Object
implements ResourceStream

This conrete implementation of the ResourceStream interface is used to serve resources from a URL, either local or remote. Note that this implementation assumes the content type is set either using the value of the defaultContentType init parameter of the ResourceServerServlet, or via mapping file, so null is returned by getContentType().

Note that it is the developer's responsibility to ensure that the request parameter used to indicate the URL to retreive from is URL-encoding!

For this implementation, streamParam1 is the proxyHost, if needed, and streamParam2 is the proxyPort, if needed. Leave them blank or leave them out entirely if no proxy is required. Both are always required is a proxy is in use though!

Author:
Frank W. Zammetti.

Field Summary
private static org.apache.commons.logging.Log log
          Log instance.
 
Constructor Summary
ResourceStreamFromURL()
           
 
Method Summary
 java.lang.String getContentType(java.lang.String inRequestedResource, java.lang.String inParam1, java.lang.String inParam2, javax.servlet.ServletContext inServletContext)
          This implementation assumes the content type is set either using the value of the defaultContentType init parameter of the ResourceServerServlet, or via mapping file, so null is returned by getContentType().
 java.io.InputStream getStream(java.lang.String inRequestedResource, java.lang.String inParam1, java.lang.String inParam2, javax.servlet.ServletContext inServletContext)
          getStream() is the method that returns the InputStream to the resource to to be served.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log instance.

Constructor Detail

ResourceStreamFromURL

public ResourceStreamFromURL()
Method Detail

getStream

public java.io.InputStream getStream(java.lang.String inRequestedResource,
                                     java.lang.String inParam1,
                                     java.lang.String inParam2,
                                     javax.servlet.ServletContext inServletContext)
getStream() is the method that returns the InputStream to the resource to to be served.

Specified by:
getStream in interface ResourceStream
Parameters:
inRequestedResource - This is the resource that is being requested. This should be a path specifier WITHOUT leading slash.
inParam1 - First arbitrary parameter from web.xml.
inParam2 - Second arbitrary parameter from web.xml.
inServletContext - The ServletContext of the calling ResourceServerServlet.
Returns:
An InputStream on the resource to be served.

getContentType

public java.lang.String getContentType(java.lang.String inRequestedResource,
                                       java.lang.String inParam1,
                                       java.lang.String inParam2,
                                       javax.servlet.ServletContext inServletContext)
This implementation assumes the content type is set either using the value of the defaultContentType init parameter of the ResourceServerServlet, or via mapping file, so null is returned by getContentType().

Specified by:
getContentType in interface ResourceStream
Parameters:
inRequestedResource - This is the resource that is being requested. This should be a path specifier WITHOUT leading slash.
inParam1 - First arbitrary parameter from web.xml.
inParam2 - Second arbitrary parameter from web.xml.
inServletContext - The ServletContext of the calling ResourceServerServlet.
Returns:
The content type of the resource, null in this case.


Copyright © 2005 Frank W. Zammetti