You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/04/21 19:23:48 UTC

svn commit: r767233 - in /cxf/branches/2.1.x-fixes/rt: core/src/main/java/org/apache/cxf/endpoint/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/

Author: dkulp
Date: Tue Apr 21 17:23:47 2009
New Revision: 767233

URL: http://svn.apache.org/viewvc?rev=767233&view=rev
Log:
Didn't mean to commit that stuff.  Was looking at a patch.

Modified:
    cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java

Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?rev=767233&r1=767232&r2=767233&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Tue Apr 21 17:23:47 2009
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.endpoint;
 
-import java.lang.ref.WeakReference;
-
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -70,29 +68,29 @@
 public class ClientImpl
     extends AbstractBasicInterceptorProvider
     implements Client, Retryable, MessageObserver {
-
+    
     public static final String THREAD_LOCAL_REQUEST_CONTEXT = "thread.local.request.context";
 
-
+    
     public static final String FINISHED = "exchange.finished";
-
+    
     private static final Logger LOG = LogUtils.getL7dLogger(ClientImpl.class);
-
+    
     protected Bus bus;
     protected ConduitSelector conduitSelector;
-    protected ClientOutFaultObserver outFaultObserver;
+    protected ClientOutFaultObserver outFaultObserver; 
     protected int synchronousTimeout = 60000; // default 60 second timeout
-
+    
     protected PhaseChainCache outboundChainCache = new PhaseChainCache();
     protected PhaseChainCache inboundChainCache = new PhaseChainCache();
-
+    
     protected Map<String, Object> currentRequestContext = new ConcurrentHashMap<String, Object>();
-    protected ThreadLocal <WeakReference<EchoContext>> requestContext =
-        new ThreadLocal<WeakReference<EchoContext>>();
-
-    protected ThreadLocal <WeakReference<Map<String, Object>>> responseContext =
-            new ThreadLocal<WeakReference<Map<String, Object>>>();
+    protected ThreadLocal <EchoContext> requestContext =
+        new ThreadLocal<EchoContext>();
 
+    protected ThreadLocal <Map<String, Object>> responseContext =
+            new ThreadLocal<Map<String, Object>>();
+    
     protected Executor executor;
 
 
@@ -103,7 +101,7 @@
     public ClientImpl(Bus b, Endpoint e, Conduit c) {
        this(b, e, new PreexistingConduitSelector(c));
     }
-
+    
     public ClientImpl(Bus b, Endpoint e, ConduitSelector sc) {
         bus = b;
         outFaultObserver = new ClientOutFaultObserver(bus);
@@ -114,7 +112,7 @@
     public ClientImpl(URL wsdlUrl) {
         this(BusFactory.getThreadDefaultBus(), wsdlUrl, null, null, SimpleEndpointImplFactory.getSingleton());
     }
-
+    
     public ClientImpl(URL wsdlUrl, QName port) {
         this(BusFactory.getThreadDefaultBus(), wsdlUrl, null, port, SimpleEndpointImplFactory.getSingleton());
     }
@@ -138,14 +136,14 @@
      * @param port
      * @param endpointImplFactory
      */
-    public ClientImpl(Bus bus, URL wsdlUrl, QName service,
+    public ClientImpl(Bus bus, URL wsdlUrl, QName service, 
                       QName port, EndpointImplFactory endpointImplFactory) {
         this.bus = bus;
-
+        
         WSDLServiceFactory sf = (service == null)
             ? (new WSDLServiceFactory(bus, wsdlUrl)) : (new WSDLServiceFactory(bus, wsdlUrl, service));
         Service svc = sf.create();
-
+    
         EndpointInfo epfo = findEndpoint(svc, port);
 
         try {
@@ -155,17 +153,17 @@
         }
         notifyLifecycleManager();
     }
-
+    
     public void destroy() {
-
+        
         // TODO: also inform the conduit so it can shutdown any response listeners
-
+        
         ClientLifeCycleManager mgr = bus.getExtension(ClientLifeCycleManager.class);
         if (null != mgr) {
             mgr.clientDestroyed(this);
         }
     }
-
+    
     private void notifyLifecycleManager() {
         ClientLifeCycleManager mgr = bus.getExtension(ClientLifeCycleManager.class);
         if (null != mgr) {
@@ -186,7 +184,7 @@
             for (ServiceInfo svcfo : svc.getServiceInfos()) {
                 for (EndpointInfo e : svcfo.getEndpoints()) {
                     BindingInfo bfo = e.getBinding();
-
+    
                     if (bfo.getBindingId().equals("http://schemas.xmlsoap.org/wsdl/soap/")) {
                         for (Object o : bfo.getExtensors().get()) {
                             if (o instanceof SOAPBindingImpl) {
@@ -197,7 +195,7 @@
                                 }
                             }
                         }
-
+    
                     }
                 }
             }
@@ -214,15 +212,22 @@
         return getConduitSelector().getEndpoint();
     }
 
-
+    
     public Map<String, Object> getRequestContext() {
         if (isThreadLocalRequestContext()) {
-            getThreadRequestContext();
+            if (null == requestContext.get()) {
+                requestContext.set(new EchoContext(currentRequestContext));
+            }
+            return requestContext.get();
         }
         return currentRequestContext;
     }
     public Map<String, Object> getResponseContext() {
-        return getThreadResponseContext();
+        if (null == responseContext.get()) {
+            responseContext.set(new HashMap<String, Object>());
+        }        
+        return responseContext.get();
+
     }
     public boolean isThreadLocalRequestContext() {
         if (currentRequestContext.containsKey(THREAD_LOCAL_REQUEST_CONTEXT)) {
@@ -241,37 +246,37 @@
         currentRequestContext.put(THREAD_LOCAL_REQUEST_CONTEXT, b);
     }
 
-
+    
     public Object[] invoke(BindingOperationInfo oi, Object... params) throws Exception {
         return invoke(oi, params, null);
     }
 
     public Object[] invoke(String operationName, Object... params) throws Exception {
         QName q = new QName(getEndpoint().getService().getName().getNamespaceURI(), operationName);
-
+       
         return invoke(q, params);
     }
-
+    
     public Object[] invoke(QName operationName, Object... params) throws Exception {
         BindingOperationInfo op = getEndpoint().getEndpointInfo().getBinding().getOperation(operationName);
         if (op == null) {
             throw new UncheckedException(
                 new org.apache.cxf.common.i18n.Message("NO_OPERATION", LOG, operationName));
         }
-
+        
         if (op.isUnwrappedCapable()) {
             op = op.getUnwrappedOperation();
         }
-
+        
         return invoke(op, params);
     }
 
     public Object[] invokeWrapped(String operationName, Object... params) throws Exception {
         QName q = new QName(getEndpoint().getService().getName().getNamespaceURI(), operationName);
-
+       
         return invokeWrapped(q, params);
     }
-
+    
     public Object[] invokeWrapped(QName operationName, Object... params) throws Exception {
         BindingOperationInfo op = getEndpoint().getEndpointInfo().getBinding().getOperation(operationName);
         if (op == null) {
@@ -282,7 +287,7 @@
     }
 
     public Object[] invoke(BindingOperationInfo oi,
-                           Object[] params,
+                           Object[] params, 
                            Exchange exchange) throws Exception {
         Map<String, Object> context = new HashMap<String, Object>();
         Map<String, Object> resp = getResponseContext();
@@ -293,11 +298,11 @@
         try {
             return invoke(oi, params, context, exchange);
         } finally {
-            setThreadResponseContext(resp);
+            responseContext.set(resp);
         }
     }
     public Object[] invoke(BindingOperationInfo oi,
-                           Object[] params,
+                           Object[] params, 
                            Map<String, Object> context) throws Exception {
         try {
             return invoke(oi, params, context, (Exchange)null);
@@ -305,46 +310,46 @@
             if (context != null) {
                 Map<String, Object> resp = CastUtils.cast((Map<?, ?>)context.get(RESPONSE_CONTEXT));
                 if (resp != null) {
-                    setThreadResponseContext(resp);
+                    responseContext.set(resp);
                 }
             }
         }
     }
-
-    public void invoke(ClientCallback callback,
-                       String operationName,
+    
+    public void invoke(ClientCallback callback, 
+                       String operationName, 
                        Object... params) throws Exception {
         QName q = new QName(getEndpoint().getService().getName().getNamespaceURI(), operationName);
-        invoke(callback, q, params);
+        invoke(callback, q, params);        
     }
 
-    public void invoke(ClientCallback callback,
-                       QName operationName,
+    public void invoke(ClientCallback callback, 
+                       QName operationName, 
                        Object... params) throws Exception {
         BindingOperationInfo op = getEndpoint().getEndpointInfo().getBinding().getOperation(operationName);
         if (op == null) {
             throw new UncheckedException(
                 new org.apache.cxf.common.i18n.Message("NO_OPERATION", LOG, operationName));
         }
-
+        
         if (op.isUnwrappedCapable()) {
             op = op.getUnwrappedOperation();
         }
-
+        
         invoke(callback, op, params);
     }
 
 
-    public void invokeWrapped(ClientCallback callback,
-                              String operationName,
+    public void invokeWrapped(ClientCallback callback, 
+                              String operationName, 
                               Object... params)
         throws Exception {
         QName q = new QName(getEndpoint().getService().getName().getNamespaceURI(), operationName);
-        invokeWrapped(callback, q, params);
+        invokeWrapped(callback, q, params);        
     }
 
-    public void invokeWrapped(ClientCallback callback,
-                              QName operationName,
+    public void invokeWrapped(ClientCallback callback, 
+                              QName operationName, 
                               Object... params)
         throws Exception {
         BindingOperationInfo op = getEndpoint().getEndpointInfo().getBinding().getOperation(operationName);
@@ -355,9 +360,9 @@
         invoke(callback, op, params);
     }
 
-
-    public void invoke(ClientCallback callback,
-                       BindingOperationInfo oi,
+    
+    public void invoke(ClientCallback callback, 
+                       BindingOperationInfo oi, 
                        Object... params) throws Exception {
         Bus origBus = BusFactory.getThreadDefaultBus(false);
         BusFactory.setThreadDefaultBus(bus);
@@ -374,42 +379,42 @@
 
             Message message = endpoint.getBinding().createMessage();
             message.put(Message.INVOCATION_CONTEXT, context);
-
+            
             //setup the message context
             setContext(reqContext, message);
             setParameters(params, message);
-
+    
             if (null != reqContext) {
                 exchange.putAll(reqContext);
             }
             exchange.setOneWay(oi.getOutput() == null);
             exchange.setOutMessage(message);
             exchange.put(ClientCallback.class, callback);
-
+            
             setOutMessageProperties(message, oi);
             setExchangeProperties(exchange, endpoint, oi);
-
+            
             // setup chain
-
+    
             PhaseInterceptorChain chain = setupInterceptorChain(endpoint);
             message.setInterceptorChain(chain);
-
+            
             modifyChain(chain, reqContext);
             chain.setFaultObserver(outFaultObserver);
-
+            
             // setup conduit selector
             prepareConduitSelector(message);
-
-            // execute chain
+            
+            // execute chain        
             chain.doIntercept(message);
 
         } finally {
             BusFactory.setThreadDefaultBus(origBus);
-        }
+        }       
     }
-
+    
     public Object[] invoke(BindingOperationInfo oi,
-                           Object[] params,
+                           Object[] params, 
                            Map<String, Object> context,
                            Exchange exchange) throws Exception {
         Bus origBus = BusFactory.getThreadDefaultBus(false);
@@ -420,7 +425,7 @@
             }
             exchange.setSynchronous(true);
             Endpoint endpoint = getEndpoint();
-
+            
             Map<String, Object> reqContext = null;
             Map<String, Object> resContext = null;
             if (LOG.isLoggable(Level.FINE)) {
@@ -431,46 +436,46 @@
                 reqContext = CastUtils.cast((Map)context.get(REQUEST_CONTEXT));
                 resContext = CastUtils.cast((Map)context.get(RESPONSE_CONTEXT));
                 message.put(Message.INVOCATION_CONTEXT, context);
-            }
+            }    
             //setup the message context
             setContext(reqContext, message);
             setParameters(params, message);
-
+    
             if (null != reqContext) {
                 exchange.putAll(reqContext);
             }
-
+            
             if (null != oi) {
                 exchange.setOneWay(oi.getOutput() == null);
             }
-
+    
             exchange.setOutMessage(message);
-
+            
             setOutMessageProperties(message, oi);
             setExchangeProperties(exchange, endpoint, oi);
-
+            
             // setup chain
-
+    
             PhaseInterceptorChain chain = setupInterceptorChain(endpoint);
             message.setInterceptorChain(chain);
-
+            
             modifyChain(chain, reqContext);
             chain.setFaultObserver(outFaultObserver);
-
+            
             // setup conduit selector
             prepareConduitSelector(message);
-
-            // execute chain
+            
+            // execute chain        
             chain.doIntercept(message);
-
+    
             return processResult(message, exchange, oi, resContext);
-
+            
         } finally {
             BusFactory.setThreadDefaultBus(origBus);
         }
     }
 
-    protected Object[] processResult(Message message,
+    protected Object[] processResult(Message message, 
                                    Exchange exchange,
                                    BindingOperationInfo oi,
                                    Map<String, Object> resContext) throws Exception {
@@ -491,14 +496,14 @@
             }
             throw ex;
         }
-
+        
         // Wait for a response if we need to
         if (oi != null && !oi.getOperationInfo().isOneWay()) {
             synchronized (exchange) {
                 waitResponse(exchange);
             }
         }
-
+        
         // leave the input stream open for the caller
         Boolean keepConduitAlive = (Boolean)exchange.get(Client.KEEP_CONDUIT_ALIVE);
         if (keepConduitAlive == null || !keepConduitAlive) {
@@ -509,7 +514,7 @@
         List resList = null;
         Message inMsg = exchange.getInMessage();
         if (inMsg != null) {
-            if (null != resContext) {
+            if (null != resContext) {                   
                 resContext.putAll(inMsg);
                 if (LOG.isLoggable(Level.FINE)) {
                     LOG.fine("set responseContext to be" + responseContext);
@@ -517,18 +522,18 @@
             }
             resList = inMsg.getContent(List.class);
         }
-
+        
         // check for an incoming fault
         ex = getException(exchange);
-
+        
         if (ex != null) {
             throw ex;
         }
-
+        
         if (resList != null) {
             return resList.toArray();
         }
-
+        
         return null;
     }
     protected Exception getException(Exchange exchange) {
@@ -536,17 +541,17 @@
             return exchange.getInFaultMessage().getContent(Exception.class);
         } else if (exchange.getOutFaultMessage() != null) {
             return exchange.getOutFaultMessage().getContent(Exception.class);
-        }
+        } 
         return null;
     }
 
     protected void setContext(Map<String, Object> ctx, Message message) {
-        if (ctx != null) {
+        if (ctx != null) {            
             message.putAll(ctx);
             if (LOG.isLoggable(Level.FINE)) {
                 LOG.fine("set requestContext to message be" + ctx);
             }
-        }
+        }        
     }
 
     protected void waitResponse(Exchange exchange) {
@@ -571,24 +576,24 @@
         MessageContentsList contents = new MessageContentsList(params);
         message.setContent(List.class, contents);
     }
-
+    
     public void onMessage(Message message) {
 
         Endpoint endpoint = message.getExchange().get(Endpoint.class);
         if (endpoint == null) {
             // in this case correlation will occur outside the transport,
-            // however there's a possibility that the endpoint may have been
+            // however there's a possibility that the endpoint may have been 
             // rebased in the meantime, so that the response will be mediated
             // via a set of in interceptors provided by a *different* endpoint
             //
             endpoint = getConduitSelector().getEndpoint();
-            message.getExchange().put(Endpoint.class, endpoint);
+            message.getExchange().put(Endpoint.class, endpoint);            
         }
         message = endpoint.getBinding().createMessage(message);
         message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
         message.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
         PhaseManager pm = bus.getExtension(PhaseManager.class);
-
+        
         List<Interceptor> i1 = bus.getInInterceptors();
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Interceptors contributed by bus: " + i1);
@@ -605,12 +610,12 @@
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Interceptors contributed by binding: " + i4);
         }
-
-        PhaseInterceptorChain chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4);
+        
+        PhaseInterceptorChain chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4); 
         message.setInterceptorChain(chain);
-
+        
         chain.setFaultObserver(outFaultObserver);
-
+        
         Bus origBus = BusFactory.getThreadDefaultBus(false);
         BusFactory.setThreadDefaultBus(bus);
         // execute chain
@@ -623,7 +628,7 @@
                 }
                 callback.start(message);
             }
-
+            
             String startingAfterInterceptorID = (String) message.get(
                 PhaseInterceptorChain.STARTING_AFTER_INTERCEPTOR_ID);
             String startingInterceptorID = (String) message.get(
@@ -635,9 +640,9 @@
             } else {
                 chain.doIntercept(message);
             }
-
+            
             callback = message.getExchange().get(ClientCallback.class);
-
+            
             if (callback != null && !isPartialResponse(message)) {
                 message.getExchange().setInMessage(message);
                 Map<String, Object> resCtx = CastUtils.cast((Map<?, ?>)message
@@ -645,11 +650,11 @@
                                                                 .getOutMessage()
                                                                 .get(Message.INVOCATION_CONTEXT));
                 resCtx = CastUtils.cast((Map<?, ?>)resCtx.get(RESPONSE_CONTEXT));
-
+                
                 try {
                     Object obj[] = processResult(message, message.getExchange(),
                                                  null, resCtx);
-
+                                        
                     callback.handleResponse(resCtx, obj);
                 } catch (Throwable ex) {
                     callback.handleException(resCtx, ex);
@@ -660,7 +665,7 @@
                 if (!isPartialResponse(message) && callback == null) {
                     message.getExchange().put(FINISHED, Boolean.TRUE);
                     message.getExchange().setInMessage(message);
-                    message.getExchange().notifyAll();
+                    message.getExchange().notifyAll();                   
                 }
             }
             BusFactory.setThreadDefaultBus(origBus);
@@ -688,7 +693,7 @@
             message.put(MessageInfo.class, boi.getOperationInfo().getInput());
         }
     }
