KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jsr181 > EndpointDeliveryChannel


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.jsr181;
18
19 import javax.jbi.messaging.DeliveryChannel;
20 import javax.jbi.messaging.ExchangeStatus;
21 import javax.jbi.messaging.MessageExchange;
22 import javax.jbi.messaging.MessageExchangeFactory;
23 import javax.jbi.messaging.MessagingException;
24 import javax.jbi.servicedesc.ServiceEndpoint;
25 import javax.xml.namespace.QName JavaDoc;
26
27 /**
28  * This class is a wrapper around an existing DeliveryChannel
29  * that will be given to service engine endpoints so that
30  * they are able to send messages and to interact with the
31  * JBI container.
32  *
33  * @author gnodet
34  */

35 public class EndpointDeliveryChannel implements DeliveryChannel {
36
37     private final DeliveryChannel channel;
38     
39     public EndpointDeliveryChannel(DeliveryChannel channel) {
40         this.channel = channel;
41     }
42
43     public MessageExchange accept() throws MessagingException {
44         throw new UnsupportedOperationException JavaDoc();
45     }
46
47     public MessageExchange accept(long timeout) throws MessagingException {
48         throw new UnsupportedOperationException JavaDoc();
49     }
50
51     public void close() throws MessagingException {
52         throw new UnsupportedOperationException JavaDoc();
53     }
54
55     public MessageExchangeFactory createExchangeFactory() {
56         return channel.createExchangeFactory();
57     }
58
59     public MessageExchangeFactory createExchangeFactory(QName JavaDoc interfaceName) {
60         return channel.createExchangeFactory(interfaceName);
61     }
62
63     public MessageExchangeFactory createExchangeFactory(ServiceEndpoint endpoint) {
64         return channel.createExchangeFactory(endpoint);
65     }
66
67     public MessageExchangeFactory createExchangeFactoryForService(QName JavaDoc serviceName) {
68         return channel.createExchangeFactoryForService(serviceName);
69     }
70
71     public void send(MessageExchange exchange) throws MessagingException {
72         if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
73             throw new UnsupportedOperationException JavaDoc("Asynchonous send of active exchanges are not supported");
74         }
75         channel.send(exchange);
76     }
77
78     public boolean sendSync(MessageExchange exchange, long timeout) throws MessagingException {
79         return channel.sendSync(exchange, timeout);
80     }
81
82     public boolean sendSync(MessageExchange exchange) throws MessagingException {
83         return channel.sendSync(exchange);
84     }
85 }
86
Popular Tags