You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jack <jr...@gmail.com> on 2011/09/05 11:58:59 UTC

[5.2.6] Advising the PageLoader Service

Hi All,
I'm trying to advise the PageLoader service because we have some custom 
page caching requirements. I've tried the following but it doesn't seem 
to get invoked. Is it even possible to advise this service? If so can 
anyone tell me what I'm doing wrong?

     @Advise(serviceInterface = ComponentAssemblerSource.class)
     @Match("PageLoader")
     public static void siteKeyPageCache(MethodAdviceReceiver receiver) {
         MethodAdvice advice = new MethodAdvice() {
             public void advise(Invocation invocation) {
                 ...
             }
         };
     }

Many thanks,

Jack

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


Re: [5.2.6] Advising the PageLoader Service

Posted by jack <jr...@gmail.com>.
Hi Jens,

Thanks for your suggestions but the caching I'm referring to is the 
inbuilt cache Tapestry uses for the ComponentAssemblers. Currently (or 
in 5.2.6) it caches these ComponentAssemblers based on classname and 
Locale.

I need to cache these based on classname, locale and another-key. This 
is because I have different Components that get rendered based on 
another-key.

Specifically I want to advise the methods:

     getAssembler(String className, Locale locale)
     void objectWasInvalidated()

and replace the caching with my own.

Hope that makes sense. It feels like I should be able to advise these 
service methods but as I said my advice is not getting invoked. Any ideas?

Thanks,

Jack


On 05/09/11 12:10, Jens Breitenstein wrote:
> Hi Jack!
>
>
> I wonder what kind of page data you want to cache which is not 
> provideable by a service?
>
> a) why not using a spring singleton or a plain java static?
>
> b) You can bind a service implementation (without interface) in your 
> app module and inject it to your page if you're not using a spring 
> service layer, for example.
>
> c) in case your data is considerably volatile you can try something 
> like OSCache?
>
> d) Hopefully I am correct, but in case you write something like this 
> in your page class:
>
>     private final YourType _var = whatEverService.getData();
>
>     the call to getData() is only excuted once (first time your page 
> is ever used).
>
>
> Sorry I did not exactly answer your question, but maybe moving the 
> code to a service (away from the page class itself) will also solve 
> your problem without advising the PageLoader and a chance for a cache 
> related unit test?
>
> Jens
>
>
>
>
>
>
> Am 05.09.11 11:58, schrieb jack:
>> Hi All,
>> I'm trying to advise the PageLoader service because we have some 
>> custom page caching requirements. I've tried the following but it 
>> doesn't seem to get invoked. Is it even possible to advise this 
>> service? If so can anyone tell me what I'm doing wrong?
>>
>>     @Advise(serviceInterface = ComponentAssemblerSource.class)
>>     @Match("PageLoader")
>>     public static void siteKeyPageCache(MethodAdviceReceiver receiver) {
>>         MethodAdvice advice = new MethodAdvice() {
>>             public void advise(Invocation invocation) {
>>                 ...
>>             }
>>         };
>>     }
>>
>> Many thanks,
>>
>> Jack
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: [5.2.6] Advising the PageLoader Service

Posted by Jens Breitenstein <ma...@j-b-s.de>.
Hi Jack!


I wonder what kind of page data you want to cache which is not 
provideable by a service?

a) why not using a spring singleton or a plain java static?

b) You can bind a service implementation (without interface) in your app 
module and inject it to your page if you're not using a spring service 
layer, for example.

c) in case your data is considerably volatile you can try something like 
OSCache?

d) Hopefully I am correct, but in case you write something like this in 
your page class:

     private final YourType _var = whatEverService.getData();

     the call to getData() is only excuted once (first time your page is 
ever used).


Sorry I did not exactly answer your question, but maybe moving the code 
to a service (away from the page class itself) will also solve your 
problem without advising the PageLoader and a chance for a cache related 
unit test?

Jens






Am 05.09.11 11:58, schrieb jack:
> Hi All,
> I'm trying to advise the PageLoader service because we have some 
> custom page caching requirements. I've tried the following but it 
> doesn't seem to get invoked. Is it even possible to advise this 
> service? If so can anyone tell me what I'm doing wrong?
>
>     @Advise(serviceInterface = ComponentAssemblerSource.class)
>     @Match("PageLoader")
>     public static void siteKeyPageCache(MethodAdviceReceiver receiver) {
>         MethodAdvice advice = new MethodAdvice() {
>             public void advise(Invocation invocation) {
>                 ...
>             }
>         };
>     }
>
> Many thanks,
>
> Jack
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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