1 package org.objectweb.celtix.bindings; 2 3 import java.io.IOException ; 4 5 import javax.xml.ws.Binding; 6 7 import org.objectweb.celtix.Bus; 8 import org.objectweb.celtix.configuration.Configuration; 9 import org.objectweb.celtix.context.InputStreamMessageContext; 10 import org.objectweb.celtix.context.ObjectMessageContext; 11 import org.objectweb.celtix.context.ObjectMessageContextImpl; 12 import org.objectweb.celtix.context.OutputStreamMessageContext; 13 import org.objectweb.celtix.handlers.HandlerInvoker; 14 import org.objectweb.celtix.transports.ServerTransport; 15 import org.objectweb.celtix.transports.Transport; 16 import org.objectweb.celtix.ws.addressing.EndpointReferenceType; 17 18 public abstract class AbstractBindingBase implements BindingBase { 19 20 protected final Bus bus; 21 protected final EndpointReferenceType reference; 22 protected Transport transport; 23 24 protected AbstractBindingBase(Bus b, EndpointReferenceType r) { 25 bus = b; 26 reference = r; 27 } 28 29 public Bus getBus() { 30 return bus; 31 } 32 33 public EndpointReferenceType getEndpointReference() { 34 return reference; 35 } 36 37 public Binding getBinding() { 38 return getBindingImpl(); 39 } 40 41 public Transport retrieveTransport() { 42 return transport; 43 } 44 45 public ObjectMessageContext createObjectContext() { 46 return new ObjectMessageContextImpl(); 47 } 48 49 public HandlerInvoker createHandlerInvoker() { 50 return getBindingImpl().createHandlerInvoker(); 51 } 52 53 public void configureSystemHandlers(Configuration endpointConfiguration) { 54 getBindingImpl().configureSystemHandlers(endpointConfiguration); 55 } 56 57 public void send(Request request, DataBindingCallback callback) 58 throws IOException { 59 ObjectMessageContext objectCtx = request.getObjectMessageContext(); 60 BindingContextUtils.storeDataBindingCallback(objectCtx, callback); 61 62 try { 63 OutputStreamMessageContext ostreamCtx = request.process(null); 64 65 if (null != ostreamCtx) { 66 if (BindingContextUtils.isOnewayTransport(ostreamCtx) 67 || transport instanceof ServerTransport) { 68 ostreamCtx.getOutputStream().close(); 70 ostreamCtx.getCorrespondingInputStreamContext().getInputStream().close(); 71 } else { 72 ostreamCtx.getOutputStream().close(); 73 InputStreamMessageContext istreamCtx = 75 ostreamCtx.getCorrespondingInputStreamContext(); 76 Response response = new Response(request); 77 response.processProtocol(istreamCtx); 78 response.processLogical(null); 79 } 80 } 81 82 } finally { 83 request.complete(); 84 } 85 } 86 87 88 public abstract AbstractBindingImpl getBindingImpl(); 89 90 91 } 92 | Popular Tags |