KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > jaxws > BindingProviderImpl


1 package org.objectweb.celtix.bus.jaxws;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Iterator JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import javax.xml.ws.Binding;
8 import javax.xml.ws.BindingProvider;
9 import javax.xml.ws.handler.MessageContext;
10
11 public class BindingProviderImpl implements BindingProvider {
12     
13     private Binding binding;
14     private ThreadLocal JavaDoc requestContext;
15     private Map JavaDoc<String JavaDoc, Object JavaDoc> responseContext;
16     
17     public BindingProviderImpl() {
18     }
19     
20     @SuppressWarnings JavaDoc("unchecked")
21     public Map JavaDoc<String JavaDoc, Object JavaDoc> getRequestContext() {
22         if (requestContext == null) {
23             requestContext = new ThreadLocal JavaDoc() {
24                 protected synchronized Object JavaDoc initialValue() {
25                     return new HashMap JavaDoc<String JavaDoc, Object JavaDoc>();
26                 }
27             };
28         }
29         return (Map JavaDoc<String JavaDoc, Object JavaDoc>)requestContext.get();
30     }
31     
32     public Map JavaDoc<String JavaDoc, Object JavaDoc> getResponseContext() {
33         if (responseContext == null) {
34             responseContext = new HashMap JavaDoc<String JavaDoc, Object JavaDoc>();
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 JavaDoc<String JavaDoc> iter = ctx.keySet().iterator();
50         Map JavaDoc<String JavaDoc, Object JavaDoc> respCtx = getResponseContext();
51         while (iter.hasNext()) {
52             String JavaDoc obj = iter.next();
53             if (MessageContext.Scope.APPLICATION.compareTo(ctx.getScope(obj)) == 0) {
54                 respCtx.put(obj, ctx.get(obj));
55             }
56         }
57     }
58
59 }
60
Popular Tags