1 package org.objectweb.celtix.bindings; 2 3 4 import javax.xml.ws.handler.MessageContext; 5 6 import org.objectweb.celtix.context.OutputStreamMessageContext; 7 8 import static org.objectweb.celtix.bindings.JAXWSConstants.DATABINDING_CALLBACK_PROPERTY; 9 import static org.objectweb.celtix.bindings.JAXWSConstants.DISPATCH_PROPERTY; 10 import static org.objectweb.celtix.bindings.JAXWSConstants.SERVER_BINDING_ENDPOINT_CALLBACK_PROPERTY; 11 import static org.objectweb.celtix.context.InputStreamMessageContext.ASYNC_ONEWAY_DISPATCH; 12 import static org.objectweb.celtix.context.InputStreamMessageContext.DECOUPLED_RESPONSE; 13 import static org.objectweb.celtix.context.ObjectMessageContext.CORRELATION_IN; 14 15 16 19 20 public final class BindingContextUtils { 21 22 25 private BindingContextUtils() { 26 } 27 28 34 public static void storeDataBindingCallback(MessageContext context, DataBindingCallback callback) { 35 context.put(DATABINDING_CALLBACK_PROPERTY, callback); 36 context.setScope(DATABINDING_CALLBACK_PROPERTY, MessageContext.Scope.HANDLER); 37 } 38 39 45 public static DataBindingCallback retrieveDataBindingCallback(MessageContext context) { 46 return (DataBindingCallback)context.get(DATABINDING_CALLBACK_PROPERTY); 47 } 48 49 55 public static void storeServerBindingEndpointCallback(MessageContext context, 56 ServerBindingEndpointCallback sbec) { 57 context.put(SERVER_BINDING_ENDPOINT_CALLBACK_PROPERTY, sbec); 58 context.setScope(SERVER_BINDING_ENDPOINT_CALLBACK_PROPERTY, MessageContext.Scope.HANDLER); 59 } 60 61 67 public static ServerBindingEndpointCallback retrieveServerBindingEndpointCallback( 68 MessageContext context) { 69 return (ServerBindingEndpointCallback)context.get(SERVER_BINDING_ENDPOINT_CALLBACK_PROPERTY); 70 } 71 72 79 public static boolean isOnewayMethod(MessageContext context) { 80 DataBindingCallback cb = retrieveDataBindingCallback(context); 81 if (cb == null) { 82 if (!context.containsKey(OutputStreamMessageContext.ONEWAY_MESSAGE_TF)) { 83 return false; 84 } 85 return ((Boolean )context.get(OutputStreamMessageContext.ONEWAY_MESSAGE_TF)).booleanValue(); 86 } 87 return cb.isOneWay(); 88 } 89 90 97 public static boolean isOnewayTransport(MessageContext context) { 98 Boolean b = (Boolean )context.get(OutputStreamMessageContext.ONEWAY_MESSAGE_TF); 99 if (null != b) { 100 return b.booleanValue(); 101 } 102 return false; 103 } 104 105 111 public static String retrieveCorrelationID(MessageContext context) { 112 return (String )context.get(CORRELATION_IN); 113 } 114 115 121 public static void storeDispatch(MessageContext context, boolean dispatch) { 122 context.put(DISPATCH_PROPERTY, dispatch ? Boolean.TRUE : Boolean.FALSE); 123 context.setScope(DISPATCH_PROPERTY, MessageContext.Scope.HANDLER); 124 } 125 126 132 public static boolean retrieveDispatch(MessageContext context) { 133 Boolean b = (Boolean )context.get(DISPATCH_PROPERTY); 134 return null == b || b.booleanValue(); 135 } 136 137 143 public static void storeAsyncOnewayDispatch(MessageContext context, boolean async) { 144 context.put(ASYNC_ONEWAY_DISPATCH, async ? Boolean.TRUE : Boolean.FALSE); 145 context.setScope(ASYNC_ONEWAY_DISPATCH, MessageContext.Scope.HANDLER); 146 } 147 148 154 public static boolean retrieveAsyncOnewayDispatch(MessageContext context) { 155 Boolean b = (Boolean )context.get(ASYNC_ONEWAY_DISPATCH); 156 return b != null && b.booleanValue(); 157 } 158 159 165 public static void storeDecoupledResponse(MessageContext context, boolean decoupled) { 166 context.put(DECOUPLED_RESPONSE, decoupled ? Boolean.TRUE : Boolean.FALSE); 167 context.setScope(DECOUPLED_RESPONSE, MessageContext.Scope.HANDLER); 168 } 169 170 176 public static boolean retrieveDecoupledResponse(MessageContext context) { 177 Boolean b = (Boolean )context.get(DECOUPLED_RESPONSE); 178 return b != null && b.booleanValue(); 179 } 180 181 } 182 | Popular Tags |