KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > server > RMMessageProcessorIdentifier


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;
18
19 import org.apache.axis.message.addressing.AddressingHeaders;
20 import org.apache.sandesha.Constants;
21 import org.apache.sandesha.IStorageManager;
22 import org.apache.sandesha.RMMessageContext;
23 import org.apache.sandesha.server.msgprocessors.*;
24 import org.apache.sandesha.ws.rm.RMHeaders;
25
26 /**
27  * @author Jaliya Ekanayake
28  */

29 public class RMMessageProcessorIdentifier {
30     /**
31      * This method will identify the messages. Messages specific to the
32      * reliablility are identified using the action. Request messages are
33      * identified using the message number property.
34      *
35      * @param rmMessageContext
36      * @param storageManager
37      * @return
38      */

39     public static IRMMessageProcessor getMessageProcessor(RMMessageContext rmMessageContext,
40                                                           IStorageManager storageManager) {
41
42         AddressingHeaders addrHeaders = rmMessageContext.getAddressingHeaders();
43         RMHeaders rmHeaders = rmMessageContext.getRMHeaders();
44
45         if (addrHeaders.getAction() != null) {
46             if (addrHeaders.getAction().toString().equals(Constants.WSRM.ACTION_CREATE_SEQUENCE)) {
47                 return new CreateSequenceProcessor(storageManager);
48             } else if (addrHeaders.getAction().toString().equals(Constants.WSRM.ACTION_CREATE_SEQUENCE_RESPONSE)) {
49                 return new CreateSequenceResponseProcessor(storageManager);
50             } else if (addrHeaders.getAction().toString().equals(Constants.WSRM.ACTION_TERMINATE_SEQUENCE)) {
51                 return new TerminateSequenceProcessor(storageManager);
52             } else if (rmHeaders.getSequenceAcknowledgement() != null ||
53                     rmHeaders.getSequence().getMessageNumber() != null) {
54                 return new CompositeProcessor(storageManager);
55             } else
56                 return new FaultProcessor(storageManager);
57         } else if (rmHeaders.getSequenceAcknowledgement() != null ||
58                 rmHeaders.getSequence().getMessageNumber() != null) {
59             return new CompositeProcessor(storageManager);
60         } else
61             return new FaultProcessor(storageManager);
62     }
63 }
Popular Tags