users@jersey.java.net

[Jersey] Re: Spring integration improvement (_at_Component specializations support)

From: Michal Gajdos <michal.gajdos_at_oracle.com>
Date: Tue, 06 May 2014 09:58:52 +0200

Hi Konrad,

sure it would be welcomed, thank you. Just add a comment to those issues
that you're working on it to let people know.

Thanks,
Michal

On 05.05.2014, 11:01 , Konrad Garus wrote:
> Hello,
>
> there are two similar issues in JIRA: JERSEY-2495 and JERSEY-2059.
> I've also spent a few hours myself trying to figure this out.
>
> The jersey-spring module has different behavior for Spring beans
> annotated directly with @Component and other annotations. For example,
> Spring has @Service, @Repository and @Controller annotations that are
> themselves annotated with @Component, and are commonly used to better
> communicate the bean role. In context of REST @Service and @Repository
> make perfect sense, arguably more so than @Component.
>
> Now, the SpringComponentProvider only supports beans annotated
> directly with @Component. If a bean from Spring app context has this
> annotation, it will be used directly for Jersey. Otherwise Jersey will
> create new request-scoped instance for every request. Such instance
> does not have complete Spring augmentation, for example it does not
> seem to have AOP wrappers.
>
> I propose to fix this by replacing this line in SpringComponentProvider:
>
> if(component.isAnnotationPresent(Component.class)) {
>
> ... with a recursive check on all annotations. Get all annotations,
> and for each of them *and their annotations* see if we can find
> @Component.
>
> I can contribute a pull request for it (need to sign OCA first, but
> I'm OK with it). Would such contribution be welcome?
>
> --
> Konrad Garus