users@jersey.java.net

Re: [Jersey] SpringResourceProvider

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 03 Sep 2008 10:16:36 +0200

On Sep 3, 2008, at 8:48 AM, Martin Grotzke wrote:

> Hi Paul,
>
> On Wed, 2008-09-03 at 00:28 +0200, Martin Grotzke wrote:
>> Hi Paul,
>>
>> On Mon, 2008-09-01 at 12:39 +0200, Paul Sandoz wrote:
>>> Hi Martin,
>>>
>>> The SpringResourceProvider patch looks good. Just a couple of minor
>>> questions on defaults.
>>>
>>> If a spring bean is not annotated with @Component does that mean
>>> that
>>> such information needs to be described in the XML configuration?
>> Exactly this is my understanding of the documentation [1] and [2].
>>
>> Reading this (again) I also noticed that we should also use the
>> spring
>> annotations @Repository, @Service and @Controller, as these serve as
>> specializations of @Component for more specific use cases. These are
>> used by the spring autodetection the same as @Component.
>>
>> I'll add support for these annotations to the SpringResourceProvider.
> Done.
>

Thanks.


>>
>> As you can read in [3], the spring user can customize the scanning
>> for
>> components with filters. This is really nice, though I don't think
>> that
>> we have to support s.th. like this right now, but instead might wait
>> until a user requests a feature like this.
>>
>>>
>>> If a spring bean is annotated with @Component but not annotated with
>>> @Scope is there a default for the scope?
>> For spring this is singleton, I'll add this to accordingly.
> I just have done this. However, we have to be aware that this asumes,
> that users already use spring and then add a jersey annotation to
> expose
> this bean as a resource. If a user starts with jersey and doesn't
> supply
> a jersey lifecycle annotation (so that the jersey default lifecycle is
> used) and then/afterwards also uses spring, perhaps he would expect
> that
> the jersey default lifecycle would be used.
>
> What do you think?
>

Hmm... good point. This is a tricky one. Spring users starting from
scratch will be confused if the default life-cycle is not as they
understand Spring. Jersey users migrating from non-Spring to Spring
will wonder why their application breaks.

If a developer migrating to Spring is not using the auto-wired
functionality then they will have to configure the XML accordingly
with the appropriate life-cycle of "prototype", i suppose this is not
much different from them requiring to do @Component
@Scope("prototype"). I think we just need to document this carefully.


>>
>>>
>>> Once i know the answers to the above questions i can improve the
>>> JavaDoc
>>> related to defaults.
>> You refer to javadoc of SpringResourceProvider?
>>
>> I'll do the changes these days and afterwards commit it to the trunk,
>> ok?
> I just have noticed that you already committed the patch, thanx :)
> However, the changes mentioned above are in the trunk now.
>

Thanks!
Paul.

> Cheers,
> Martin
>
>>
>> Cheers,
>> Martin
>>
>>
>> [1] http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-stereotype-annotations
>> [2] http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-scanning-scope-resolver
>>
>>
>>
>>
>>>
>>> Paul.
>
> --
> Martin Grotzke
> http://www.javakaffee.de/blog/