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 */
017package org.apache.camel.impl;
018
019import java.util.Collection;
020import java.util.Collections;
021import java.util.concurrent.TimeUnit;
022
023import org.apache.camel.CamelContext;
024import org.apache.camel.Experimental;
025import org.apache.camel.Route;
026import org.apache.camel.spi.RouteController;
027
028@Experimental
029public class DefaultRouteController extends org.apache.camel.support.ServiceSupport implements RouteController  {
030    private CamelContext camelContext;
031    public DefaultRouteController() {
032        this(null);
033    }
034
035    public DefaultRouteController(CamelContext camelContext) {
036        this.camelContext = camelContext;
037    }
038
039    // ***************************************************
040    // Properties
041    // ***************************************************
042
043    @Override
044    public void setCamelContext(CamelContext camelContext) {
045        this.camelContext = camelContext;
046    }
047
048    @Override
049    public CamelContext getCamelContext() {
050        return camelContext;
051    }
052
053    // ***************************************************
054    // Life cycle
055    // ***************************************************
056
057    @Override
058    protected void doStart() throws Exception {
059    }
060
061    @Override
062    protected void doStop() throws Exception {
063    }
064
065    // ***************************************************
066    // Route management
067    // ***************************************************
068
069    @Override
070    public void startRoute(String routeId) throws Exception {
071        camelContext.startRoute(routeId);
072    }
073
074    @Override
075    public void stopRoute(String routeId) throws Exception {
076        camelContext.stopRoute(routeId);
077    }
078
079    @Override
080    public void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception {
081        camelContext.stopRoute(routeId, timeout, timeUnit);
082    }
083
084    @Override
085    public boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception {
086        return camelContext.stopRoute(routeId, timeout, timeUnit, abortAfterTimeout);
087    }
088
089    @Override
090    public void suspendRoute(String routeId) throws Exception {
091        camelContext.suspendRoute(routeId);
092    }
093
094    @Override
095    public void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception {
096        camelContext.suspendRoute(routeId, timeout, timeUnit);
097    }
098
099    @Override
100    public void resumeRoute(String routeId) throws Exception {
101        camelContext.resumeRoute(routeId);
102    }
103
104    // ***************************************************
105    //
106    // ***************************************************
107
108    @Override
109    public Collection<Route> getControlledRoutes() {
110        return Collections.emptyList();
111    }
112}