01: /*
02: * Copyright 2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.springframework.ws.transport.context;
17:
18: /**
19: * Simple holder class that associates a <code>TransportContext</code> instance with the current thread. The
20: * <code>TransportContext</code> will be inherited by any child threads spawned by the current thread.
21: *
22: * @author Arjen Poutsma
23: * @see TransportContext
24: * @since 1.0.0
25: */
26: public abstract class TransportContextHolder {
27:
28: private static final ThreadLocal transportContextHolder = new ThreadLocal();
29:
30: /**
31: * Associate the given <code>TransportContext</code> with the current thread.
32: *
33: * @param transportContext the current transport context, or <code>null</code> to reset the thread-bound context
34: */
35: public static void setTransportContext(
36: TransportContext transportContext) {
37: transportContextHolder.set(transportContext);
38: }
39:
40: /**
41: * Return the <code>TransportContext</code> associated with the current thread, if any.
42: *
43: * @return the current transport context, or <code>null</code> if none
44: */
45: public static TransportContext getTransportContext() {
46: return (TransportContext) transportContextHolder.get();
47: }
48: }
|