users@jersey.java.net

Re: [Jersey] Registration of resource/provider classes via Spring

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Mon, 10 Nov 2008 00:01:03 +0100

Hi Paul,

On Fri, 2008-11-07 at 11:53 +0100, Paul Sandoz wrote:
> Hi Martin,
>
> I am wondering if we could improve the registration mechanism of
> Jersey with Spring currently we do the following:
>
> 1) In the xml config we require that the spring bean is named as the
> fully qualified class name.
I asume you are referring to spring's applicationContext.xml, right? I'm
not sure what you want to say with "the spring bean is named as the
fully qualified class name".

1) spring beans (bean definitions) have an id/name: you can choose it as
you want. In jersey we can refer to this is/name in @Inject#value. If
the value is not set we resolve the spring bean by type.

2) spring beans (bean definitions) have set a fully qualified class
name. This has nothing to do with the bean id/name.


>
> 2) For autowire, Jersey scans and Spring scans, it requires some
> duplication of package declaration.
>
> Do you know if there is any way to get the set of classes or bean
> class information Spring knows about at initialization?
Yes, it's possible to get the bean definitions via
ConfigurableListableBeanFactory#getBeanDefinition(String beanName)
([1]).

> If so those
> classes could be analyzed by Jersey and registration of those classes
> could occur. In such cases Jersey scanning could be disabled unless
> one explicitly declares it and wants to mix Spring and non-Spring beans.
Sounds good to me.

So we would introduce a new SpringResourceConfig that is provided by the
SpringServlet if the user did not specify any init param related to the
resourceConfig (resourceConfigClass, application, packes, classpath)?

>
> I guess the problem is a little more complicated since there is not
> always a one to one correspondence between the class and the instance
> but i think that is a fair assumption to make for resource and
> provider classes.
What do you mean with this?

Cheers,
Martin


[1] http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.html#getBeanDefinition(java.lang.String)

>
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net