KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > ws > rm > SequenceInfoRequest


1 package org.objectweb.celtix.bus.ws.rm;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Collection JavaDoc;
5 import java.util.List JavaDoc;
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         // NOTE: Not storing a method in the context causes BindingContextUtils.isOnewayMethod
50
// to always return false (although effectively all standalone requests based on the
51
// the SequenceInfo request are oneway requests).
52
// An important implication of this is that we don't expect partial
53
// responses sent in response to such messages, which is fine as we normally only piggyback
54
// sequence acknowledgements onto application messages.
55
}
56     
57     public void requestAcknowledgement(Collection JavaDoc<SourceSequence> seqs) {
58         List JavaDoc<AckRequestedType> requested = new ArrayList JavaDoc<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         // rm properties will be created (and actual acknowledgments added)
75
// by rm handler upon outbound processing of this message
76
}
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