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; 018 019import java.util.List; 020import java.util.Map; 021 022import org.apache.camel.spi.RouteContext; 023 024/** 025 * A <a href="http://camel.apache.org/routes.html">Route</a> 026 * defines the processing used on an inbound message exchange 027 * from a specific {@link org.apache.camel.Endpoint} within a {@link org.apache.camel.CamelContext}. 028 * <p/> 029 * Use the API from {@link org.apache.camel.CamelContext} to control the lifecycle of a route, 030 * such as starting and stopping using the {@link org.apache.camel.CamelContext#startRoute(String)} 031 * and {@link org.apache.camel.CamelContext#stopRoute(String)} methods. 032 */ 033public interface Route extends EndpointAware { 034 035 String ID_PROPERTY = "id"; 036 String PARENT_PROPERTY = "parent"; 037 String GROUP_PROPERTY = "group"; 038 String REST_PROPERTY = "rest"; 039 String DESCRIPTION_PROPERTY = "description"; 040 041 /** 042 * Gets the route id 043 * 044 * @return the route id 045 */ 046 String getId(); 047 048 /** 049 * Gets the route group 050 * 051 * @return the route group 052 */ 053 String getGroup(); 054 055 /** 056 * Gets the uptime in a human readable format 057 * 058 * @return the uptime in days/hours/minutes 059 */ 060 String getUptime(); 061 062 /** 063 * Gets the uptime in milli seconds 064 * 065 * @return the uptime in millis seconds 066 */ 067 long getUptimeMillis(); 068 069 /** 070 * Gets the inbound {@link Consumer} 071 * 072 * @return the inbound consumer 073 */ 074 Consumer getConsumer(); 075 076 /** 077 * Whether or not the route supports suspension (suspend and resume) 078 * 079 * @return <tt>true</tt> if this route supports suspension 080 */ 081 boolean supportsSuspension(); 082 083 /** 084 * This property map is used to associate information about the route. 085 * 086 * @return properties 087 */ 088 Map<String, Object> getProperties(); 089 090 /** 091 * Gets the route description (if any has been configured). 092 * <p/> 093 * The description is configured using the {@link #DESCRIPTION_PROPERTY} as key in the {@link #getProperties()}. 094 * 095 * @return the description, or <tt>null</tt> if no description has been configured. 096 */ 097 String getDescription(); 098 099 /** 100 * Gets the route context 101 * 102 * @return the route context 103 */ 104 RouteContext getRouteContext(); 105 106 /** 107 * A strategy callback allowing special initialization when services are starting. 108 * 109 * @param services the service 110 * @throws Exception is thrown in case of error 111 */ 112 void onStartingServices(List<Service> services) throws Exception; 113 114 /** 115 * Returns the services for this particular route 116 * 117 * @return the services 118 */ 119 List<Service> getServices(); 120 121 /** 122 * Adds a service to this route 123 * 124 * @param service the service 125 */ 126 void addService(Service service); 127 128 /** 129 * Returns a navigator to navigate this route by navigating all the {@link Processor}s. 130 * 131 * @return a navigator for {@link Processor}. 132 */ 133 Navigate<Processor> navigate(); 134 135 /** 136 * Returns a list of all the {@link Processor}s from this route that has id's matching the pattern 137 * 138 * @param pattern the pattern to match by ids 139 * @return a list of {@link Processor}, is never <tt>null</tt>. 140 */ 141 List<Processor> filter(String pattern); 142 143 /** 144 * Callback preparing the route to be started, by warming up the route. 145 */ 146 void warmUp(); 147 148}