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.camel.component.cxf;
018    
019    import org.apache.camel.Consumer;
020    import org.apache.camel.Processor;
021    import org.apache.camel.Producer;
022    import org.apache.camel.impl.DefaultEndpoint;
023    import org.apache.cxf.BusException;
024    import org.apache.cxf.message.Message;
025    import org.apache.cxf.service.model.EndpointInfo;
026    import org.apache.cxf.transport.local.LocalTransportFactory;
027    
028    /**
029     * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Endpoint</a>
030     * 
031     * @version $Revision: 563665 $
032     */
033    public class CxfEndpoint extends DefaultEndpoint<CxfExchange> {
034        private CxfBinding binding;
035        private final CxfComponent component;
036        private final EndpointInfo endpointInfo;
037        private boolean inOut = true;
038    
039        public CxfEndpoint(String uri, CxfComponent component, EndpointInfo endpointInfo) {
040            super(uri, component);
041            this.component = component;
042            this.endpointInfo = endpointInfo;
043        }
044    
045        public Producer<CxfExchange> createProducer() throws Exception {
046            return new CxfProducer(this, getLocalTransportFactory());
047        }
048    
049        public Consumer<CxfExchange> createConsumer(Processor processor) throws Exception {
050            return new CxfConsumer(this, processor, getLocalTransportFactory());
051        }
052    
053        public CxfExchange createExchange() {
054            return new CxfExchange(getContext(), getBinding());
055        }
056    
057        public CxfExchange createExchange(Message inMessage) {
058            return new CxfExchange(getContext(), getBinding(), inMessage);
059        }
060    
061        public CxfBinding getBinding() {
062            if (binding == null) {
063                binding = new CxfBinding();
064            }
065            return binding;
066        }
067    
068        public void setBinding(CxfBinding binding) {
069            this.binding = binding;
070        }
071    
072        public boolean isInOut() {
073            return inOut;
074        }
075    
076        public void setInOut(boolean inOut) {
077            this.inOut = inOut;
078        }
079    
080        public LocalTransportFactory getLocalTransportFactory() throws BusException {
081            return component.getLocalTransportFactory();
082        }
083    
084        public EndpointInfo getEndpointInfo() {
085            return endpointInfo;
086        }
087    
088        public CxfComponent getComponent() {
089            return component;
090        }
091    
092        public boolean isSingleton() {
093            return true;
094        }
095    
096    }