KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > components > drools > JbiHelper


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.components.drools;
18
19 import javax.jbi.messaging.DeliveryChannel;
20 import javax.jbi.messaging.MessageExchange;
21 import javax.jbi.messaging.MessagingException;
22 import javax.jbi.messaging.NormalizedMessage;
23 import javax.xml.namespace.QName JavaDoc;
24
25 import org.drools.WorkingMemory;
26
27 /**
28  * A helper class for use inside a rule to forward a message to an endpoint
29  *
30  * @version $Revision: 426415 $
31  */

32 public class JbiHelper {
33     private DroolsComponent component;
34     private MessageExchange exchange;
35     private NormalizedMessage in;
36     private WorkingMemory memory;
37
38     public JbiHelper(DroolsComponent component,
39                      MessageExchange exchange,
40                      NormalizedMessage in,
41                      WorkingMemory memory) {
42         this.component = component;
43         this.exchange = exchange;
44         this.in = in;
45         this.memory = memory;
46     }
47
48     /**
49      * Forwards the inbound message to the given
50      *
51      * @param uri
52      * @param localPart
53      */

54     public void forwardToService(String JavaDoc uri, String JavaDoc localPart) throws MessagingException {
55         QName JavaDoc service = new QName JavaDoc(uri, localPart);
56         component.forwardToService(exchange, in, service);
57     }
58
59     public void forwardToService(QName JavaDoc name, QName JavaDoc operation, QName JavaDoc interfaceName) throws MessagingException {
60         component.forwardToService(exchange, in, name);
61     }
62
63     public void invoke(QName JavaDoc service, QName JavaDoc operation, QName JavaDoc interfaceName) throws MessagingException {
64         component.invoke(exchange, in, service, interfaceName, operation);
65     }
66
67     public void route(QName JavaDoc service, QName JavaDoc operation, QName JavaDoc interfaceName) throws MessagingException {
68         component.route(exchange, in, service, interfaceName, operation);
69     }
70
71     public DeliveryChannel getDeliveryChannel() throws MessagingException {
72         return getComponent().getContext().getDeliveryChannel();
73     }
74
75     public DroolsComponent getComponent() {
76         return component;
77     }
78
79     public MessageExchange getExchange() {
80         return exchange;
81     }
82
83     public NormalizedMessage getIn() {
84         return in;
85     }
86 }
87
Popular Tags