Generally speaking, assets are expected to be static (that is, unchanging)
and global, which is why there's so much caching going on.

I would say that you should implement your own Dispatcher (contributed to
the MasterDispatcher) service and just take control of this, using the same
techniques you might use to server content out of a database. It ends up
being more like a servlet at that point (Dispatcher is very similar to
HttpServlet) and you have control over everything that happens: you control
the cache, the URL format, the works.  With a little bit of effort, you can
probably leverage some of the features of Tapestry's asset pipeline
(minimization, CSS rewriting in 5.4, etc.), by making your data implement
StreamableResource.


On Wed, Apr 17, 2013 at 5:33 PM, Nenad Nikolic <iznenad.niko...@gmail.com>wrote:

> Hello, i'm struggling with delivering a transformed resource for each
> request.
>
> Here is exactly what i mean:
>
> There are two requests expected to hit the app.
> 1) a request containing a unique identifier and some other values as
> request parameters.
> This request will hit a dispatcher which will store the data into
> hazelcast, and render a response which will contain urls to two assets (one
> js one css) with a request parameter (the unique identifier).
> Here is how an example response looks like:
>
> <modifier>
> <javascript>
> <filepath>
>
> http://localhost:8080/app/assets/1.0.0-SNAPSHOT/ccdd/template.nmjs?trid=unique_identifier
> </filepath>
> </javascript>
> <css>
> <filepath>
>
> http://localhost:8080/app/assets/1.0.0-SNAPSHOT/ccdd/template.nmcss?trid=unique_identifier
> </filepath>
> </css>
> </modifier>
>
> This is a machine-to-machine request. The system that made the request will
> give the asset urls to the client when rendering a webpage.
>
> 2) the second request is the one coming from the client. It is a request
> for the actuall assets. It should return the asset but replace the
> placeholders within the asset with values from hazelcast.
> I currently have an AssetHandler mapped to the "ccdd" path.
> In the AssetHandler i get the request parameter and get the values from the
> hazelcast map. Then the values are stored on the environment stack for my
> ResourceTransformer to access. This whole thing is working and i get a
> properly transformed asset for the first request.
>
> My problem is that when the unique identifier changes the resource is not
> transformed again.
>
> So my questions are:
>
> Is it possible to cache resources selectively?
> Am i doing this in a completely shitty way?
>
> I hope that my explanation is understandable. Thx in advance for any
> responses!
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

Reply via email to