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: 45123 $ 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 List<InterceptStrategy> getInterceptStrategies(); 081 082 /** 083 * This method sets the InterceptStrategy instances on this route context. 084 */ 085 void setInterceptStrategies(List<InterceptStrategy> interceptStrategies); 086 087 void addInterceptStrategy(InterceptStrategy interceptStrategy); 088 089 /** 090 * This method retrieves the ErrorHandlerWrappingStrategy. 091 */ 092 ErrorHandlerWrappingStrategy getErrorHandlerWrappingStrategy(); 093 094 /** 095 * This method sets the ErrorHandlerWrappingStrategy. 096 */ 097 void setErrorHandlerWrappingStrategy(ErrorHandlerWrappingStrategy strategy); 098 099 /** 100 * If this flag is true, {@link ProcessorType#addRoutes(RouteContext, java.util.Collection)} 101 * will not add processor to addEventDrivenProcessor to the RouteContext and it 102 * will prevent from adding an EventDrivenRoute. 103 * 104 */ 105 void setIsRouteAdded(boolean value); 106 107 boolean isRouteAdded(); 108 109 }