01: package org.objectweb.celtix.bus.jaxws;
02:
03: import java.util.HashMap;
04: import java.util.Iterator;
05: import java.util.Map;
06:
07: import javax.xml.ws.Binding;
08: import javax.xml.ws.BindingProvider;
09: import javax.xml.ws.handler.MessageContext;
10:
11: public class BindingProviderImpl implements BindingProvider {
12:
13: private Binding binding;
14: private ThreadLocal requestContext;
15: private Map<String, Object> responseContext;
16:
17: public BindingProviderImpl() {
18: }
19:
20: @SuppressWarnings("unchecked")
21: public Map<String, Object> getRequestContext() {
22: if (requestContext == null) {
23: requestContext = new ThreadLocal() {
24: protected synchronized Object initialValue() {
25: return new HashMap<String, Object>();
26: }
27: };
28: }
29: return (Map<String, Object>) requestContext.get();
30: }
31:
32: public Map<String, Object> getResponseContext() {
33: if (responseContext == null) {
34: responseContext = new HashMap<String, Object>();
35: }
36: return responseContext;
37: }
38:
39: public Binding getBinding() {
40: return binding;
41: }
42:
43: protected void setBinding(Binding b) {
44: binding = b;
45: }
46:
47: protected void populateResponseContext(MessageContext ctx) {
48:
49: Iterator<String> iter = ctx.keySet().iterator();
50: Map<String, Object> respCtx = getResponseContext();
51: while (iter.hasNext()) {
52: String obj = iter.next();
53: if (MessageContext.Scope.APPLICATION.compareTo(ctx
54: .getScope(obj)) == 0) {
55: respCtx.put(obj, ctx.get(obj));
56: }
57: }
58: }
59:
60: }
|