You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Otho <ta...@googlemail.com> on 2008/08/13 22:30:19 UTC

[T5] Two RequestFilters in application module possible?

Hi all!
I want two contribute a second requestfilter alongside the timing filter in
application module. But unfortunately this doesn't work with an anonymous
definition (like the timing filter)  and a contribution to RequestHandler
nor does it work with a written out interface/class pair contributet via the
bind mechanism. In the latter case the error message is like this:

HTTP ERROR: 500

Exception constructing service 'RequestHandler': Error invoking service
builder method
org.apache.tapestry5.services.TapestryModule.buildRequestHandler(Logger,
List, Dispatcher) (at TapestryModule.java:970) (for service
'RequestHandler'): Error invoking service contribution method
org.example.animaltips.services.AtModule.contributeRequestHandler(OrderedConfiguration,
RequestFilter): Unable to locate a single service assignable to type
org.apache.tapestry5.services.RequestFilter with marker annotation(s)
org.apache.tapestry5.ioc.annotations.Local.  All of the following services
match: org.example.animaltips.services.AtModule.buildTimingFilter(Logger)
(at AtModule.java:63),
org.example.animaltips.services.UserActivityFilterImpl() (at
UserActivityFilterImpl.java:24).

In the former case it also complains about 2 classes implementing the
RequestFilter interface.

My own filter works flawlessly when I comment out the timing filter
contribution. But for the time being I want to have both. Is there any way
to do this easily?

Regards,
Otho

Re: [T5] Two RequestFilters in application module possible?

Posted by Otho <ta...@googlemail.com>.
Thanks a lot again!

I'll try that out.

Regards,
Otho

Re: [T5] Two RequestFilters in application module possible?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi,

Glad it worked.

I have something similar in my application, but instead of using a 
RequestFilter I use a PageRenderRequestFilter.

This is only called for pages and has the added benefit of giving you 
easy access to the page name, parameters, etc.

There's something similar for component events, 
ComponentEventRequestFilter, in case you'll ever need that, by the way.

-Filip

On 2008-08-14 10:05, Otho wrote:
> Thank you very much  for the answer. Works perfectly!
> 
> But this brought up a new question. The UserActivityFilter is used to track
> a users last activity to check for "active users at the moment". The
> simplistic approach I use at the moment updates a database table with a
> reference to user and a timestamp. Using a requestfilter then obviously
> leads to a lot of database roundtrips per user-activity, since every asset
> triggers the filter.
> 
> How would you track useractivity in a real world application? A resolution
> of about 1 minute would suffice, but it shouldn't be much above that.
> 
> 
> Regards,
> Otho
> 

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


Re: [T5] Two RequestFilters in application module possible?

Posted by Sven Homburg <ho...@googlemail.com>.
i wrote a short documentation how to use the scheduler service

http://212.202.126.8:8080/chenillekit/chenillekit-quartz/index.html

i hope its helps someone

2008/8/14 Sven Homburg <ho...@googlemail.com>

> chenillkit has a ready quartz module.
> it works for two of my customers.
>
> the only snag is the outstanding documentation.
> i hope that i find some minutes to do that this week
>
> 2008/8/14 Robert Zeigler <ro...@scazdl.org>
>
> you could use a dispatcher instead of a request filter, inserted after the
>> asset dispatcher.
>> That way, only non-asset requests trigger the db update.
>>
>> You could adapt your filter to only fire the update on non-asset requests
>> by explicitly checking the url (for matching patterns, for instance:
>> ^.*\.png$ and so forth).
>>
>> You could have a separate thread that does the update.  Then you have a
>> service (which, naturally, will have to be threadsafe) that your request
>> filter calls into to record all of the updates (multiple updates from the
>> same user within the given timespan could be consolidated into a single
>> update).  The separate thread asks this service for the pool of changes on a
>> regular basis (Quartz package would be useful here) and commits them.
>>
>> There are other ways you could accomplish this, as well.
>>
>> If you're interested in using a Quartz-based solution, it looks like
>> chenillekit is planning on adding it at some point (they have a quartz
>> module, but it doesn't look like there's actually any code in there yet).
>> Alternatively, I wrote an integration module for TapestryQuartz that you're
>> welcome to use (contact me off list).  I'll be releasing it for general use
>> at some point, but I need to refine the documentation for it.
>>
>> Robert
>>
>>
>>
>> On Aug 14, 2008, at 8/143:05 AM , Otho wrote:
>>
>>  Thank you very much  for the answer. Works perfectly!
>>>
>>> But this brought up a new question. The UserActivityFilter is used to
>>> track
>>> a users last activity to check for "active users at the moment". The
>>> simplistic approach I use at the moment updates a database table with a
>>> reference to user and a timestamp. Using a requestfilter then obviously
>>> leads to a lot of database roundtrips per user-activity, since every
>>> asset
>>> triggers the filter.
>>>
>>> How would you track useractivity in a real world application? A
>>> resolution
>>> of about 1 minute would suffice, but it shouldn't be much above that.
>>>
>>>
>>> Regards,
>>> Otho
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> with regards
> Sven Homburg
> http://www.chenillekit.org
> http://tapestry5-components.googlecode.com
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: [T5] Two RequestFilters in application module possible?

