Hello,

We have to use @Context to get access to MessageContext and/or any of the other 
supported classes.

We cannot use @Context in the method signatures of the JAX-RS interfaces, 
because of these interfaces should be reused 
on the client-side.

So we have to use @Context on class fields, which leads to the problem of 
thread-safety.

Even if I setup the service beans to be prototypes, they are still singletons, 
which is most-likely happening because of 
the implementation of:

org.apache.cxf.jaxrs.JAXRSServiceFactoryBean#setResourceClassesFromBeans

Which is not following the rules of the spring beans, I guess.

Also, when debugging this, I noticed that even the MessageContext instance was 
the same instance for multiple threads. 
So if I change the HttpHeaders in one thread, this will affect the HttpHeaders 
in another thread.


How am I supposed to use @Context, reuse the JAX-RS interface on client-side 
and be thread-safe? Any ideas?


Best regards,

-- 
Marko Voß
ePublishing & eScience
Development & Applied Research
Phone +49 7247 808-744
Fax +49 7247 808-133
[email protected]


FIZ Karlsruhe - Leibniz Institute for Information Infrastructure
Hermann-von-Helmholtz-Platz 1
76344 Eggenstein-Leopoldshafen, Germany

www.fiz-karlsruhe.de


-------------------------------------------------------

Fachinformationszentrum Karlsruhe, Gesellschaft für wissenschaftlich-technische 
Information mbH. 
Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB 
101892. 
Geschäftsführerin: Sabine Brünger-Weilandt. 
Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.


Reply via email to