I need to dynamically assign EntityManagers to my beans at runtime based on the contents of a soap header. My plan is to extract the info from the header with a SOAPHandler and then store it in the request scope. I have a method @Producer that I envisage accessing this request scope, examining the stored variable, and returning the appropriate entitymanager.
(The EntityManagers refer to different DB’s with the same structure, but different data).
MY PROBLEM IS THIS: How do I access the request context to store the name (on the SOAPHandler side) and then, again, retrieve the request context to retrieve the name?
Any help appreciated.
To answer my own question:
Stick it in the SOAPMessageContext, as follows:
(The Scope.APPLICATION is important).
In the service layer you can then get the message context from the web service context, which you can inject in; the message context will then have your object: