KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > client > DefaultDestination


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.client;
18
19 import javax.jbi.messaging.InOnly;
20 import javax.jbi.messaging.InOptionalOut;
21 import javax.jbi.messaging.InOut;
22 import javax.jbi.messaging.MessageExchange;
23 import javax.jbi.messaging.MessagingException;
24 import javax.jbi.messaging.RobustInOnly;
25
26 import org.apache.servicemix.jbi.resolver.URIResolver;
27
28 /**
29  *
30  * @version $Revision: 432921 $
31  */

32 public class DefaultDestination implements Destination {
33
34     private ServiceMixClient client;
35     private String JavaDoc destinationUri;
36
37     public DefaultDestination(ServiceMixClient client, String JavaDoc destinationUri) throws MessagingException {
38         this.client = client;
39         this.destinationUri = destinationUri;
40     }
41
42     public InOnly createInOnlyExchange() throws MessagingException {
43         InOnly answer = client.createInOnlyExchange();
44         configure(answer);
45         return answer;
46     }
47
48     public InOptionalOut createInOptionalOutExchange() throws MessagingException {
49         InOptionalOut answer = client.createInOptionalOutExchange();
50         configure(answer);
51         return answer;
52     }
53
54     public InOut createInOutExchange() throws MessagingException {
55         InOut answer = client.createInOutExchange();
56         configure(answer);
57         return answer;
58     }
59
60     public RobustInOnly createRobustInOnlyExchange() throws MessagingException {
61         RobustInOnly answer = client.createRobustInOnlyExchange();
62         configure(answer);
63         return answer;
64     }
65
66     public Message createInOnlyMessage() throws MessagingException {
67         return (Message) createInOnlyExchange().getInMessage();
68     }
69     
70     protected void configure(MessageExchange exchange) throws MessagingException {
71         URIResolver.configureExchange(exchange, client.getContext(), destinationUri);
72     }
73
74 }
75
Popular Tags