Hi,
I just realized that such a resource filter would be a really neat way
for developers to get logging/debug information on what resources are
being matched. This is something that has been requested a number of
times but i have been reluctant to "pollute" the code with explicit
logging statements. Now i just need to find time to implement....
Paul.
On Aug 28, 2009, at 11:12 AM, Paul Sandoz wrote:
>
> On Aug 27, 2009, at 8:58 PM, Yong Yuan wrote:
>
>> Hi,
>>
>> I'd like to collect some stats in a filter across all incoming
>> requests for certain resources. In that case, is it possible to
>> apply @Singleton annotation to a resource filter, or should I
>> simply keep my stats in a singleton object, or a resource filter
>> will be a singleton per resource as long as the resource is a
>> singleton?
>
> Container request/response filters or resource filter factories are
> always instantiated as singletons and the life-cycle is independent
> of the life-cycle of the resource. (Note that the Jersey life-cycle
> annotations only apply to resource classes.)
>
> So you can keep state in your filter, and of course you will need to
> ensure that state is protected from concurrent access.
>
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>