-
+    
     protected void setExchangeProperties(Exchange exchange,
                                          Endpoint endpoint,
                                          BindingOperationInfo boi) {
@@ -706,7 +711,7 @@
             exchange.put(BindingOperationInfo.class, boi);
             exchange.put(OperationInfo.class, boi.getOperationInfo());
         }
-
+                
         if (exchange.isSynchronous() || executor == null) {
             exchange.put(MessageObserver.class, this);
         } else {
@@ -718,7 +723,7 @@
                         }
                     });
                 }
-            });
+            });            
         }
         exchange.put(Retryable.class, this);
         exchange.put(Client.class, this);
@@ -751,10 +756,10 @@
         }
     }
 
-    protected PhaseInterceptorChain setupInterceptorChain(Endpoint endpoint) {
+    protected PhaseInterceptorChain setupInterceptorChain(Endpoint endpoint) { 
 
         PhaseManager pm = bus.getExtension(PhaseManager.class);
-
+        
         List<Interceptor> i1 = bus.getOutInterceptors();
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Interceptors contributed by bus: " + i1);
@@ -789,17 +794,17 @@
     public void setSynchronousTimeout(int synchronousTimeout) {
         this.synchronousTimeout = synchronousTimeout;
     }
-
+    
     public final ConduitSelector getConduitSelector() {
         return getConduitSelector(null);
     }
-
+    
     protected final synchronized ConduitSelector getConduitSelector(
         ConduitSelector override
     ) {
         if (null == conduitSelector) {
             setConduitSelector(override != null
-                               ? override
+                               ? override 
                                : new UpfrontConduitSelector());
         }
         return conduitSelector;
@@ -812,13 +817,13 @@
     private boolean isPartialResponse(Message in) {
         return Boolean.TRUE.equals(in.get(Message.PARTIAL_RESPONSE_MESSAGE));
     }
-
-
+    
+    
     /*
      * modification are echoed back to the shared map
      */
     public static class EchoContext extends HashMap<String, Object> {
-        final Map<String, Object> shared;
+        final Map<String, Object> shared; 
         public EchoContext(Map<String, Object> sharedMap) {
             super(sharedMap);
             shared = sharedMap;
@@ -833,12 +838,12 @@
             shared.putAll(t);
             super.putAll(t);
         }
-
+        
         public Object remove(Object key) {
             shared.remove(key);
             return super.remove(key);
         }
-
+        
         public void reload() {
             super.clear();
             super.putAll(shared);
@@ -850,29 +855,5 @@
         this.executor = executor;
     }
 
-    protected Map<String, Object> getThreadRequestContext() {
-        WeakReference<EchoContext> r = requestContext.get();
-        if ((null == r) || (null == r.get())) {
-            r = new WeakReference<EchoContext>(new EchoContext(currentRequestContext));
-            requestContext.set(r);
-        }
-        return (r == null) ? null : r.get();
-    }
-
-    protected Map<String, Object> getThreadResponseContext() {
-        WeakReference<Map<String, Object>> r = responseContext.get();
-        if ((null == r) || (null == r.get())) {
-            r = new WeakReference<Map<String, Object>>(new HashMap<String, Object>());
-            responseContext.set(r);
-        }
-        return (r == null) ? null : r.get();
-
-    }
-
-    protected void setThreadResponseContext(Map<String, Object> resp) {
-        WeakReference<Map<String, Object>> r =
-            new WeakReference<Map<String, Object>>(resp);
-        responseContext.set(r);
-    }
 
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java?rev=767233&r1=767232&r2=767233&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java Tue Apr 21 17:23:47 2009
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.jaxws;
 
-import java.lang.ref.WeakReference;
-
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -35,13 +33,13 @@
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 
 public class BindingProviderImpl implements BindingProvider {
-    protected ThreadLocal <WeakReference<Map<String, Object>>> requestContext =
-        new ThreadLocal<WeakReference<Map<String, Object>>>();
-    protected ThreadLocal <WeakReference<Map<String, Object>>> responseContext =
-        new ThreadLocal<WeakReference<Map<String, Object>>>();
+    protected ThreadLocal <Map<String, Object>> requestContext = 
+        new ThreadLocal<Map<String, Object>>();
+    protected ThreadLocal <Map<String, Object>> responseContext =
+        new ThreadLocal<Map<String, Object>>();
     private final Binding binding;
     private final EndpointReferenceBuilder builder;
-
+       
     public BindingProviderImpl() {
         this.binding = null;
         this.builder = null;
@@ -51,20 +49,28 @@
         this.binding = b;
         this.builder = null;
     }
-
+    
     public BindingProviderImpl(JaxWsEndpointImpl endpoint) {
         this.binding = endpoint.getJaxwsBinding();
         this.builder = new EndpointReferenceBuilder(endpoint);
     }
-
+    
     public Map<String, Object> getRequestContext() {
-        return getThreadRequestContext();
+        if (null == requestContext.get()) {
+            requestContext.set(new HashMap<String, Object>());
+        }
+        return requestContext.get();
     }
 
     public Map<String, Object> getResponseContext() {
-        return getThreadResponseContext();
+        if (null == responseContext.get()) {
+            responseContext.set(new WrappedMessageContext(new HashMap<String, Object>(),
+                                                          null,
+                                                          Scope.APPLICATION));
+        }
+        return responseContext.get();
     }
-
+    
     protected void clearContext(ThreadLocal<Map<String, Object>> context) {
         context.set(null);
     }
@@ -72,9 +78,9 @@
     public Binding getBinding() {
         return binding;
     }
-
+    
     protected void populateResponseContext(MessageContext ctx) {
-
+        
         Iterator<String> iter  = ctx.keySet().iterator();
         Map<String, Object> respCtx = getResponseContext();
         while (iter.hasNext()) {
@@ -85,32 +91,11 @@
         }
     }
 
-    public EndpointReference getEndpointReference() {
+    public EndpointReference getEndpointReference() {            
         return builder.getEndpointReference();
     }
 
     public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
         return builder.getEndpointReference(clazz);
     }
-
-    protected Map<String, Object> getThreadRequestContext() {
-        WeakReference<Map<String, Object>> r = requestContext.get();
-        if ((null == r) || (null == r.get())) {
-            r = new WeakReference<Map<String, Object>>(new HashMap<String, Object>());
-            requestContext.set(r);
-        }
-        return (r != null) ? r.get() : null;
-    }
-
-    protected Map<String, Object> getThreadResponseContext() {
-        WeakReference<Map<String, Object>> r = responseContext.get();
-        if ((null == r) || (null == r.get())) {
-            r = new WeakReference<Map<String, Object>>(
-                    new WrappedMessageContext(
-                    new HashMap<String, Object>(), null, Scope.APPLICATION));
-            responseContext.set(r);
-        }
-        return (r != null) ? r.get() : null;
-    }
-
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java?rev=767233&r1=767232&r2=767233&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java Tue Apr 21 17:23:47 2009
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.jaxws.context;
 
-import java.lang.ref.WeakReference;
-
 import java.security.Principal;
 import java.util.logging.Logger;
 
@@ -41,20 +39,19 @@
 public class WebServiceContextImpl implements WebServiceContext {
     private static final Logger LOG = LogUtils.getL7dLogger(WebServiceContextImpl.class);
 
-    private static ThreadLocal<WeakReference<MessageContext>> context =
-            new ThreadLocal<WeakReference<MessageContext>>();
+    private static ThreadLocal<MessageContext> context = new ThreadLocal<MessageContext>();
 
-    public WebServiceContextImpl() {
+    public WebServiceContextImpl() { 
     }
 
-    public WebServiceContextImpl(MessageContext ctx) {
+    public WebServiceContextImpl(MessageContext ctx) { 
         setMessageContext(ctx);
-    }
+    } 
 
     // Implementation of javax.xml.ws.WebServiceContext
 
     public final MessageContext getMessageContext() {
-        return getThreadMessageContext();
+        return context.get();
     }
 
     public final Principal getUserPrincipal() {
@@ -72,7 +69,7 @@
         }
         return ctx.isUserInRole(role);
     }
-
+    
     //  TODO JAX-WS 2.1
     public EndpointReference getEndpointReference(Element... referenceParameters) {
         WrappedMessageContext ctx = (WrappedMessageContext)getMessageContext();
@@ -84,13 +81,13 @@
         builder.serviceName(ep.getService().getName());
         builder.endpointName(ep.getEndpointInfo().getName());
 
-//        builder.wsdlDocumentLocation(wsdlLocation);
+//        builder.wsdlDocumentLocation(wsdlLocation);        
         if (referenceParameters != null) {
             for (Element referenceParameter : referenceParameters) {
                 builder.referenceParameter(referenceParameter);
             }
         }
-
+        
         return builder.build();
     }
 
@@ -106,21 +103,11 @@
 
     public static void setMessageContext(MessageContext ctx) {
         //ContextPropertiesMapping.mapCxf2Jaxws(ctx);
-        setThreadMessageContext(ctx);
+        context.set(ctx);
     }
 
     public static void clear() {
         context.set(null);
     }
 
-    private static MessageContext getThreadMessageContext() {
-        WeakReference<MessageContext> r = context.get();
-        return (r != null) ? r.get() : null;
-    }
-
-    private static void setThreadMessageContext(MessageContext ctx) {
-        WeakReference<MessageContext> r = new WeakReference<MessageContext>(ctx);
-        context.set(r);
-    }
-
 }