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.Collection; 020import java.util.List; 021import java.util.Map; 022import java.util.Set; 023import java.util.concurrent.ExecutorService; 024import java.util.concurrent.ScheduledExecutorService; 025 026import org.apache.camel.spi.AnnotationBasedProcessorFactory; 027import org.apache.camel.spi.AsyncProcessorAwaitManager; 028import org.apache.camel.spi.BeanIntrospection; 029import org.apache.camel.spi.BeanProcessorFactory; 030import org.apache.camel.spi.BeanProxyFactory; 031import org.apache.camel.spi.CamelBeanPostProcessor; 032import org.apache.camel.spi.DataFormatResolver; 033import org.apache.camel.spi.DeferServiceFactory; 034import org.apache.camel.spi.EndpointStrategy; 035import org.apache.camel.spi.FactoryFinder; 036import org.apache.camel.spi.FactoryFinderResolver; 037import org.apache.camel.spi.InterceptStrategy; 038import org.apache.camel.spi.LifecycleStrategy; 039import org.apache.camel.spi.LogListener; 040import org.apache.camel.spi.ManagementMBeanAssembler; 041import org.apache.camel.spi.ModelJAXBContextFactory; 042import org.apache.camel.spi.NodeIdFactory; 043import org.apache.camel.spi.PackageScanClassResolver; 044import org.apache.camel.spi.PackageScanResourceResolver; 045import org.apache.camel.spi.ProcessorFactory; 046import org.apache.camel.spi.Registry; 047import org.apache.camel.spi.RouteStartupOrder; 048import org.apache.camel.spi.UnitOfWorkFactory; 049 050/** 051 * Extended {@link CamelContext} which contains the methods and APIs that are not primary intended for Camel end users 052 * but for SPI, custom components, or more advanced used-cases with Camel. 053 */ 054public interface ExtendedCamelContext extends CamelContext { 055 056 /** 057 * Sets the name (id) of the this context. 058 * <p/> 059 * This operation is mostly only used by different Camel runtimes such as camel-spring, camel-cdi, camel-spring-boot etc. 060 * Important: Setting the name should only be set before CamelContext is started. 061 * 062 * @param name the name 063 */ 064 void setName(String name); 065 066 /** 067 * Sets the registry Camel should use for looking up beans by name or type. 068 * <p/> 069 * This operation is mostly only used by different Camel runtimes such as camel-spring, camel-cdi, camel-spring-boot etc. 070 * Important: Setting the registry should only be set before CamelContext is started. 071 * 072 * @param registry the registry such as DefaultRegistry or 073 */ 074 void setRegistry(Registry registry); 075 076 /** 077 * Method to signal to {@link CamelContext} that the process to initialize setup routes is in progress. 078 * 079 * @param done <tt>false</tt> to start the process, call again with <tt>true</tt> to signal its done. 080 * @see #isSetupRoutes() 081 */ 082 void setupRoutes(boolean done); 083 084 /** 085 * Indicates whether current thread is setting up route(s) as part of starting Camel from spring/blueprint. 086 * <p/> 087 * This can be useful to know by {@link LifecycleStrategy} or the likes, in case 088 * they need to react differently. 089 * <p/> 090 * As the startup procedure of {@link CamelContext} is slightly different when using plain Java versus 091 * Spring or Blueprint, then we need to know when Spring/Blueprint is setting up the routes, which 092 * can happen after the {@link CamelContext} itself is in started state, due the asynchronous event nature 093 * of especially Blueprint. 094 * 095 * @return <tt>true</tt> if current thread is setting up route(s), or <tt>false</tt> if not. 096 */ 097 boolean isSetupRoutes(); 098 099 /** 100 * Registers a {@link org.apache.camel.spi.EndpointStrategy callback} to allow you to do custom 101 * logic when an {@link Endpoint} is about to be registered to the {@link org.apache.camel.spi.EndpointRegistry}. 102 * <p/> 103 * When a callback is registered it will be executed on the already registered endpoints allowing you to catch-up 104 * 105 * @param strategy callback to be invoked 106 */ 107 void registerEndpointCallback(EndpointStrategy strategy); 108 109 /** 110 * Returns the order in which the route inputs was started. 111 * <p/> 112 * The order may not be according to the startupOrder defined on the route. 113 * For example a route could be started manually later, or new routes added at runtime. 114 * 115 * @return a list in the order how routes was started 116 */ 117 List<RouteStartupOrder> getRouteStartupOrder(); 118 119 /** 120 * Returns the bean post processor used to do any bean customization. 121 * 122 * @return the bean post processor. 123 */ 124 CamelBeanPostProcessor getBeanPostProcessor(); 125 126 /** 127 * Returns the management mbean assembler 128 * 129 * @return the mbean assembler 130 */ 131 ManagementMBeanAssembler getManagementMBeanAssembler(); 132 133 /** 134 * Creates a new multicast processor which sends an exchange to all the processors. 135 * 136 * @param processors the list of processors to send to 137 * @param executor the executor to use 138 * @return a multicasting processor 139 */ 140 AsyncProcessor createMulticast(Collection<Processor> processors, 141 ExecutorService executor, boolean shutdownExecutorService); 142 143 /** 144 * Gets the default error handler builder which is inherited by the routes 145 * 146 * @return the builder 147 */ 148 ErrorHandlerFactory getErrorHandlerFactory(); 149 150 /** 151 * Sets the default error handler builder which is inherited by the routes 152 * 153 * @param errorHandlerFactory the builder 154 */ 155 void setErrorHandlerFactory(ErrorHandlerFactory errorHandlerFactory); 156 157 /** 158 * Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions 159 * 160 * @param factory custom factory to use 161 */ 162 void setNodeIdFactory(NodeIdFactory factory); 163 164 /** 165 * Gets the node id factory 166 * 167 * @return the node id factory 168 */ 169 NodeIdFactory getNodeIdFactory(); 170 171 /** 172 * Gets the current data format resolver 173 * 174 * @return the resolver 175 */ 176 DataFormatResolver getDataFormatResolver(); 177 178 /** 179 * Sets a custom data format resolver 180 * 181 * @param dataFormatResolver the resolver 182 */ 183 void setDataFormatResolver(DataFormatResolver dataFormatResolver); 184 185 /** 186 * Returns the package scanning class resolver 187 * 188 * @return the resolver 189 */ 190 PackageScanClassResolver getPackageScanClassResolver(); 191 192 /** 193 * Sets the package scanning class resolver to use 194 * 195 * @param resolver the resolver 196 */ 197 void setPackageScanClassResolver(PackageScanClassResolver resolver); 198 199 /** 200 * Returns the package scanning resource resolver 201 * 202 * @return the resolver 203 */ 204 PackageScanResourceResolver getPackageScanResourceResolver(); 205 206 /** 207 * Sets the package scanning resource resolver to use 208 * 209 * @param resolver the resolver 210 */ 211 void setPackageScanResourceResolver(PackageScanResourceResolver resolver); 212 213 /** 214 * Gets the default FactoryFinder which will be used for the loading the factory class from META-INF 215 * 216 * @return the default factory finder 217 */ 218 FactoryFinder getDefaultFactoryFinder(); 219 220 /** 221 * Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path 222 * 223 * @param path the META-INF path 224 * @return the factory finder 225 * @throws NoFactoryAvailableException is thrown if a factory could not be found 226 */ 227 FactoryFinder getFactoryFinder(String path) throws NoFactoryAvailableException; 228 229 /** 230 * Sets the factory finder resolver to use. 231 * 232 * @param resolver the factory finder resolver 233 */ 234 void setFactoryFinderResolver(FactoryFinderResolver resolver); 235 236 /** 237 * Gets the factory finder resolver to use 238 * 239 * @return the factory finder resolver 240 */ 241 FactoryFinderResolver getFactoryFinderResolver(); 242 243 /** 244 * Gets the current {@link org.apache.camel.spi.ProcessorFactory} 245 * 246 * @return the factory, can be <tt>null</tt> if no custom factory has been set 247 */ 248 ProcessorFactory getProcessorFactory(); 249 250 /** 251 * Sets a custom {@link org.apache.camel.spi.ProcessorFactory} 252 * 253 * @param processorFactory the custom factory 254 */ 255 void setProcessorFactory(ProcessorFactory processorFactory); 256 257 /** 258 * Returns the JAXB Context factory used to create Models. 259 * 260 * @return the JAXB Context factory used to create Models. 261 */ 262 ModelJAXBContextFactory getModelJAXBContextFactory(); 263 264 /** 265 * Sets a custom JAXB Context factory to be used 266 * 267 * @param modelJAXBContextFactory a JAXB Context factory 268 */ 269 void setModelJAXBContextFactory(ModelJAXBContextFactory modelJAXBContextFactory); 270 271 /** 272 * Gets the {@link DeferServiceFactory} to use. 273 */ 274 DeferServiceFactory getDeferServiceFactory(); 275 276 /** 277 * Gets the {@link UnitOfWorkFactory} to use. 278 */ 279 UnitOfWorkFactory getUnitOfWorkFactory(); 280 281 /** 282 * Sets a custom {@link UnitOfWorkFactory} to use. 283 */ 284 void setUnitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory); 285 286 /** 287 * Gets the {@link AnnotationBasedProcessorFactory} to use. 288 */ 289 AnnotationBasedProcessorFactory getAnnotationBasedProcessorFactory(); 290 291 /** 292 * Gets the {@link BeanProxyFactory} to use. 293 */ 294 BeanProxyFactory getBeanProxyFactory(); 295 296 /** 297 * Gets the {@link BeanProcessorFactory} to use. 298 */ 299 BeanProcessorFactory getBeanProcessorFactory(); 300 301 /** 302 * Gets the default shared thread pool for error handlers which 303 * leverages this for asynchronous redelivery tasks. 304 */ 305 ScheduledExecutorService getErrorHandlerExecutorService(); 306 307 /** 308 * Adds the given interceptor strategy 309 * 310 * @param interceptStrategy the strategy 311 */ 312 void addInterceptStrategy(InterceptStrategy interceptStrategy); 313 314 /** 315 * Gets the interceptor strategies 316 * 317 * @return the list of current interceptor strategies 318 */ 319 List<InterceptStrategy> getInterceptStrategies(); 320 321 /** 322 * Setup management according to whether JMX is enabled or disabled. 323 * 324 * @param options optional parameters to configure {@link org.apache.camel.spi.ManagementAgent}. 325 */ 326 void setupManagement(Map<String, Object> options); 327 328 /** 329 * Gets a list of {@link LogListener}. 330 */ 331 Set<LogListener> getLogListeners(); 332 333 /** 334 * Adds a {@link LogListener}. 335 */ 336 void addLogListener(LogListener listener); 337 338 /** 339 * Gets the {@link org.apache.camel.AsyncProcessor} await manager. 340 * 341 * @return the manager 342 */ 343 AsyncProcessorAwaitManager getAsyncProcessorAwaitManager(); 344 345 /** 346 * Sets a custom {@link org.apache.camel.AsyncProcessor} await manager. 347 * 348 * @param manager the manager 349 */ 350 void setAsyncProcessorAwaitManager(AsyncProcessorAwaitManager manager); 351 352 /** 353 * Gets the {@link BeanIntrospection} 354 */ 355 BeanIntrospection getBeanIntrospection(); 356 357 /** 358 * Sets a custom {@link BeanIntrospection}. 359 */ 360 void setBeanIntrospection(BeanIntrospection beanIntrospection); 361 362}