org.apache.tapestry.asset
Class AssetService

java.lang.Object
  extended by org.apache.tapestry.engine.AbstractService
      extended by org.apache.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(IEngineServiceView, 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 244183 2005-03-21 19:30:48Z pferraro $
Author:
Howard Lewis Ship

Constructor Summary
AssetService()
           
 
Method Summary
 ILink getLink(IRequestCycle cycle, IComponent component, Object[] parameters)
          Builds a ILink for a PrivateAsset.
 String getName()
          Returns the name of the service.
 void service(IEngineServiceView engine, 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 org.apache.tapestry.engine.AbstractService
constructLink, getParameters, getServiceContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssetService

public AssetService()
Method Detail

getLink

public ILink getLink(IRequestCycle cycle,
                     IComponent component,
                     Object[] parameters)
Builds a ILink for a PrivateAsset.

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

Parameters:
cycle - Defines the request cycle being processed.
component - The component requesting the URL. Generally, the service context is established from the component.
parameters - Additional parameters specific to the component requesting the EngineServiceLink.
Returns:
The URL for the service. The URL will have to be encoded via HttpServletResponse.encodeURL(java.lang.String).

getName

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


service

public void service(IEngineServiceView engine,
                    IRequestCycle cycle,
                    ResponseOutputStream output)
             throws IOException
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.

Parameters:
engine - a view of the IEngine with additional methods needed by services
cycle - the incoming request
output - stream to which output should ultimately be directed
Throws:
IOException
See Also:
IEngine.service(org.apache.tapestry.request.RequestContext)