Posted by Robert Zeigler <ro...@scazdl.org>.
Good to know.
I just didn't see any code in the repository. ;)

Robert

On Aug 14, 2008, at 8/1411:05 AM , Sven Homburg wrote:

> chenillkit has a ready quartz module.
> it works for two of my customers.
>
> the only snag is the outstanding documentation.
> i hope that i find some minutes to do that this week
>
> 2008/8/14 Robert Zeigler <ro...@scazdl.org>
>
>> you could use a dispatcher instead of a request filter, inserted  
>> after the
>> asset dispatcher.
>> That way, only non-asset requests trigger the db update.
>>
>> You could adapt your filter to only fire the update on non-asset  
>> requests
>> by explicitly checking the url (for matching patterns, for instance:
>> ^.*\.png$ and so forth).
>>
>> You could have a separate thread that does the update.  Then you  
>> have a
>> service (which, naturally, will have to be threadsafe) that your  
>> request
>> filter calls into to record all of the updates (multiple updates  
>> from the
>> same user within the given timespan could be consolidated into a  
>> single
>> update).  The separate thread asks this service for the pool of  
>> changes on a
>> regular basis (Quartz package would be useful here) and commits them.
>>
>> There are other ways you could accomplish this, as well.
>>
>> If you're interested in using a Quartz-based solution, it looks like
>> chenillekit is planning on adding it at some point (they have a  
>> quartz
>> module, but it doesn't look like there's actually any code in there  
>> yet).
>> Alternatively, I wrote an integration module for TapestryQuartz  
>> that you're
>> welcome to use (contact me off list).  I'll be releasing it for  
>> general use
>> at some point, but I need to refine the documentation for it.
>>
>> Robert
>>
>>
>>
>> On Aug 14, 2008, at 8/143:05 AM , Otho wrote:
>>
>> Thank you very much  for the answer. Works perfectly!
>>>
>>> But this brought up a new question. The UserActivityFilter is used  
>>> to
>>> track
>>> a users last activity to check for "active users at the moment". The
>>> simplistic approach I use at the moment updates a database table  
>>> with a
>>> reference to user and a timestamp. Using a requestfilter then  
>>> obviously
>>> leads to a lot of database roundtrips per user-activity, since  
>>> every asset
>>> triggers the filter.
>>>
>>> How would you track useractivity in a real world application? A  
>>> resolution
>>> of about 1 minute would suffice, but it shouldn't be much above  
>>> that.
>>>
>>>
>>> Regards,
>>> Otho
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> -- 
> with regards
> Sven Homburg
> http://www.chenillekit.org
> http://tapestry5-components.googlecode.com


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


Re: [T5] Two RequestFilters in application module possible?

Posted by Sven Homburg <ho...@googlemail.com>.
chenillkit has a ready quartz module.
it works for two of my customers.

the only snag is the outstanding documentation.
i hope that i find some minutes to do that this week

2008/8/14 Robert Zeigler <ro...@scazdl.org>

> you could use a dispatcher instead of a request filter, inserted after the
> asset dispatcher.
> That way, only non-asset requests trigger the db update.
>
> You could adapt your filter to only fire the update on non-asset requests
> by explicitly checking the url (for matching patterns, for instance:
> ^.*\.png$ and so forth).
>
> You could have a separate thread that does the update.  Then you have a
> service (which, naturally, will have to be threadsafe) that your request
> filter calls into to record all of the updates (multiple updates from the
> same user within the given timespan could be consolidated into a single
> update).  The separate thread asks this service for the pool of changes on a
> regular basis (Quartz package would be useful here) and commits them.
>
> There are other ways you could accomplish this, as well.
>
> If you're interested in using a Quartz-based solution, it looks like
> chenillekit is planning on adding it at some point (they have a quartz
> module, but it doesn't look like there's actually any code in there yet).
> Alternatively, I wrote an integration module for TapestryQuartz that you're
> welcome to use (contact me off list).  I'll be releasing it for general use
> at some point, but I need to refine the documentation for it.
>
> Robert
>
>
>
> On Aug 14, 2008, at 8/143:05 AM , Otho wrote:
>
>  Thank you very much  for the answer. Works perfectly!
>>
>> But this brought up a new question. The UserActivityFilter is used to
>> track
>> a users last activity to check for "active users at the moment". The
>> simplistic approach I use at the moment updates a database table with a
>> reference to user and a timestamp. Using a requestfilter then obviously
>> leads to a lot of database roundtrips per user-activity, since every asset
>> triggers the filter.
>>
>> How would you track useractivity in a real world application? A resolution
>> of about 1 minute would suffice, but it shouldn't be much above that.
>>
>>
>> Regards,
>> Otho
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: [T5] Two RequestFilters in application module possible?

Posted by Robert Zeigler <ro...@scazdl.org>.
you could use a dispatcher instead of a request filter, inserted after  
the asset dispatcher.
That way, only non-asset requests trigger the db update.

You could adapt your filter to only fire the update on non-asset  
requests by explicitly checking the url (for matching patterns, for  
instance: ^.*\.png$ and so forth).

