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.controlbus;
018    
019    import org.apache.camel.Component;
020    import org.apache.camel.Consumer;
021    import org.apache.camel.LoggingLevel;
022    import org.apache.camel.Processor;
023    import org.apache.camel.Producer;
024    import org.apache.camel.RuntimeCamelException;
025    import org.apache.camel.impl.DefaultEndpoint;
026    import org.apache.camel.spi.Language;
027    import org.apache.camel.spi.UriEndpoint;
028    import org.apache.camel.spi.UriParam;
029    import org.apache.camel.util.CamelLogger;
030    
031    /**
032     * The control bus endpoint.
033     */
034    @UriEndpoint(scheme = "controlbus")
035    public class ControlBusEndpoint extends DefaultEndpoint {
036    
037        private Language language;
038        @UriParam
039        private String routeId;
040        @UriParam
041        private String action;
042        @UriParam
043        private boolean async;
044        @UriParam
045        private LoggingLevel loggingLevel = LoggingLevel.INFO;
046    
047        public ControlBusEndpoint(String endpointUri, Component component) {
048            super(endpointUri, component);
049        }
050    
051        @Override
052        public Producer createProducer() throws Exception {
053            CamelLogger logger = new CamelLogger(ControlBusProducer.class.getName(), loggingLevel);
054            return new ControlBusProducer(this, logger);
055        }
056    
057        @Override
058        public Consumer createConsumer(Processor processor) throws Exception {
059            throw new RuntimeCamelException("Cannot consume from a ControlBusEndpoint: " + getEndpointUri());
060        }
061    
062        @Override
063        public boolean isSingleton() {
064            // we dont want to be enlisted in JMX, so lets just be non-singleton
065            return false;
066        }
067    
068        @Override
069        public ControlBusComponent getComponent() {
070            return (ControlBusComponent) super.getComponent();
071        }
072    
073        public Language getLanguage() {
074            return language;
075        }
076    
077        public void setLanguage(Language language) {
078            this.language = language;
079        }
080    
081        public String getRouteId() {
082            return routeId;
083        }
084    
085        public void setRouteId(String routeId) {
086            this.routeId = routeId;
087        }
088    
089        public String getAction() {
090            return action;
091        }
092    
093        public void setAction(String action) {
094            this.action = action;
095        }
096    
097        public boolean isAsync() {
098            return async;
099        }
100    
101        public void setAsync(boolean async) {
102            this.async = async;
103        }
104    
105        public LoggingLevel getLoggingLevel() {
106            return loggingLevel;
107        }
108    
109        public void setLoggingLevel(LoggingLevel loggingLevel) {
110            this.loggingLevel = loggingLevel;
111        }
112    }