You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Santha Kumar <sa...@gmail.com> on 2012/02/03 16:21:55 UTC

Wicket ResourceFinder implementation for resources modified at runtime

I am using wicket 1.5.2. I have implemented a custom IResourceFinder that
locates my wicket template [HTML] files from say "/assets" folder. This
custom resource finder is registered with the application during application
init [getResourceSettings().setResourceFinder(new myCustomResFinder())]. Now
I have a situation where the assets are going to get versioned at runtime,
which means my lookup path should be something like "/assets/1" or
"/assets/2". I am just looking for a way if someone had a similar situation
earlier.

There are a couple of ways I think this can be achieved.

1. Listen to the assert version change event in wicket WebApplication and
create a new instance of my custom resource finder with the new path, and
set it again in ResourceSettings. I think this may be against any assumption
that wicket makes that once WebApplication is initialized, the
ResourceFinder is not going to change. Does wicket assumes that? Or can I go
ahead and change the ResourceFinder anytime I want?

2. My custom resource finder decorates around WebApplicationPath and adds
the path to the decorated WebApplicationPath instance - I have to decorate
this as I determine the path within this resource finder component. Now I
can listen to the asset version change event in my resource finder but I
won't be able to overwrite the existing path in the WebApplicationPath.
WebApplicationPath maintains a private final list of paths. If I need to do
this way, I will end up duplicating the WebApplicationPath code in my custom
resource finder, which I am not really comfortable in doing.

Has any one tried this? Any suggestion?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-ResourceFinder-implementation-for-resources-modified-at-runtime-tp4354878p4354878.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket ResourceFinder implementation for resources modified at runtime

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Fri, Feb 3, 2012 at 5:21 PM, Santha Kumar <sa...@gmail.com> wrote:
> I am using wicket 1.5.2. I have implemented a custom IResourceFinder that
> locates my wicket template [HTML] files from say "/assets" folder. This
> custom resource finder is registered with the application during application
> init [getResourceSettings().setResourceFinder(new myCustomResFinder())]. Now
> I have a situation where the assets are going to get versioned at runtime,
> which means my lookup path should be something like "/assets/1" or
> "/assets/2". I am just looking for a way if someone had a similar situation
> earlier.
>
> There are a couple of ways I think this can be achieved.
>
> 1. Listen to the assert version change event in wicket WebApplication and
> create a new instance of my custom resource finder with the new path, and
> set it again in ResourceSettings. I think this may be against any assumption
> that wicket makes that once WebApplication is initialized, the
> ResourceFinder is not going to change. Does wicket assumes that? Or can I go
> ahead and change the ResourceFinder anytime I want?

This is allowed. The only thing that bothers me is that there is no
synchronization when reading/writing the finder and you may experience
problems like seeing the old assets after assetVersionChanged event
has been fired for some request(s).

>
> 2. My custom resource finder decorates around WebApplicationPath and adds
> the path to the decorated WebApplicationPath instance - I have to decorate
> this as I determine the path within this resource finder component. Now I
> can listen to the asset version change event in my resource finder but I
> won't be able to overwrite the existing path in the WebApplicationPath.
> WebApplicationPath maintains a private final list of paths. If I need to do
> this way, I will end up duplicating the WebApplicationPath code in my custom
> resource finder, which I am not really comfortable in doing.

I think you may use org.apache.wicket.util.file.Path instead of
WebApplicationPath.

And I think WebApplicationPath should extend Path because now they
share common logic...

>
> Has any one tried this? Any suggestion?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-ResourceFinder-implementation-for-resources-modified-at-runtime-tp4354878p4354878.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org