You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Vjacheslav V. Borisov" <sl...@gmail.com> on 2014/10/13 15:19:07 UTC

Auto-discovery of root resources

Hi All!

How to setup singleton  / per request resources in case of

https://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders

?

Re: Auto-discovery of root resources

Posted by Sergey Beryozkin <sb...@gmail.com>.
Actually, yes, if you add Component and Scope annotation to the root 
resources then we can probably wrap it internally in a 
SpringResourceFactory and thus control the life-cycle process correctly.
I'll experiment it with it a bit later

Cheers, Sergey

On 14/10/14 14:59, Sergey Beryozkin wrote:
> On 14/10/14 14:04, Vjacheslav V. Borisov wrote:
>> 2014-10-14 14:37 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:
>>
>>>
>>>
>>>>   I'm not sure the auto-discovery can work well with the Spring
>>>> mechanism
>>> of dealing with non-singleton contexts. In Spring one has to declare
>>> scopes
>>> like "prototype", etc, see
>>>
>>> http://cxf.apache.org/docs/jaxrs-services-configuration.html#
>>> JAXRSServicesConfiguration-FromSpring
>>>
>>> i.e, the bean classes have to be declared which leaves no space for the
>>> auto-discovery.
>>>
>>> May be an annotation such as @PerRequest can be added which will take
>>> effect only during the auto-discovery phase. I'll think about it
>>>
>> May be annotation   javax.enterprise.context.RequestScoped suits ?
>> This anotation adds Netbeans when I create Restfl service from Patterns
>>
> This is an extra dependency; to be honest I doubt we can have both the
> auto-discovery and the scope control mechanism supported at the same
> time. It does not seem to be a good idea now to me to have a new
> annotation added, I was wrong, when it is Spring the lifecycle control
> has to be done via Spring ApplicationContext...
>
> Perhaps you should experiment with a pure Spring based auto-discovery
> mechanism, where Spring @Component and @Scope annotations are used...
>
> Cheers, Sergey


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Auto-discovery of root resources

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 14/10/14 14:04, Vjacheslav V. Borisov wrote:
> 2014-10-14 14:37 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:
>
>>
>>
>>>   I'm not sure the auto-discovery can work well with the Spring mechanism
>> of dealing with non-singleton contexts. In Spring one has to declare scopes
>> like "prototype", etc, see
>>
>> http://cxf.apache.org/docs/jaxrs-services-configuration.html#
>> JAXRSServicesConfiguration-FromSpring
>>
>> i.e, the bean classes have to be declared which leaves no space for the
>> auto-discovery.
>>
>> May be an annotation such as @PerRequest can be added which will take
>> effect only during the auto-discovery phase. I'll think about it
>>
> May be annotation   javax.enterprise.context.RequestScoped suits ?
> This anotation adds Netbeans when I create Restfl service from Patterns
>
This is an extra dependency; to be honest I doubt we can have both the 
auto-discovery and the scope control mechanism supported at the same 
time. It does not seem to be a good idea now to me to have a new 
annotation added, I was wrong, when it is Spring the lifecycle control 
has to be done via Spring ApplicationContext...

Perhaps you should experiment with a pure Spring based auto-discovery 
mechanism, where Spring @Component and @Scope annotations are used...

Cheers, Sergey

Re: Auto-discovery of root resources

Posted by "Vjacheslav V. Borisov" <sl...@gmail.com>.
2014-10-14 14:37 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:

>
>
>>  I'm not sure the auto-discovery can work well with the Spring mechanism
> of dealing with non-singleton contexts. In Spring one has to declare scopes
> like "prototype", etc, see
>
> http://cxf.apache.org/docs/jaxrs-services-configuration.html#
> JAXRSServicesConfiguration-FromSpring
>
> i.e, the bean classes have to be declared which leaves no space for the
> auto-discovery.
>
> May be an annotation such as @PerRequest can be added which will take
> effect only during the auto-discovery phase. I'll think about it
>
May be annotation   javax.enterprise.context.RequestScoped suits ?
This anotation adds Netbeans when I create Restfl service from Patterns

Re: Auto-discovery of root resources

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 14/10/14 06:22, Vjacheslav V. Borisov wrote:
> 2014-10-13 18:10 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:
>
>>
>> How to setup singleton  / per request resources in case of
>>>
>>> https://cxf.apache.org/docs/jaxrs-services-configuration.html#
>>> JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders
>>>
>>>   It currently works only with Spring. Not possible yet to auto-discover
>> the root resources/providers if no Spring is used...
>>
>
> But I am using spring with  auto-discover feature. I just dont know how to
> conigure resources to "per request" (they are singletons by default)
>
I'm not sure the auto-discovery can work well with the Spring mechanism 
of dealing with non-singleton contexts. In Spring one has to declare 
scopes like "prototype", etc, see

http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-FromSpring

i.e, the bean classes have to be declared which leaves no space for the 
auto-discovery.

May be an annotation such as @PerRequest can be added which will take 
effect only during the auto-discovery phase. I'll think about it

Cheers, Sergey

Re: Auto-discovery of root resources

Posted by "Vjacheslav V. Borisov" <sl...@gmail.com>.
2014-10-13 18:10 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:

>
> How to setup singleton  / per request resources in case of
>>
>> https://cxf.apache.org/docs/jaxrs-services-configuration.html#
>> JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders
>>
>>  It currently works only with Spring. Not possible yet to auto-discover
> the root resources/providers if no Spring is used...
>

But I am using spring with  auto-discover feature. I just dont know how to
conigure resources to "per request" (they are singletons by default)

Re: Auto-discovery of root resources

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 13/10/14 14:19, Vjacheslav V. Borisov wrote:
> Hi All!
>
> How to setup singleton  / per request resources in case of
>
> https://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders
>
> ?
>
It currently works only with Spring. Not possible yet to auto-discover 
the root resources/providers if no Spring is used...

Cheers, Sergey