001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.camel.component.cxf.transport;
019
020 import org.apache.camel.CamelContext;
021 import org.apache.cxf.Bus;
022 import org.apache.cxf.configuration.Configurer;
023 import org.apache.cxf.service.model.EndpointInfo;
024 import org.apache.cxf.transport.AbstractTransportFactory;
025 import org.apache.cxf.transport.Conduit;
026 import org.apache.cxf.transport.ConduitInitiator;
027 import org.apache.cxf.transport.Destination;
028 import org.apache.cxf.transport.DestinationFactory;
029 import org.apache.cxf.ws.addressing.EndpointReferenceType;
030
031 import javax.annotation.Resource;
032 import java.io.IOException;
033 import java.util.HashSet;
034 import java.util.Set;
035
036 /**
037 * @version $Revision: 522906 $
038 */
039 public class CamelTransportFactory extends AbstractTransportFactory implements ConduitInitiator, DestinationFactory {
040 private static final Set<String> URI_PREFIXES = new HashSet<String>();
041
042 static {
043 URI_PREFIXES.add("camel://");
044 }
045
046 private Bus bus;
047 private CamelContext camelContext;
048
049 @Resource
050 public void setBus(Bus b) {
051 bus = b;
052 }
053
054 public Bus getBus() {
055 return bus;
056 }
057
058 public CamelContext getCamelContext() {
059 return camelContext;
060 }
061
062 @Resource
063 public void setCamelContext(CamelContext camelContext) {
064 this.camelContext = camelContext;
065 }
066
067 public Conduit getConduit(EndpointInfo targetInfo) throws IOException {
068 return getConduit(targetInfo, null);
069 }
070
071 public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target) throws IOException {
072 return new CamelConduit(camelContext, bus, endpointInfo, target);
073 }
074
075 public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
076 CamelDestination destination = new CamelDestination(camelContext, bus, this, endpointInfo);
077 Configurer configurer = bus.getExtension(Configurer.class);
078 if (null != configurer) {
079 configurer.configureBean(destination);
080 }
081 return destination;
082 }
083
084 public Set<String> getUriPrefixes() {
085 return URI_PREFIXES;
086 }
087 }
088