Hi
On 28/08/13 10:44, Thibaut Robert wrote:
Hi,
I have some jax-rs service beans deployed via Spring. I use the
jaxrs:server tag with the beanNames attribute to specify my bean. My
beans are in a custom spring scope.
Everything works fine, except that I notice that both Spring and cxf
calls my @PostConstruct and @PreDestroy methods. I think this is a bit
confusing. As cxf SpringResourceFactory delegate the resource
lifecycle to spring, why is it calling itself the lifecycle methods ?
In my case, the @Postconstruct is called twice at the first request
(by spring then cxf). Then once per request (by cxf), whereas it is
using an already existing instance. I would prefer cxf doesn't call
the methods at all.
I think I added it in a 'copy-and-paste' kind of fashion, the runtime
would release a current service instance and if it is a per-request
instance explicitly managed by the runtime then it makes sense, but I
can see now it may cause side-effects, I'll make SpringResourceFactory
calling lifecycle methods only if requested by the user, in meantime,
the workaround is to register a custom SpringResourceFactory which will
ignore release calls
Cheers, Sergey
Regards,
Thibaut