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.impl;
018
019 import java.util.ArrayList;
020 import java.util.List;
021 import java.util.Map;
022
023 import org.apache.camel.Consumer;
024 import org.apache.camel.Route;
025 import org.apache.camel.spi.RouteStartupOrder;
026
027 /**
028 * Default implementation of {@link org.apache.camel.spi.RouteStartupOrder}.
029 *
030 * @version $Revision: 903817 $
031 */
032 public class DefaultRouteStartupOrder implements RouteStartupOrder {
033
034 private final int startupOrder;
035 private final Route route;
036 private final List<Consumer> inputs = new ArrayList<Consumer>();
037 private final RouteService routeService;
038
039 public DefaultRouteStartupOrder(int startupOrder, Route route, RouteService routeService) {
040 this.startupOrder = startupOrder;
041 this.route = route;
042 this.routeService = routeService;
043 }
044
045 public int getStartupOrder() {
046 return startupOrder;
047 }
048
049 public Route getRoute() {
050 return route;
051 }
052
053 public List<Consumer> getInputs() {
054 List<Consumer> answer = new ArrayList<Consumer>();
055 Map<Route, Consumer> inputs = routeService.getInputs();
056 for (Consumer consumer : inputs.values()) {
057 answer.add(consumer);
058 }
059 return answer;
060 }
061
062 public RouteService getRouteService() {
063 return routeService;
064 }
065
066 @Override
067 public String toString() {
068 return "Route " + route.getId() + " starts in order " + startupOrder;
069 }
070 }