StreamService

Description

Acts together with the StreamLink component and StreamAsset by dispatcing requests from links produced by StreamLinks and StreamAssets to an implementation of StreamResourceSource . Stream resources resolved like this are streamed direct to client with the specified content type and content disposition.

This service is perfect for downloading/streaming pdf files, images, csv files or other resources, as the content disposition can be set for the browser to act upon it.

Required Configuration

This service needs to have somewhere to lookup the resources that can be streamed. Each incoming link to this service can have parameters, which is passed on to an extension implementing StreamResourceSource . These parameters can be used to look up the resource to stream.

In the Tapestry application which uses this service you must define an extension like this:

<extension name="bayeux.stream.resourcesource"
           class="com.foo.bar.YourImplementationOfStreamResourceSource"/>
                

Where the "com.foo.bar.YourImplementationOfStreamResourceSource" is a class of your application which implements the StreamResourceSource interface.

Tapestry bayeux comes with a abstract default implementation of the StreamResourceSource inteface.

The default implementation requires a InputStream getResourceAsStream() method to be implemented. (just as the deprecated DownloadResourceSource did) but handles the writing to the outout stream.

In many cases this is what is needed.

Note: For your stream extentions to be seen you have to prefix it with ' bayeux.stream '. like this:

<extension name="bayeux.stream.<your-extention-name>"
           class="com.foo.bar.YourImplementationOfStreamResourceSource"/>
                    

Example

The StreamService is most likely not used alone but together with the StreamLink and StreamAsset, but in some cases it can be useful to have the StreamService injected into a page or a component. You can do that by inserting the following in a specification file for the component or page.
<inject property="streamService" object="service:com.nordija.tapestry.bayeux.StreamService"/>