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 032 public DefaultRouteController() { 033 this(null); 034 } 035 036 public DefaultRouteController(CamelContext camelContext) { 037 this.camelContext = camelContext; 038 } 039 040 // *************************************************** 041 // Properties 042 // *************************************************** 043 044 @Override 045 public void setCamelContext(CamelContext camelContext) { 046 this.camelContext = camelContext; 047 } 048 049 @Override 050 public CamelContext getCamelContext() { 051 return camelContext; 052 } 053 054 // *************************************************** 055 // Life cycle 056 // *************************************************** 057 058 @Override 059 protected void doStart() throws Exception { 060 // noop 061 } 062 063 @Override 064 protected void doStop() throws Exception { 065 // noop 066 } 067 068 // *************************************************** 069 // Route management 070 // *************************************************** 071 072 @Override 073 public void startRoute(String routeId) throws Exception { 074 camelContext.startRoute(routeId); 075 } 076 077 @Override 078 public void stopRoute(String routeId) throws Exception { 079 camelContext.stopRoute(routeId); 080 } 081 082 @Override 083 public void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception { 084 camelContext.stopRoute(routeId, timeout, timeUnit); 085 } 086 087 @Override 088 public boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception { 089 return camelContext.stopRoute(routeId, timeout, timeUnit, abortAfterTimeout); 090 } 091 092 @Override 093 public void suspendRoute(String routeId) throws Exception { 094 camelContext.suspendRoute(routeId); 095 } 096 097 @Override 098 public void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception { 099 camelContext.suspendRoute(routeId, timeout, timeUnit); 100 } 101 102 @Override 103 public void resumeRoute(String routeId) throws Exception { 104 camelContext.resumeRoute(routeId); 105 } 106 107 // *************************************************** 108 // 109 // *************************************************** 110 111 @Override 112 public Collection<Route> getControlledRoutes() { 113 return Collections.emptyList(); 114 } 115}