1 package org.objectweb.celtix.bus.jaxws; 2 3 import java.util.HashMap ; 4 import java.util.Iterator ; 5 import java.util.Map ; 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 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.getScope(obj)) == 0) { 54 respCtx.put(obj, ctx.get(obj)); 55 } 56 } 57 } 58 59 } 60 | Popular Tags |