org.apache.tapestry.asset
Class AssetService

java.lang.Object
  extended by org.apache.tapestry.asset.AssetService
All Implemented Interfaces:
IEngineService

public class AssetService
extends 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) 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

Field Summary
static String DIGEST
          Query parameter that stores the digest for the file; this is used to authenticate that the client is allowed to access the file.
static String PATH
          Query parameter that stores the path to the resource (with a leading slash).
 
Constructor Summary
AssetService()
           
 
Method Summary
 ILink getLink(boolean post, Object parameter)
          Builds a ILinkfor a PrivateAsset.
 String getName()
          Returns the name of the service.
 void service(IRequestCycle cycle)
          Retrieves a resource from the classpath and returns it to the client in a binary output stream.
 void setClassResolver(org.apache.hivemind.ClassResolver classResolver)
           
 void setContext(WebContext context)
           
 void setDigestSource(ResourceDigestSource md5Source)
           
 void setExceptionReporter(RequestExceptionReporter exceptionReporter)
           
 void setLinkFactory(LinkFactory linkFactory)
           
 void setLog(Log log)
           
 void setRequest(WebRequest request)
           
 void setResponse(WebResponse response)
           
 void setUnprotectedMatcher(ResourceMatcher matcher)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH

public static final String PATH
Query parameter that stores the path to the resource (with a leading slash).

Since:
4.0
See Also:
Constant Field Values

DIGEST

public static final String DIGEST
Query parameter that stores the digest for the file; this is used to authenticate that the client is allowed to access the file.

Since:
4.0
See Also:
Constant Field Values
Constructor Detail

AssetService

public AssetService()
Method Detail

getLink

public ILink getLink(boolean post,
                     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:
post - if true, then the link will be used for a post (not a get, i.e., for a HTML form); this may affect what information is encoded into the link
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 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)
             throws IOException
Retrieves a resource from the classpath and returns it to the client in a binary output stream.

Specified by:
service in interface IEngineService
Parameters:
cycle - the incoming request
Throws:
IOException

setExceptionReporter

public void setExceptionReporter(RequestExceptionReporter exceptionReporter)
Since:
4.0

setLinkFactory

public void setLinkFactory(LinkFactory linkFactory)
Since:
4.0

setClassResolver

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

setContext

public void setContext(WebContext context)
Since:
4.0

setResponse

public void setResponse(WebResponse response)
Since:
4.0

setDigestSource

public void setDigestSource(ResourceDigestSource md5Source)
Since:
4.0

setRequest

public void setRequest(WebRequest request)
Since:
4.0

setUnprotectedMatcher

public void setUnprotectedMatcher(ResourceMatcher matcher)
Since:
4.1

setLog

public void setLog(Log log)


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.