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