1 package org.objectweb.celtix.bus.ws.rm; 2 3 import java.util.ArrayList ; 4 import java.util.Collection ; 5 import java.util.List ; 6 7 import org.objectweb.celtix.bindings.AbstractBindingBase; 8 import org.objectweb.celtix.bindings.Request; 9 import org.objectweb.celtix.bus.ws.addressing.AddressingPropertiesImpl; 10 import org.objectweb.celtix.bus.ws.addressing.ContextUtils; 11 import org.objectweb.celtix.bus.ws.addressing.VersionTransformer; 12 import org.objectweb.celtix.transports.Transport; 13 import org.objectweb.celtix.ws.addressing.AddressingProperties; 14 import org.objectweb.celtix.ws.addressing.AttributedURIType; 15 import org.objectweb.celtix.ws.addressing.v200408.EndpointReferenceType; 16 import org.objectweb.celtix.ws.rm.AckRequestedType; 17 import org.objectweb.celtix.ws.rm.persistence.RMDestinationSequence; 18 19 public class SequenceInfoRequest extends Request { 20 21 public SequenceInfoRequest(AbstractBindingBase b, 22 Transport t, 23 EndpointReferenceType to) { 24 this(b, t, VersionTransformer.convert(to)); 25 } 26 27 public SequenceInfoRequest(AbstractBindingBase b, 28 Transport t, 29 org.objectweb.celtix.ws.addressing.EndpointReferenceType to) { 30 31 super(b, t, b.createObjectContext()); 32 33 if (to != null) { 34 ContextUtils.storeTo(to, getObjectMessageContext()); 35 } 36 37 ContextUtils.storeUsingAddressing(true, getObjectMessageContext()); 38 39 getObjectMessageContext().setRequestorRole(true); 40 AddressingProperties maps = new AddressingPropertiesImpl(); 41 AttributedURIType actionURI = 42 ContextUtils.WSA_OBJECT_FACTORY.createAttributedURIType(); 43 actionURI.setValue(RMUtils.getRMConstants().getSequenceInfoAction()); 44 maps.setAction(actionURI); 45 ContextUtils.storeMAPs(maps, getObjectMessageContext(), true, true, true, true); 46 47 setOneway(true); 48 49 } 56 57 public void requestAcknowledgement(Collection <SourceSequence> seqs) { 58 List <AckRequestedType> requested = new ArrayList <AckRequestedType>(); 59 for (AbstractSequenceImpl seq : seqs) { 60 AckRequestedType ar = RMUtils.getWSRMFactory().createAckRequestedType(); 61 ar.setIdentifier(seq.getIdentifier()); 62 requested.add(ar); 63 } 64 RMPropertiesImpl rmps = new RMPropertiesImpl(); 65 rmps.setAcksRequested(requested); 66 } 67 68 public void acknowledge(RMDestinationSequence seq) { 69 AddressingProperties maps = ContextUtils.retrieveMAPs(getObjectMessageContext(), true, true); 70 maps.getAction().setValue(RMUtils.getRMConstants().getSequenceAcknowledgmentAction()); 71 AttributedURIType toAddress = ContextUtils.WSA_OBJECT_FACTORY.createAttributedURIType(); 72 toAddress.setValue(seq.getAcksTo().getAddress().getValue()); 73 maps.setTo(toAddress); 74 } 77 78 public void lastMessage(SourceSequence seq) { 79 AddressingProperties maps = ContextUtils.retrieveMAPs(getObjectMessageContext(), true, true); 80 maps.getAction().setValue(RMUtils.getRMConstants().getLastMessageAction()); 81 RMPropertiesImpl rmps = new RMPropertiesImpl(); 82 seq.nextAndLastMessageNumber(); 83 rmps.setSequence(seq); 84 assert seq.isLastMessage(); 85 RMContextUtils.storeRMProperties(getObjectMessageContext(), rmps, true); 86 } 87 } 88 | Popular Tags |