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.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 destinationUri;
36:
37: public DefaultDestination(ServiceMixClient client,
38: String destinationUri) throws MessagingException {
39: this .client = client;
40: this .destinationUri = destinationUri;
41: }
42:
43: public InOnly createInOnlyExchange() throws MessagingException {
44: InOnly answer = client.createInOnlyExchange();
45: configure(answer);
46: return answer;
47: }
48:
49: public InOptionalOut createInOptionalOutExchange()
50: throws MessagingException {
51: InOptionalOut answer = client.createInOptionalOutExchange();
52: configure(answer);
53: return answer;
54: }
55:
56: public InOut createInOutExchange() throws MessagingException {
57: InOut answer = client.createInOutExchange();
58: configure(answer);
59: return answer;
60: }
61:
62: public RobustInOnly createRobustInOnlyExchange()
63: throws MessagingException {
64: RobustInOnly answer = client.createRobustInOnlyExchange();
65: configure(answer);
66: return answer;
67: }
68:
69: public Message createInOnlyMessage() throws MessagingException {
70: return (Message) createInOnlyExchange().getInMessage();
71: }
72:
73: protected void configure(MessageExchange exchange)
74: throws MessagingException {
75: URIResolver.configureExchange(exchange, client.getContext(),
76: destinationUri);
77: }
78:
79: }
|