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 java.util.Properties;
020    
021    import org.apache.camel.Consumer;
022    import org.apache.camel.Processor;
023    import org.apache.camel.Producer;
024    import org.apache.camel.impl.DefaultEndpoint;
025    import org.apache.cxf.Bus;
026    import org.apache.cxf.message.Message;
027    
028    /**
029     * The endpoint in the service engine
030     * 
031     * @version $Revision: 563665 $
032     */
033    public class CxfInvokeEndpoint extends DefaultEndpoint<CxfExchange> {
034        private CxfBinding binding;
035        private final CxfInvokeComponent component;
036        private boolean inOut = true;
037        private Properties properties;
038    
039        public CxfInvokeEndpoint(String uri, CxfInvokeComponent component, Properties properties) {
040            super(uri, component);
041            this.component = component;
042            this.properties = properties;
043        }
044    
045        public Producer<CxfExchange> createProducer() throws Exception {
046            return new CxfInvokeProducer(this);
047        }
048    
049        public Consumer<CxfExchange> createConsumer(Processor processor) throws Exception {
050            return new CxfInvokeConsumer(this, processor);
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 CxfInvokeComponent getComponent() {
081            return component;
082        }
083    
084        public String getProperty(String key) {
085            return properties.getProperty(key);
086        }
087    
088        public Bus getBus() {
089            return component.getBus();
090        }
091    
092        public boolean isSingleton() {
093            return true;
094        }
095    
096    }