001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.servicemix.client;
018
019 import javax.jbi.messaging.InOnly;
020 import javax.jbi.messaging.InOptionalOut;
021 import javax.jbi.messaging.InOut;
022 import javax.jbi.messaging.MessageExchange;
023 import javax.jbi.messaging.MessagingException;
024 import javax.jbi.messaging.RobustInOnly;
025
026 import org.apache.servicemix.jbi.resolver.URIResolver;
027
028 /**
029 *
030 * @version $Revision: 432921 $
031 */
032 public class DefaultDestination implements Destination {
033
034 private ServiceMixClient client;
035 private String destinationUri;
036
037 public DefaultDestination(ServiceMixClient client, String destinationUri) throws MessagingException {
038 this.client = client;
039 this.destinationUri = destinationUri;
040 }
041
042 public InOnly createInOnlyExchange() throws MessagingException {
043 InOnly answer = client.createInOnlyExchange();
044 configure(answer);
045 return answer;
046 }
047
048 public InOptionalOut createInOptionalOutExchange() throws MessagingException {
049 InOptionalOut answer = client.createInOptionalOutExchange();
050 configure(answer);
051 return answer;
052 }
053
054 public InOut createInOutExchange() throws MessagingException {
055 InOut answer = client.createInOutExchange();
056 configure(answer);
057 return answer;
058 }
059
060 public RobustInOnly createRobustInOnlyExchange() throws MessagingException {
061 RobustInOnly answer = client.createRobustInOnlyExchange();
062 configure(answer);
063 return answer;
064 }
065
066 public Message createInOnlyMessage() throws MessagingException {
067 return (Message) createInOnlyExchange().getInMessage();
068 }
069
070 protected void configure(MessageExchange exchange) throws MessagingException {
071 URIResolver.configureExchange(exchange, client.getContext(), destinationUri);
072 }
073
074 }