1 package org.objectweb.celtix.bus.ws.rm; 2 3 import java.math.BigInteger ; 4 import java.util.Set ; 5 import java.util.logging.Logger ; 6 7 import javax.annotation.Resource; 8 import javax.xml.namespace.QName ; 9 import javax.xml.ws.handler.MessageContext; 10 import javax.xml.ws.handler.soap.SOAPHandler; 11 import javax.xml.ws.handler.soap.SOAPMessageContext; 12 13 import org.objectweb.celtix.bindings.AbstractBindingBase; 14 import org.objectweb.celtix.bindings.ClientBinding; 15 import org.objectweb.celtix.bindings.JAXWSConstants; 16 import org.objectweb.celtix.bindings.ServerBinding; 17 import org.objectweb.celtix.bus.ws.addressing.AddressingPropertiesImpl; 18 import org.objectweb.celtix.bus.ws.addressing.ContextUtils; 19 import org.objectweb.celtix.bus.ws.addressing.VersionTransformer; 20 import org.objectweb.celtix.common.logging.LogUtils; 21 import org.objectweb.celtix.ws.rm.Identifier; 22 23 24 public class RMPersistenceHandler implements SOAPHandler<SOAPMessageContext> { 25 26 private static final Logger LOG = LogUtils.getL7dLogger(RMPersistenceHandler.class); 27 28 @Resource(name = JAXWSConstants.CLIENT_BINDING_PROPERTY) private ClientBinding clientBinding; 29 @Resource(name = JAXWSConstants.SERVER_BINDING_PROPERTY) private ServerBinding serverBinding; 30 31 public Set <QName > getHeaders() { 32 return null; 33 } 34 35 public void close(MessageContext arg0) { 36 } 37 38 public boolean handleFault(SOAPMessageContext context) { 39 if (ContextUtils.isOutbound(context)) { 40 handleOutbound(context); 41 } 42 return true; 43 } 44 45 public boolean handleMessage(SOAPMessageContext context) { 46 if (ContextUtils.isOutbound(context)) { 47 handleOutbound(context); 48 } 49 return true; 50 } 51 52 void handleOutbound(SOAPMessageContext context) { 53 LOG.entering(getClass().getName(), "handleOutbound"); 54 if (!isApplicationMessage(context)) { 56 return; 57 } 58 59 63 RMPropertiesImpl rmpsOut = 64 (RMPropertiesImpl)RMContextUtils.retrieveRMProperties(context, true); 65 67 if (null == rmpsOut) { 68 return; 71 } 72 73 if (null == rmpsOut.getSequence()) { 74 return; 76 } 77 78 BigInteger mn = rmpsOut.getSequence().getMessageNumber(); 79 boolean lm = null != rmpsOut.getSequence().getLastMessage(); 80 Identifier sid = rmpsOut.getSequence().getIdentifier(); 81 82 87 SourceSequence seq = new SourceSequence(sid, null, null, mn, lm); 88 RMHandler handler = RMHandler.getHandler(getBinding()); 89 RMMessageImpl msg = new RMMessageImpl(mn, context); 90 91 handler.getSource().addUnacknowledged(seq, msg); 92 } 93 94 AbstractBindingBase getBinding() { 95 if (null != clientBinding) { 96 return (AbstractBindingBase)clientBinding; 97 } 98 return (AbstractBindingBase)serverBinding; 99 } 100 101 private boolean isApplicationMessage(SOAPMessageContext context) { 102 boolean isApplicationMessage = true; 103 AddressingPropertiesImpl maps = 104 ContextUtils.retrieveMAPs(context, false, true); 105 106 if (null == maps) { 107 return false; 108 } 109 110 maps.exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME); 112 113 String action = null; 114 if (maps != null && null != maps.getAction()) { 115 action = maps.getAction().getValue(); 116 } 117 if (RMUtils.getRMConstants().getCreateSequenceAction().equals(action) 118 || RMUtils.getRMConstants().getCreateSequenceResponseAction().equals(action) 119 || RMUtils.getRMConstants().getTerminateSequenceAction().equals(action) 120 || RMUtils.getRMConstants().getLastMessageAction().equals(action) 121 || RMUtils.getRMConstants().getSequenceAcknowledgmentAction().equals(action) 122 || RMUtils.getRMConstants().getSequenceInfoAction().equals(action)) { 123 isApplicationMessage = false; 124 } 125 return isApplicationMessage; 126 } 127 128 129 } 130 | Popular Tags |