com.primix.tapestry.asset
Class AssetService

java.lang.Object
  |
  +--com.primix.tapestry.engine.AbstractService
        |
        +--com.primix.tapestry.asset.AssetService
All Implemented Interfaces:
IEngineService

public class AssetService
extends AbstractService

A service for building URLs to and accessing IAssets. Most of the work is deferred to the IAsset instance.

The retrieval part is directly linked to PrivateAsset. The service responds to a URL that encodes the path of a resource within the classpath. The service(IRequestCycle, ResponseOutputStream) method reads the resource and streams it out.

TBD: Security issues. Should only be able to retrieve a resource that was previously registerred in some way ... otherwise, hackers will be able to suck out the .class files of the application!

Version:
$Id: AssetService.java,v 1.7 2001/08/07 20:12:27 hship Exp $
Author:
Howard Ship

Fields inherited from class com.primix.tapestry.engine.AbstractService
buffer
 
Fields inherited from interface com.primix.tapestry.IEngineService
ACTION_SERVICE, ASSET_SERVICE, CONTEXT_QUERY_PARMETER_NAME, DIRECT_SERVICE, HOME_SERVICE, PAGE_SERVICE, PARAMETERS_QUERY_PARAMETER_NAME, RESET_SERVICE, RESTART_SERVICE, SERVICE_QUERY_PARAMETER_NAME
 
Constructor Summary
AssetService(IEngine engine)
           
 
Method Summary
 Gesture buildGesture(IRequestCycle cycle, IComponent component, java.lang.String[] parameters)
          Builds a Gesture for a PrivateAsset.
 java.lang.String getName()
          Returns the name of the service.
 boolean service(IRequestCycle cycle, ResponseOutputStream output)
          Retrieves a resource from the classpath and returns it to the client in a binary output stream.
 
Methods inherited from class com.primix.tapestry.engine.AbstractService
assembleGesture, getBuffer, getParameters, getServiceContext, getSplitter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssetService

public AssetService(IEngine engine)
Method Detail

buildGesture

public Gesture buildGesture(IRequestCycle cycle,
                            IComponent component,
                            java.lang.String[] parameters)
Builds a Gesture for a PrivateAsset.

A single parameter is expected, the resource path of the asset (which is expected to start with a leading slash).

Following copied from interface: com.primix.tapestry.IEngineService
Parameters:
cycle - Defines the request cycle being processed.
component - The component requesting the URL.
parameters - Additional parameters specific to the component requesting the Gesture.

getName

public java.lang.String getName()
Description copied from interface: IEngineService
Returns the name of the service.

service

public boolean service(IRequestCycle cycle,
                       ResponseOutputStream output)
                throws ServletException,
                       java.io.IOException,
                       RequestCycleException
Retrieves a resource from the classpath and returns it to the client in a binary output stream.

TBD: Security issues. Hackers can download .class files.

TBD: Error handling. What to do if an IOException is thrown, or the resource doesn't exist? Typically, we're downloading an image file and there's no way to communicate the error back to the client web browser.

Following copied from interface: com.primix.tapestry.IEngineService
See Also:
IEngine.service(RequestContext)