You could have a separate thread that does the update.  Then you have  
a service (which, naturally, will have to be threadsafe) that your  
request filter calls into to record all of the updates (multiple  
updates from the same user within the given timespan could be  
consolidated into a single update).  The separate thread asks this  
service for the pool of changes on a regular basis (Quartz package  
would be useful here) and commits them.

There are other ways you could accomplish this, as well.

If you're interested in using a Quartz-based solution, it looks like  
chenillekit is planning on adding it at some point (they have a quartz  
module, but it doesn't look like there's actually any code in there  
yet).   Alternatively, I wrote an integration module for  
TapestryQuartz that you're welcome to use (contact me off list).  I'll  
be releasing it for general use at some point, but I need to refine  
the documentation for it.

Robert


On Aug 14, 2008, at 8/143:05 AM , Otho wrote:

> Thank you very much  for the answer. Works perfectly!
>
> But this brought up a new question. The UserActivityFilter is used  
> to track
> a users last activity to check for "active users at the moment". The
> simplistic approach I use at the moment updates a database table  
> with a
> reference to user and a timestamp. Using a requestfilter then  
> obviously
> leads to a lot of database roundtrips per user-activity, since every  
> asset
> triggers the filter.
>
> How would you track useractivity in a real world application? A  
> resolution
> of about 1 minute would suffice, but it shouldn't be much above that.
>
>
> Regards,
> Otho


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


Re: [T5] Two RequestFilters in application module possible?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi,

Glad it worked.

I have something similar in my application, but instead of using a 
RequestFilter I use a PageRenderRequestFilter.

This is only called for pages and has the added benefit of giving you 
easy access to the page name, parameters, etc.

There's something similar for component events, 
ComponentEventRequestFilter, in case you'll ever need that, by the way.

-Filip

On 2008-08-14 10:05, Otho wrote:
> Thank you very much  for the answer. Works perfectly!
> 
> But this brought up a new question. The UserActivityFilter is used to track
> a users last activity to check for "active users at the moment". The
> simplistic approach I use at the moment updates a database table with a
> reference to user and a timestamp. Using a requestfilter then obviously
> leads to a lot of database roundtrips per user-activity, since every asset
> triggers the filter.
> 
> How would you track useractivity in a real world application? A resolution
> of about 1 minute would suffice, but it shouldn't be much above that.
> 
> 
> Regards,
> Otho
> 

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


Re: [T5] Two RequestFilters in application module possible?

Posted by Otho <ta...@googlemail.com>.
Thank you very much  for the answer. Works perfectly!

But this brought up a new question. The UserActivityFilter is used to track
a users last activity to check for "active users at the moment". The
simplistic approach I use at the moment updates a database table with a
reference to user and a timestamp. Using a requestfilter then obviously
leads to a lot of database roundtrips per user-activity, since every asset
triggers the filter.

How would you track useractivity in a real world application? A resolution
of about 1 minute would suffice, but it shouldn't be much above that.


Regards,
Otho

Re: [T5] Two RequestFilters in application module possible?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi,

Your problem is that Tapestry sees two RequestFilters, and that won't 
work. You'll need to properly identify each service and tell Tapestry 
that those are the services you want to contribute.

   public static void bind(ServiceBinder binder) {
     binder.bind(UserActivityFilterImpl.class).withId("UserActivityFilter");
   }

   public static RequestFilter buildTimingFilter(...) { ... }

   public static void 
contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
 
@InjectService("TimingFilter") RequestFilter timingFilter,
 
@InjectService("UserActivityFilter") RequestFilter userActivityFilter)
   {
     ...
   }

I haven't tested it, but it should work.

-Filip

On 2008-08-13 22:30, Otho wrote:
> Hi all!
> I want two contribute a second requestfilter alongside the timing filter in
> application module. But unfortunately this doesn't work with an anonymous
> definition (like the timing filter)  and a contribution to RequestHandler
> nor does it work with a written out interface/class pair contributet via the
> bind mechanism. In the latter case the error message is like this:
> 
> HTTP ERROR: 500
> 
> Exception constructing service 'RequestHandler': Error invoking service
> builder method
> org.apache.tapestry5.services.TapestryModule.buildRequestHandler(Logger,
> List, Dispatcher) (at TapestryModule.java:970) (for service
> 'RequestHandler'): Error invoking service contribution method
> org.example.animaltips.services.AtModule.contributeRequestHandler(OrderedConfiguration,
> RequestFilter): Unable to locate a single service assignable to type
> org.apache.tapestry5.services.RequestFilter with marker annotation(s)
> org.apache.tapestry5.ioc.annotations.Local.  All of the following services
> match: org.example.animaltips.services.AtModule.buildTimingFilter(Logger)
> (at AtModule.java:63),
> org.example.animaltips.services.UserActivityFilterImpl() (at
> UserActivityFilterImpl.java:24).
> 
> In the former case it also complains about 2 classes implementing the
> RequestFilter interface.
> 
> My own filter works flawlessly when I comment out the timing filter
> contribution. But for the time being I want to have both. Is there any way
> to do this easily?
> 
> Regards,
> Otho
> 

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