cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Voß, Marko <>
Subject @Context and Thread-safety
Date Tue, 03 Apr 2012 08:25:15 GMT

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

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:


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

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

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


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

View raw message