KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jbi > nmr > flow > st > STFlow


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

17 package org.apache.servicemix.jbi.nmr.flow.st;
18
19 import org.apache.servicemix.jbi.messaging.MessageExchangeImpl;
20 import org.apache.servicemix.jbi.nmr.flow.AbstractFlow;
21 import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint;
22
23 import javax.jbi.messaging.ExchangeStatus;
24 import javax.jbi.messaging.MessageExchange;
25 import javax.jbi.messaging.MessagingException;
26 import javax.jbi.messaging.MessageExchange.Role;
27
28 /**
29  * A simple Straight through flow.
30  *
31  * A MessageExchange is routed straight to it's destination with
32  * no staging or buffering. A straight through flow is best suited
33  * for the cases where the ServiceMix JBIContainer is deployed with simple
34  * flows (no state) or embedding, or where latency needs to be as low as possible.
35  *
36  * @version $Revision: 426415 $
37  * @org.apache.xbean.XBean element="stFlow"
38  */

39 public class STFlow extends AbstractFlow {
40     
41     /**
42      * Distribute an ExchangePacket
43      *
44      * @param packet
45      * @throws MessagingException
46      */

47     protected void doSend(MessageExchangeImpl me) throws MessagingException {
48         if (me.getDestinationId() == null) {
49             me.setDestinationId(((AbstractServiceEndpoint) me.getEndpoint()).getComponentNameSpace());
50         }
51         doRouting(me);
52     }
53     
54     /**
55      * The type of Flow
56      * @return the type
57      */

58     public String JavaDoc getDescription(){
59         return "st";
60     }
61     
62     /**
63      * Check if the flow can support the requested QoS for this exchange
64      * @param me the exchange to check
65      * @return true if this flow can handle the given exchange
66      */

67     public boolean canHandle(MessageExchange me) {
68         if (isPersistent(me)) {
69             return false;
70         }
71         if (isClustered(me)) {
72             return false;
73         }
74         // We can not handle transactional exchanges:
75
// * asynchronous is a bit weird when the transaction is conveyed
76
// * synchronous could lead to deadlock if the provider uses Push delivery
77
if (isTransacted(me)) {
78             return false;
79         }
80         return true;
81     }
82     
83 }
84
Popular Tags