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: 673335 $ 034 */ 035 public interface RouteContext { 036 037 Endpoint<? extends Exchange> getEndpoint(); 038 039 FromType getFrom(); 040 041 RouteType getRoute(); 042 043 /** 044 * Gets the CamelContext 045 */ 046 CamelContext getCamelContext(); 047 048 Processor createProcessor(ProcessorType node) throws Exception; 049 050 /** 051 * Resolves an endpoint from the URI 052 */ 053 Endpoint<? extends Exchange> resolveEndpoint(String uri); 054 055 /** 056 * Resolves an endpoint from either a URI or a named reference 057 */ 058 Endpoint<? extends Exchange> resolveEndpoint(String uri, String ref); 059 060 /** 061 * lookup an object by name and type 062 */ 063 <T> T lookup(String name, Class<T> type); 064 065 /** 066 * Lets complete the route creation, creating a single event driven route 067 * for the current from endpoint with any processors required 068 */ 069 void commit(); 070 071 void addEventDrivenProcessor(Processor processor); 072 073 void intercept(Intercept interceptor); 074 075 Processor createProceedProcessor(); 076 077 /** 078 * This method retrieves the InterceptStrategy instances this route context. 079 * 080 * @return InterceptStrategy 081 */ 082 List<InterceptStrategy> getInterceptStrategies(); 083 084 /** 085 * This method sets the InterceptStrategy instances on this route context. 086 * 087 * @param interceptStrategies 088 */ 089 void setInterceptStrategies(List<InterceptStrategy> interceptStrategies); 090 091 void addInterceptStrategy(InterceptStrategy interceptStrategy); 092 093 /** 094 * This method retrieves the ErrorHandlerWrappingStrategy. 095 * 096 * @return ErrorHandlerWrappingStrategy 097 */ 098 ErrorHandlerWrappingStrategy getErrorHandlerWrappingStrategy(); 099 100 /** 101 * This method sets the ErrorHandlerWrappingStrategy. 102 * 103 */ 104 void setErrorHandlerWrappingStrategy(ErrorHandlerWrappingStrategy strategy); 105 106 /** 107 * If this flag is true, {@link ProcessorType#addRoutes(RouteContext, java.util.Collection) 108 * will not add processor to addEventDrivenProcessor to the RouteContext and it 109 * will prevent from adding an EventDrivenRoute. 110 * 111 */ 112 void setIsRouteAdded(boolean value); 113 114 /** 115 * @see {@link #setIsRouteAdded(boolean)} 116 * 117 */ 118 boolean isRouteAdded(); 119 120 121 122 }