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.spring.integration;
018    
019    import org.apache.camel.CamelContext;
020    import org.apache.camel.Consumer;
021    import org.apache.camel.Exchange;
022    import org.apache.camel.ExchangePattern;
023    import org.apache.camel.Processor;
024    import org.apache.camel.Producer;
025    import org.apache.camel.impl.DefaultExchange;
026    import org.apache.camel.impl.ScheduledPollEndpoint;
027    import org.apache.commons.logging.Log;
028    import org.apache.commons.logging.LogFactory;
029    import org.springframework.integration.core.MessageChannel;
030    
031    /**
032     * Defines the <a href="http://camel.apache.org/springIntergration.html">Spring Intergration Endpoint</a>
033     *
034     * @version $Revision: 799863 $
035     */
036    public class SpringIntegrationEndpoint extends ScheduledPollEndpoint {
037        private static final Log LOG = LogFactory.getLog(SpringIntegrationEndpoint.class);
038        
039        private String inputChannel;
040        private String outputChannel;
041        private String defaultChannel;
042        private MessageChannel messageChannel;
043        private boolean inOut;
044    
045        public SpringIntegrationEndpoint(String uri, String channel, SpringIntegrationComponent component) {
046            super(uri, component);
047            defaultChannel = channel;
048        }
049    
050        public SpringIntegrationEndpoint(String uri, MessageChannel channel, CamelContext context) {
051            super(uri, context);
052            messageChannel = channel;
053        }
054    
055        public SpringIntegrationEndpoint(String endpointUri, MessageChannel messageChannel) {
056            super(endpointUri);
057            this.messageChannel = messageChannel;
058        }
059    
060        public Producer createProducer() throws Exception {
061            return new SpringIntegrationProducer(this);
062        }
063    
064        public Consumer createConsumer(Processor processor) throws Exception {
065            return new SpringIntegrationConsumer(this, processor);
066        }
067    
068        public void setInputChannel(String input) {
069            inputChannel = input;
070        }
071    
072        public String getInputChannel() {
073            return inputChannel;
074        }
075    
076        public void setOutputChannel(String output) {
077            outputChannel = output;
078        }
079    
080        public String getOutputChannel() {
081            return outputChannel;
082        }
083    
084        public String getDefaultChannel() {
085            return defaultChannel;
086        }
087    
088        public MessageChannel getMessageChannel() {
089            return messageChannel;
090        }
091    
092        public boolean isSingleton() {
093            return false;
094        }
095    
096        public void setInOut(boolean inOut) {
097            this.inOut = inOut;
098        }
099    
100        public boolean isInOut() {
101            return this.inOut;
102        }
103    
104    }