01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.script;
18:
19: import javax.jbi.component.ComponentContext;
20: import javax.jbi.messaging.DeliveryChannel;
21: import javax.jbi.messaging.MessageExchange;
22: import javax.jbi.messaging.MessageExchangeFactory;
23: import javax.jbi.messaging.MessagingException;
24:
25: /**
26: * This helper object can be injected into your scripts to allow to quick access
27: * to basic JBI operations
28: *
29: * @org.apache.xbean.XBean element="exchangeHelper" description="ServiceMix
30: * Scripting Helper"
31: */
32: public class ScriptExchangeHelper implements ScriptHelper {
33:
34: protected ScriptExchangeProcessorEndpoint endpoint;
35:
36: /*
37: * (non-Javadoc)
38: *
39: * @see org.apache.servicemix.script.ScriptHelper#setScriptExchangeProcessorEndpoint(
40: * org.apache.servicemix.script.ScriptExchangeProcessorEndpoint)
41: */
42: public void setScriptExchangeProcessorEndpoint(
43: ScriptExchangeProcessorEndpoint ep) {
44: this .endpoint = ep;
45: }
46:
47: public void doneExchange(MessageExchange exchange)
48: throws MessagingException {
49: endpoint.done(exchange);
50: }
51:
52: public void failExchange(MessageExchange exchange,
53: Exception exception) throws MessagingException {
54: endpoint.fail(exchange, exception);
55: }
56:
57: public void sendExchange(MessageExchange exchange)
58: throws MessagingException {
59: endpoint.send(exchange);
60: }
61:
62: public void sendSyncExchange(MessageExchange exchange)
63: throws MessagingException {
64: endpoint.sendSync(exchange);
65: }
66:
67: public DeliveryChannel getChannel() {
68: return endpoint.getChannel();
69: }
70:
71: public ComponentContext getContext() {
72: return endpoint.getContext();
73: }
74:
75: public MessageExchangeFactory getExchangeFactory() {
76: return endpoint.getExchangeFactory();
77: }
78: }
|