KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > server > msgprocessors > CreateSequenceResponseProcessor


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.sandesha.server.msgprocessors;
18
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.message.addressing.RelatesTo;
21 import org.apache.sandesha.IStorageManager;
22 import org.apache.sandesha.RMMessageContext;
23 import org.apache.sandesha.ws.rm.CreateSequenceResponse;
24
25 /**
26  * This is the processor for the CreateSequenceRespones.
27  *
28  * @author Jaliya Ekanayake
29  */

30 public class CreateSequenceResponseProcessor implements IRMMessageProcessor {
31     IStorageManager storageManager = null;
32
33     public CreateSequenceResponseProcessor(IStorageManager storageManger) {
34         this.storageManager = storageManger;
35     }
36
37     public boolean processMessage(RMMessageContext rmMessageContext) throws AxisFault {
38
39         CreateSequenceResponse createSeqRes = rmMessageContext.getRMHeaders()
40                 .getCreateSequenceResponse();
41
42         RelatesTo relatesTo = (RelatesTo) rmMessageContext.getAddressingHeaders().getRelatesTo()
43                 .get(0);
44         String JavaDoc sequenceID = createSeqRes.getIdentifier().toString();
45         //Approve the sequences. Now we can start sending the messages using that sequence.
46

47         storageManager.setApprovedOutSequence(relatesTo.getURI().toString(), sequenceID);
48         String JavaDoc offerID = storageManager.getOffer(relatesTo.getURI().toString());
49
50         if (createSeqRes.getAccept() != null) {
51             storageManager.addRequestedSequence(offerID);
52             storageManager.setAcksTo(offerID,
53                     createSeqRes.getAccept().getAcksTo().getAddress().toString());
54         }
55         //No response to this message.
56
return false;
57     }
58
59 }
Popular Tags