01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.jaxws;
19:
20: import java.util.HashMap;
21: import java.util.Iterator;
22: import java.util.Map;
23:
24: import javax.xml.ws.Binding;
25: import javax.xml.ws.BindingProvider; //TODO JAX-WS 2.1
26: //import javax.xml.ws.EndpointReference;
27: import javax.xml.ws.handler.MessageContext;
28:
29: public class BindingProviderImpl implements BindingProvider {
30:
31: protected ThreadLocal<Map<String, Object>> requestContext = new ThreadLocal<Map<String, Object>>();
32: protected ThreadLocal<Map<String, Object>> responseContext = new ThreadLocal<Map<String, Object>>();
33: private final Binding binding;
34:
35: public BindingProviderImpl() {
36: binding = null;
37: }
38:
39: public BindingProviderImpl(Binding b) {
40: binding = b;
41: }
42:
43: public Map<String, Object> getRequestContext() {
44: if (null == requestContext.get()) {
45: requestContext.set(new HashMap<String, Object>());
46: }
47: return requestContext.get();
48: }
49:
50: public Map<String, Object> getResponseContext() {
51: if (null == responseContext.get()) {
52: responseContext.set(new HashMap<String, Object>());
53: }
54: return responseContext.get();
55: }
56:
57: protected void clearContext(ThreadLocal<Map<String, Object>> context) {
58: context.set(null);
59: }
60:
61: public Binding getBinding() {
62: return binding;
63: }
64:
65: protected void populateResponseContext(MessageContext ctx) {
66:
67: Iterator<String> iter = ctx.keySet().iterator();
68: Map<String, Object> respCtx = getResponseContext();
69: while (iter.hasNext()) {
70: String obj = iter.next();
71: if (MessageContext.Scope.APPLICATION.compareTo(ctx
72: .getScope(obj)) == 0) {
73: respCtx.put(obj, ctx.get(obj));
74: }
75: }
76: }
77:
78: /*
79: //TODO JAX-WS 2.1
80: public EndpointReference getEndpointReference() {
81: // TODO
82: throw new UnsupportedOperationException();
83: }
84:
85: public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
86: // TODO
87: throw new UnsupportedOperationException();
88: }
89: */
90:
91: }
|