Hi Daniel,
Two Questions:
Questions:
For R&R services, is the same thread used for all phases: inbound
interceptores, service invokation, outbound?
If not, what would be the best pattern to make sure that a context object is
available during the entire invokation lifecycle? (Same context available to
inbound interceptors, service invocation, and outbound interceptors.)
Background:
I have a similar question regarding the use of interceptor threads. I have
inbound and outbound interceptors used for auditing. The inbound
interceptor captures the inbound soap message and creates a service context
object and stores it in the TLS. During the service processing I have other
objects stored in the TLS (i.e. from Hibernate Interceptors). The outbound
audit interceptor captures the outbound soap (fault) message and then
persists all of the audit events that have occured for this service
invocation.
My assumption has been that the same thread will be used for inbound,
service, and outbound interceptors. All of the services are Request/Reply.
I am new to cxf but so far is has done everything I have needed.
FYI My Context Factory Class looks Like:
public class ContextFactory {
private ThreadLocal<Context> userThreadLocal = new
ThreadLocal<Context>() {
protected Context initialValue() {
Context serviceContext = new Context();
// Generate and set transaction ID
serviceContext.setTxnUUID(UUID.randomUUID());
return serviceContext;
}
};
private static ContextFactory instance = new ContextFactory();
public static ContextFactory getFactory() {
return instance;
}
/**
* Get the service context.
* <p>
* On the initial call the service context is initialized.
*
* @since Oct 8, 2010
* @return ServiceContext
* @return
*/
public Context getContext() {
return userThreadLocal.get();
}
/**
* Remove the service context.
*
* @since Oct 8, 2010
* @return void
*/
public void unsetContext() {
userThreadLocal.remove();
}
Paul
--
View this message in context:
http://cxf.547215.n5.nabble.com/Thread-Local-Storage-not-working-in-CXF-Interceptors-tp4439646p5148525.html
Sent from the cxf-user mailing list archive at Nabble.com.