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.spi; 018 019 import java.util.List; 020 021 import org.apache.camel.CamelContext; 022 import org.apache.camel.Endpoint; 023 import org.apache.camel.Exchange; 024 import org.apache.camel.Intercept; 025 import org.apache.camel.Processor; 026 import org.apache.camel.model.FromType; 027 import org.apache.camel.model.ProcessorType; 028 import org.apache.camel.model.RouteType; 029 030 /** 031 * The context used to activate new routing rules 032 * 033 * @version $Revision: 47144 $ 034 */ 035 public interface RouteContext { 036 037 /** 038 * Gets the endpoint 039 * 040 * @return the endpoint 041 */ 042 Endpoint<? extends Exchange> getEndpoint(); 043 044 /** 045 * Gets the from type 046 * 047 * @return the from type 048 */ 049 FromType getFrom(); 050 051 /** 052 * Get the route type 053 * 054 * @return the route type 055 */ 056 RouteType getRoute(); 057 058 /** 059 * Gets the camel context 060 * 061 * @return the camel context 062 */ 063 CamelContext getCamelContext(); 064 065 /** 066 * Creates a processor 067 * 068 * @param node the node 069 * @return the created processor 070 * @throws Exception can be thrown 071 */ 072 Processor createProcessor(ProcessorType node) throws Exception; 073 074 /** 075 * Resolves an endpoint from the URI 076 * 077 * @param uri the URI 078 * @return the resolved endpoint 079 */ 080 Endpoint<? extends Exchange> resolveEndpoint(String uri); 081 082 /** 083 * Resolves an endpoint from either a URI or a named reference 084 * 085 * @param uri the URI or 086 * @param ref the named reference 087 * @return the resolved endpoint 088 */ 089 Endpoint<? extends Exchange> resolveEndpoint(String uri, String ref); 090 091 /** 092 * lookup an object by name and type 093 * 094 * @param name the name to lookup 095 * @param type the expected type 096 * @return the found object 097 */ 098 <T> T lookup(String name, Class<T> type); 099 100 /** 101 * Lets complete the route creation, creating a single event driven route 102 * for the current from endpoint with any processors required 103 */ 104 void commit(); 105 106 /** 107 * Adds an event driven processor 108 * 109 * @param processor the processor 110 */ 111 void addEventDrivenProcessor(Processor processor); 112 113 /** 114 * Intercepts with the given interceptor 115 * 116 * @param interceptor the interceptor 117 */ 118 void intercept(Intercept interceptor); 119 120 /** 121 * Creates a proceed processor 122 * 123 * @return the created proceed processor 124 */ 125 Processor createProceedProcessor(); 126 127 /** 128 * This method retrieves the InterceptStrategy instances this route context. 129 * 130 * @return the strategy 131 */ 132 List<InterceptStrategy> getInterceptStrategies(); 133 134 /** 135 * This method sets the InterceptStrategy instances on this route context. 136 * 137 * @param interceptStrategies the strategies 138 */ 139 void setInterceptStrategies(List<InterceptStrategy> interceptStrategies); 140 141 /** 142 * Adds a InterceptStrategy to this route context 143 * 144 * @param interceptStrategy the strategy 145 */ 146 void addInterceptStrategy(InterceptStrategy interceptStrategy); 147 148 /** 149 * This method retrieves the ErrorHandlerWrappingStrategy. 150 * 151 * @return the strategy 152 */ 153 ErrorHandlerWrappingStrategy getErrorHandlerWrappingStrategy(); 154 155 /** 156 * This method sets the ErrorHandlerWrappingStrategy. 157 * 158 * @param strategy the strategy 159 */ 160 void setErrorHandlerWrappingStrategy(ErrorHandlerWrappingStrategy strategy); 161 162 /** 163 * If this flag is true, {@link ProcessorType#addRoutes(RouteContext, java.util.Collection)} 164 * will not add processor to addEventDrivenProcessor to the RouteContext and it 165 * will prevent from adding an EventDrivenRoute. 166 * 167 * @param value the flag 168 */ 169 void setIsRouteAdded(boolean value); 170 171 /** 172 * Returns the isRouteAdded flag 173 * 174 * @return the flag 175 */ 176 boolean isRouteAdded(); 177 178 }