org.apache.tapestry.asset
Class AssetService

java.lang.Object
  |
  +--org.apache.tapestry.asset.AssetService
All Implemented Interfaces:
IEngineService

public class AssetService
extends java.lang.Object
implements IEngineService

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

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!

Author:
Howard Lewis Ship

Constructor Summary
AssetService()
           
 
Method Summary
 ILink getLink(IRequestCycle cycle, java.lang.Object parameter)
          Builds a ILinkfor a PrivateAsset.
 java.lang.String getName()
          Returns the name of the service.
 void service(IRequestCycle cycle, ResponseOutputStream output)
          Retrieves a resource from the classpath and returns it to the client in a binary output stream.
 void setAssetExternalizer(AssetExternalizer assetExternalizer)
           
 void setClassResolver(org.apache.hivemind.ClassResolver classResolver)
           
 void setExceptionReporter(RequestExceptionReporter exceptionReporter)
           
 void setLinkFactory(LinkFactory linkFactory)
           
 
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,
                     java.lang.Object parameter)
Builds a ILinkfor a PrivateAsset.

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

Specified by:
getLink in interface IEngineService
Parameters:
cycle - Defines the request cycle being processed.
parameter - An object that provide any additional information needed by the service. Each service implementation will expect that an object of the proper type be passed in. In some cases, a simple String will do; in others, a specific object (possibly implementing an interface) will be required.
Returns:
The URL for the service. The URL will have to be encoded via HttpServletResponse.encodeURL(java.lang.String).

getName

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

Specified by:
getName in interface IEngineService

service

public void service(IRequestCycle cycle,
                    ResponseOutputStream output)
             throws javax.servlet.ServletException,
                    java.io.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.

Specified by:
service in interface IEngineService
Parameters:
cycle - the incoming request
output - stream to which output should ultimately be directed
javax.servlet.ServletException
java.io.IOException
See Also:
IEngine.service(org.apache.tapestry.request.RequestContext)

setExceptionReporter

public void setExceptionReporter(RequestExceptionReporter exceptionReporter)
Since:
3.1

setAssetExternalizer

public void setAssetExternalizer(AssetExternalizer assetExternalizer)
Since:
3.1

setLinkFactory

public void setLinkFactory(LinkFactory linkFactory)
Since:
3.1

setClassResolver

public void setClassResolver(org.apache.hivemind.ClassResolver classResolver)
Since:
3.1