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.io.IOException; 020import java.io.InputStream; 021import java.util.Collection; 022import java.util.List; 023import java.util.Map; 024import java.util.Properties; 025import java.util.concurrent.ScheduledExecutorService; 026import java.util.concurrent.TimeUnit; 027 028import org.apache.camel.api.management.mbean.ManagedCamelContextMBean; 029import org.apache.camel.api.management.mbean.ManagedProcessorMBean; 030import org.apache.camel.api.management.mbean.ManagedRouteMBean; 031import org.apache.camel.builder.ErrorHandlerBuilder; 032import org.apache.camel.model.DataFormatDefinition; 033import org.apache.camel.model.ProcessorDefinition; 034import org.apache.camel.model.RouteDefinition; 035import org.apache.camel.model.RoutesDefinition; 036import org.apache.camel.model.rest.RestDefinition; 037import org.apache.camel.model.rest.RestsDefinition; 038import org.apache.camel.spi.AsyncProcessorAwaitManager; 039import org.apache.camel.spi.CamelContextNameStrategy; 040import org.apache.camel.spi.ClassResolver; 041import org.apache.camel.spi.DataFormat; 042import org.apache.camel.spi.DataFormatResolver; 043import org.apache.camel.spi.Debugger; 044import org.apache.camel.spi.EndpointRegistry; 045import org.apache.camel.spi.EndpointStrategy; 046import org.apache.camel.spi.ExecutorServiceManager; 047import org.apache.camel.spi.FactoryFinder; 048import org.apache.camel.spi.FactoryFinderResolver; 049import org.apache.camel.spi.InflightRepository; 050import org.apache.camel.spi.Injector; 051import org.apache.camel.spi.InterceptStrategy; 052import org.apache.camel.spi.Language; 053import org.apache.camel.spi.LifecycleStrategy; 054import org.apache.camel.spi.ManagementMBeanAssembler; 055import org.apache.camel.spi.ManagementNameStrategy; 056import org.apache.camel.spi.ManagementStrategy; 057import org.apache.camel.spi.MessageHistoryFactory; 058import org.apache.camel.spi.ModelJAXBContextFactory; 059import org.apache.camel.spi.NodeIdFactory; 060import org.apache.camel.spi.PackageScanClassResolver; 061import org.apache.camel.spi.ProcessorFactory; 062import org.apache.camel.spi.Registry; 063import org.apache.camel.spi.RestConfiguration; 064import org.apache.camel.spi.RestRegistry; 065import org.apache.camel.spi.RoutePolicyFactory; 066import org.apache.camel.spi.RouteStartupOrder; 067import org.apache.camel.spi.RuntimeEndpointRegistry; 068import org.apache.camel.spi.ServicePool; 069import org.apache.camel.spi.ShutdownStrategy; 070import org.apache.camel.spi.StreamCachingStrategy; 071import org.apache.camel.spi.TypeConverterRegistry; 072import org.apache.camel.spi.UnitOfWorkFactory; 073import org.apache.camel.spi.UuidGenerator; 074import org.apache.camel.util.LoadPropertiesException; 075 076/** 077 * Interface used to represent the context used to configure routes and the 078 * policies to use during message exchanges between endpoints. 079 * <p/> 080 * The context offers the following methods to control the lifecycle: 081 * <ul> 082 * <li>{@link #start()} - to start (<b>important:</b> the start method is not blocked, see more details 083 * <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li> 084 * <li>{@link #stop()} - to shutdown (will stop all routes/components/endpoints etc and clear internal state/cache)</li> 085 * <li>{@link #suspend()} - to pause routing messages</li> 086 * <li>{@link #resume()} - to resume after a suspend</li> 087 * </ul> 088 * <p/> 089 * <b>Notice:</b> {@link #stop()} and {@link #suspend()} will gracefully stop/suspend routes ensuring any messages 090 * in progress will be given time to complete. See more details at {@link org.apache.camel.spi.ShutdownStrategy}. 091 * <p/> 092 * If you are doing a hot restart then it's advised to use the suspend/resume methods which ensure a faster 093 * restart but also allows any internal state to be kept as is. 094 * The stop/start approach will do a <i>cold</i> restart of Camel, where all internal state is reset. 095 * <p/> 096 * End users are advised to use suspend/resume. Using stop is for shutting down Camel and it's not guaranteed that 097 * when it's being started again using the start method that Camel will operate consistently. 098 * 099 * @version 100 */ 101public interface CamelContext extends SuspendableService, RuntimeConfiguration { 102 103 /** 104 * Adapts this {@link org.apache.camel.CamelContext} to the specialized type. 105 * <p/> 106 * For example to adapt to {@link org.apache.camel.model.ModelCamelContext}, 107 * or <tt>SpringCamelContext</tt>, or <tt>CdiCamelContext</tt>, etc. 108 * 109 * @param type the type to adapt to 110 * @return this {@link org.apache.camel.CamelContext} adapted to the given type 111 */ 112 <T extends CamelContext> T adapt(Class<T> type); 113 114 /** 115 * Starts the {@link CamelContext} (<b>important:</b> the start method is not blocked, see more details 116 * <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li>. 117 * <p/> 118 * See more details at the class-level javadoc of this class. 119 * 120 * @throws Exception is thrown if starting failed 121 */ 122 void start() throws Exception; 123 124 /** 125 * Stop and shutdown the {@link CamelContext} (will stop all routes/components/endpoints etc and clear internal state/cache). 126 * <p/> 127 * See more details at the class-level javadoc of this class. 128 * 129 * @throws Exception is thrown if stopping failed 130 */ 131 void stop() throws Exception; 132 133 /** 134 * Gets the name (id) of the this context. 135 * 136 * @return the name 137 */ 138 String getName(); 139 140 /** 141 * Gets the current name strategy 142 * 143 * @return name strategy 144 */ 145 CamelContextNameStrategy getNameStrategy(); 146 147 /** 148 * Sets a custom name strategy 149 * 150 * @param nameStrategy name strategy 151 */ 152 void setNameStrategy(CamelContextNameStrategy nameStrategy); 153 154 /** 155 * Gets the current management name strategy 156 * 157 * @return management name strategy 158 */ 159 ManagementNameStrategy getManagementNameStrategy(); 160 161 /** 162 * Sets a custom management name strategy 163 * 164 * @param nameStrategy name strategy 165 */ 166 void setManagementNameStrategy(ManagementNameStrategy nameStrategy); 167 168 /** 169 * Gets the name this {@link CamelContext} was registered in JMX. 170 * <p/> 171 * The reason that a {@link CamelContext} can have a different name in JMX is the fact to remedy for name clash 172 * in JMX when having multiple {@link CamelContext}s in the same JVM. Camel will automatic reassign and use 173 * a free name to avoid failing to start. 174 * 175 * @return the management name 176 */ 177 String getManagementName(); 178 179 /** 180 * Gets the version of the this context. 181 * 182 * @return the version 183 */ 184 String getVersion(); 185 186 /** 187 * Get the status of this context 188 * 189 * @return the status 190 */ 191 ServiceStatus getStatus(); 192 193 /** 194 * Gets the uptime in a human readable format 195 * 196 * @return the uptime in days/hours/minutes 197 */ 198 String getUptime(); 199 200 // Service Methods 201 //----------------------------------------------------------------------- 202 203 /** 204 * Adds a service to this context, which allows this context to control the lifecycle, ensuring 205 * the service is stopped when the context stops. 206 * <p/> 207 * The service will also have {@link CamelContext} injected if its {@link CamelContextAware}. 208 * The service will also be enlisted in JMX for management (if JMX is enabled). 209 * The service will be started, if its not already started. 210 * 211 * @param object the service 212 * @throws Exception can be thrown when starting the service 213 */ 214 void addService(Object object) throws Exception; 215 216 /** 217 * Adds a service to this context. 218 * <p/> 219 * The service will also have {@link CamelContext} injected if its {@link CamelContextAware}. 220 * The service will also be enlisted in JMX for management (if JMX is enabled). 221 * The service will be started, if its not already started. 222 * <p/> 223 * If the option <tt>closeOnShutdown</tt> is <tt>true</tt> then this context will control the lifecycle, ensuring 224 * the service is stopped when the context stops. 225 * If the option <tt>closeOnShutdown</tt> is <tt>false</tt> then this context will not stop the service when the context stops. 226 * 227 * @param object the service 228 * @param stopOnShutdown whether to stop the service when this CamelContext shutdown. 229 * @throws Exception can be thrown when starting the service 230 */ 231 void addService(Object object, boolean stopOnShutdown) throws Exception; 232 233 /** 234 * Removes a service from this context. 235 * <p/> 236 * The service is assumed to have been previously added using {@link #addService(Object)} method. 237 * This method will <b>not</b> change the service lifecycle. 238 * 239 * @param object the service 240 * @throws Exception can be thrown if error removing the service 241 * @return <tt>true</tt> if the service was removed, <tt>false</tt> if no service existed 242 */ 243 boolean removeService(Object object) throws Exception; 244 245 /** 246 * Has the given service already been added to this context? 247 * 248 * @param object the service 249 * @return <tt>true</tt> if already added, <tt>false</tt> if not. 250 */ 251 boolean hasService(Object object); 252 253 /** 254 * Has the given service type already been added to this context? 255 * 256 * @param type the class type 257 * @return the service instance or <tt>null</tt> if not already added. 258 */ 259 <T> T hasService(Class<T> type); 260 261 /** 262 * Defers starting the service until {@link CamelContext} is started and has initialized all its prior services and routes. 263 * <p/> 264 * If {@link CamelContext} is already started then the service is started immediately. 265 * 266 * @param object the service 267 * @param stopOnShutdown whether to stop the service when this CamelContext shutdown. Setting this to <tt>true</tt> will keep a reference to the service in 268 * this {@link CamelContext} until the context is stopped. So do not use it for short lived services. 269 * @throws Exception can be thrown when starting the service, which is only attempted if {@link CamelContext} has already been started when calling this method. 270 */ 271 void deferStartService(Object object, boolean stopOnShutdown) throws Exception; 272 273 /** 274 * Adds the given listener to be invoked when {@link CamelContext} have just been started. 275 * <p/> 276 * This allows listeners to do any custom work after the routes and other services have been started and are running. 277 * <p/><b>Important:</b> The listener will always be invoked, also if the {@link CamelContext} has already been 278 * started, see the {@link org.apache.camel.StartupListener#onCamelContextStarted(CamelContext, boolean)} method. 279 * 280 * @param listener the listener 281 * @throws Exception can be thrown if {@link CamelContext} is already started and the listener is invoked 282 * and cause an exception to be thrown 283 */ 284 void addStartupListener(StartupListener listener) throws Exception; 285 286 // Component Management Methods 287 //----------------------------------------------------------------------- 288 289 /** 290 * Adds a component to the context. 291 * 292 * @param componentName the name the component is registered as 293 * @param component the component 294 */ 295 void addComponent(String componentName, Component component); 296 297 /** 298 * Is the given component already registered? 299 * 300 * @param componentName the name of the component 301 * @return the registered Component or <tt>null</tt> if not registered 302 */ 303 Component hasComponent(String componentName); 304 305 /** 306 * Gets a component from the context by name. 307 * 308 * @param componentName the name of the component 309 * @return the component 310 */ 311 Component getComponent(String componentName); 312 313 /** 314 * Gets a component from the context by name. 315 * 316 * @param name the name of the component 317 * @param autoCreateComponents whether or not the component should 318 * be lazily created if it does not already exist 319 * @return the component 320 */ 321 Component getComponent(String name, boolean autoCreateComponents); 322 323 /** 324 * Gets a component from the context by name and specifying the expected type of component. 325 * 326 * @param name the name to lookup 327 * @param componentType the expected type 328 * @return the component 329 */ 330 <T extends Component> T getComponent(String name, Class<T> componentType); 331 332 /** 333 * Gets a readonly list of names of the components currently registered 334 * 335 * @return a readonly list with the names of the the components 336 */ 337 List<String> getComponentNames(); 338 339 /** 340 * Removes a previously added component. 341 * <p/> 342 * The component being removed will be stopped first. 343 * 344 * @param componentName the component name to remove 345 * @return the previously added component or null if it had not been previously added. 346 */ 347 Component removeComponent(String componentName); 348 349 // Endpoint Management Methods 350 //----------------------------------------------------------------------- 351 352 /** 353 * Gets the {@link org.apache.camel.spi.EndpointRegistry} 354 */ 355 EndpointRegistry<String> getEndpointRegistry(); 356 357 /** 358 * Resolves the given name to an {@link Endpoint} of the specified type. 359 * If the name has a singleton endpoint registered, then the singleton is returned. 360 * Otherwise, a new {@link Endpoint} is created and registered in the {@link org.apache.camel.spi.EndpointRegistry}. 361 * 362 * @param uri the URI of the endpoint 363 * @return the endpoint 364 */ 365 Endpoint getEndpoint(String uri); 366 367 /** 368 * Resolves the given name to an {@link Endpoint} of the specified type. 369 * If the name has a singleton endpoint registered, then the singleton is returned. 370 * Otherwise, a new {@link Endpoint} is created and registered in the {@link org.apache.camel.spi.EndpointRegistry}. 371 * 372 * @param name the name of the endpoint 373 * @param endpointType the expected type 374 * @return the endpoint 375 */ 376 <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType); 377 378 /** 379 * Returns a new {@link Collection} of all of the endpoints from the {@link org.apache.camel.spi.EndpointRegistry} 380 * 381 * @return all endpoints 382 */ 383 Collection<Endpoint> getEndpoints(); 384 385 /** 386 * Returns a new {@link Map} containing all of the endpoints from the {@link org.apache.camel.spi.EndpointRegistry} 387 * 388 * @return map of endpoints 389 */ 390 Map<String, Endpoint> getEndpointMap(); 391 392 /** 393 * Is the given endpoint already registered in the {@link org.apache.camel.spi.EndpointRegistry} 394 * 395 * @param uri the URI of the endpoint 396 * @return the registered endpoint or <tt>null</tt> if not registered 397 */ 398 Endpoint hasEndpoint(String uri); 399 400 /** 401 * Adds the endpoint to the {@link org.apache.camel.spi.EndpointRegistry} using the given URI. 402 * 403 * @param uri the URI to be used to resolve this endpoint 404 * @param endpoint the endpoint to be added to the registry 405 * @return the old endpoint that was previously registered or <tt>null</tt> if none was registered 406 * @throws Exception if the new endpoint could not be started or the old endpoint could not be stopped 407 */ 408 Endpoint addEndpoint(String uri, Endpoint endpoint) throws Exception; 409 410 /** 411 * Removes the endpoint from the {@link org.apache.camel.spi.EndpointRegistry}. 412 * <p/> 413 * The endpoint being removed will be stopped first. 414 * 415 * @param endpoint the endpoint 416 * @throws Exception if the endpoint could not be stopped 417 */ 418 void removeEndpoint(Endpoint endpoint) throws Exception; 419 420 /** 421 * Removes all endpoints with the given URI from the {@link org.apache.camel.spi.EndpointRegistry}. 422 * <p/> 423 * The endpoints being removed will be stopped first. 424 * 425 * @param pattern an uri or pattern to match 426 * @return a collection of endpoints removed which could be empty if there are no endpoints found for the given <tt>pattern</tt> 427 * @throws Exception if at least one endpoint could not be stopped 428 * @see org.apache.camel.util.EndpointHelper#matchEndpoint(CamelContext, String, String) for pattern 429 */ 430 Collection<Endpoint> removeEndpoints(String pattern) throws Exception; 431 432 /** 433 * Registers a {@link org.apache.camel.spi.EndpointStrategy callback} to allow you to do custom 434 * logic when an {@link Endpoint} is about to be registered to the {@link org.apache.camel.spi.EndpointRegistry}. 435 * <p/> 436 * When a callback is added it will be executed on the already registered endpoints allowing you to catch-up 437 * 438 * @param strategy callback to be invoked 439 */ 440 void addRegisterEndpointCallback(EndpointStrategy strategy); 441 442 // Route Management Methods 443 //----------------------------------------------------------------------- 444 445 /** 446 * Method to signal to {@link CamelContext} that the process to initialize setup routes is in progress. 447 * 448 * @param done <tt>false</tt> to start the process, call again with <tt>true</tt> to signal its done. 449 * @see #isSetupRoutes() 450 */ 451 void setupRoutes(boolean done); 452 453 /** 454 * Returns a list of the current route definitions 455 * 456 * @return list of the current route definitions 457 */ 458 List<RouteDefinition> getRouteDefinitions(); 459 460 /** 461 * Gets the route definition with the given id 462 * 463 * @param id id of the route 464 * @return the route definition or <tt>null</tt> if not found 465 */ 466 RouteDefinition getRouteDefinition(String id); 467 468 /** 469 * Returns a list of the current REST definitions 470 * 471 * @return list of the current REST definitions 472 */ 473 List<RestDefinition> getRestDefinitions(); 474 475 /** 476 * Adds a collection of rest definitions to the context 477 * 478 * @param restDefinitions the rest(s) definition to add 479 */ 480 void addRestDefinitions(Collection<RestDefinition> restDefinitions) throws Exception; 481 482 /** 483 * Sets a custom {@link org.apache.camel.spi.RestConfiguration} 484 * 485 * @param restConfiguration the REST configuration 486 */ 487 void setRestConfiguration(RestConfiguration restConfiguration); 488 489 /** 490 * Gets the default REST configuration 491 * 492 * @return the configuration, or <tt>null</tt> if none has been configured. 493 */ 494 RestConfiguration getRestConfiguration(); 495 496 /** 497 * Sets a custom {@link org.apache.camel.spi.RestConfiguration} 498 * 499 * @param restConfiguration the REST configuration 500 */ 501 void addRestConfiguration(RestConfiguration restConfiguration); 502 503 /** 504 * Gets the REST configuration for the given component 505 * 506 * @param component the component name to get the configuration 507 * @param defaultIfNotFound determine if the default configuration is returned if there isn't a 508 * specific configuration for the given component 509 * @return the configuration, or <tt>null</tt> if none has been configured. 510 */ 511 RestConfiguration getRestConfiguration(String component, boolean defaultIfNotFound); 512 513 /** 514 * Gets all the RestConfiguration's 515 */ 516 Collection<RestConfiguration> getRestConfigurations(); 517 518 /** 519 * Returns the order in which the route inputs was started. 520 * <p/> 521 * The order may not be according to the startupOrder defined on the route. 522 * For example a route could be started manually later, or new routes added at runtime. 523 * 524 * @return a list in the order how routes was started 525 */ 526 List<RouteStartupOrder> getRouteStartupOrder(); 527 528 /** 529 * Returns the current routes in this context 530 * 531 * @return the current routes 532 */ 533 List<Route> getRoutes(); 534 535 /** 536 * Gets the route with the given id 537 * 538 * @param id id of the route 539 * @return the route or <tt>null</tt> if not found 540 */ 541 Route getRoute(String id); 542 543 /** 544 * Gets the processor from any of the routes which with the given id 545 * 546 * @param id id of the processor 547 * @return the processor or <tt>null</tt> if not found 548 */ 549 Processor getProcessor(String id); 550 551 /** 552 * Gets the processor from any of the routes which with the given id 553 * 554 * @param id id of the processor 555 * @param type the processor type 556 * @return the processor or <tt>null</tt> if not found 557 * @throws java.lang.ClassCastException is thrown if the type is not correct type 558 */ 559 <T extends Processor> T getProcessor(String id, Class<T> type); 560 561 /** 562 * Gets the managed processor client api from any of the routes which with the given id 563 * 564 * @param id id of the processor 565 * @param type the managed processor type from the {@link org.apache.camel.api.management.mbean} package. 566 * @return the processor or <tt>null</tt> if not found 567 * @throws IllegalArgumentException if the type is not compliant 568 */ 569 <T extends ManagedProcessorMBean> T getManagedProcessor(String id, Class<T> type); 570 571 /** 572 * Gets the managed route client api with the given route id 573 * 574 * @param routeId id of the route 575 * @param type the managed route type from the {@link org.apache.camel.api.management.mbean} package. 576 * @return the route or <tt>null</tt> if not found 577 * @throws IllegalArgumentException if the type is not compliant 578 */ 579 <T extends ManagedRouteMBean> T getManagedRoute(String routeId, Class<T> type); 580 581 /** 582 * Gets the managed Camel context client api 583 */ 584 ManagedCamelContextMBean getManagedCamelContext(); 585 586 /** 587 * Gets the processor definition from any of the routes which with the given id 588 * 589 * @param id id of the processor definition 590 * @return the processor definition or <tt>null</tt> if not found 591 */ 592 ProcessorDefinition getProcessorDefinition(String id); 593 594 /** 595 * Gets the processor definition from any of the routes which with the given id 596 * 597 * @param id id of the processor definition 598 * @param type the processor definition type 599 * @return the processor definition or <tt>null</tt> if not found 600 * @throws java.lang.ClassCastException is thrown if the type is not correct type 601 */ 602 <T extends ProcessorDefinition> T getProcessorDefinition(String id, Class<T> type); 603 604 /** 605 * Adds a collection of routes to this context using the given builder 606 * to build them. 607 * <p/> 608 * <b>Important:</b> The added routes will <b>only</b> be started, if {@link CamelContext} 609 * is already started. You may want to check the state of {@link CamelContext} before 610 * adding the routes, using the {@link org.apache.camel.CamelContext#getStatus()} method. 611 * <p/> 612 * <b>Important: </b> Each route in the same {@link org.apache.camel.CamelContext} must have an <b>unique</b> route id. 613 * If you use the API from {@link org.apache.camel.CamelContext} or {@link org.apache.camel.model.ModelCamelContext} to add routes, then any 614 * new routes which has a route id that matches an old route, then the old route is replaced by the new route. 615 * 616 * @param builder the builder which will create the routes and add them to this context 617 * @throws Exception if the routes could not be created for whatever reason 618 */ 619 void addRoutes(RoutesBuilder builder) throws Exception; 620 621 /** 622 * Loads a collection of route definitions from the given {@link java.io.InputStream}. 623 * 624 * @param is input stream with the route(s) definition to add 625 * @throws Exception if the route definitions could not be loaded for whatever reason 626 * @return the route definitions 627 */ 628 RoutesDefinition loadRoutesDefinition(InputStream is) throws Exception; 629 630 /** 631 * Loads a collection of rest definitions from the given {@link java.io.InputStream}. 632 * 633 * @param is input stream with the rest(s) definition to add 634 * @throws Exception if the rest definitions could not be loaded for whatever reason 635 * @return the rest definitions 636 */ 637 RestsDefinition loadRestsDefinition(InputStream is) throws Exception; 638 639 /** 640 * Adds a collection of route definitions to the context 641 * 642 * @param routeDefinitions the route(s) definition to add 643 * @throws Exception if the route definitions could not be created for whatever reason 644 */ 645 void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception; 646 647 /** 648 * Add a route definition to the context 649 * 650 * @param routeDefinition the route definition to add 651 * @throws Exception if the route definition could not be created for whatever reason 652 */ 653 void addRouteDefinition(RouteDefinition routeDefinition) throws Exception; 654 655 /** 656 * Removes a collection of route definitions from the context - stopping any previously running 657 * routes if any of them are actively running 658 * 659 * @param routeDefinitions route(s) definitions to remove 660 * @throws Exception if the route definitions could not be removed for whatever reason 661 */ 662 void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception; 663 664 /** 665 * Removes a route definition from the context - stopping any previously running 666 * routes if any of them are actively running 667 * 668 * @param routeDefinition route definition to remove 669 * @throws Exception if the route definition could not be removed for whatever reason 670 */ 671 void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception; 672 673 /** 674 * Starts the given route if it has been previously stopped 675 * 676 * @param route the route to start 677 * @throws Exception is thrown if the route could not be started for whatever reason 678 * @deprecated favor using {@link CamelContext#startRoute(String)} 679 */ 680 @Deprecated 681 void startRoute(RouteDefinition route) throws Exception; 682 683 /** 684 * Starts all the routes which currently is not started. 685 * 686 * @throws Exception is thrown if a route could not be started for whatever reason 687 */ 688 void startAllRoutes() throws Exception; 689 690 /** 691 * Starts the given route if it has been previously stopped 692 * 693 * @param routeId the route id 694 * @throws Exception is thrown if the route could not be started for whatever reason 695 */ 696 void startRoute(String routeId) throws Exception; 697 698 /** 699 * Stops the given route. 700 * 701 * @param route the route to stop 702 * @throws Exception is thrown if the route could not be stopped for whatever reason 703 * @deprecated favor using {@link CamelContext#stopRoute(String)} 704 */ 705 @Deprecated 706 void stopRoute(RouteDefinition route) throws Exception; 707 708 /** 709 * Stops the given route using {@link org.apache.camel.spi.ShutdownStrategy}. 710 * 711 * @param routeId the route id 712 * @throws Exception is thrown if the route could not be stopped for whatever reason 713 * @see #suspendRoute(String) 714 */ 715 void stopRoute(String routeId) throws Exception; 716 717 /** 718 * Stops the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout. 719 * 720 * @param routeId the route id 721 * @param timeout timeout 722 * @param timeUnit the unit to use 723 * @throws Exception is thrown if the route could not be stopped for whatever reason 724 * @see #suspendRoute(String, long, java.util.concurrent.TimeUnit) 725 */ 726 void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception; 727 728 /** 729 * Stops the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout 730 * and optional abortAfterTimeout mode. 731 * 732 * @param routeId the route id 733 * @param timeout timeout 734 * @param timeUnit the unit to use 735 * @param abortAfterTimeout should abort shutdown after timeout 736 * @return <tt>true</tt> if the route is stopped before the timeout 737 * @throws Exception is thrown if the route could not be stopped for whatever reason 738 * @see #suspendRoute(String, long, java.util.concurrent.TimeUnit) 739 */ 740 boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception; 741 742 /** 743 * Shutdown and <b>removes</b> the given route using {@link org.apache.camel.spi.ShutdownStrategy}. 744 * 745 * @param routeId the route id 746 * @throws Exception is thrown if the route could not be shutdown for whatever reason 747 * @deprecated use {@link #stopRoute(String)} and {@link #removeRoute(String)} 748 */ 749 @Deprecated 750 void shutdownRoute(String routeId) throws Exception; 751 752 /** 753 * Shutdown and <b>removes</b> the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout. 754 * 755 * @param routeId the route id 756 * @param timeout timeout 757 * @param timeUnit the unit to use 758 * @throws Exception is thrown if the route could not be shutdown for whatever reason 759 * @deprecated use {@link #stopRoute(String, long, java.util.concurrent.TimeUnit)} and {@link #removeRoute(String)} 760 */ 761 @Deprecated 762 void shutdownRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception; 763 764 /** 765 * Removes the given route (the route <b>must</b> be stopped before it can be removed). 766 * <p/> 767 * A route which is removed will be unregistered from JMX, have its services stopped/shutdown and the route 768 * definition etc. will also be removed. All the resources related to the route will be stopped and cleared. 769 * <p/> 770 * <b>Important:</b> When removing a route, the {@link Endpoint}s which are in the static cache of 771 * {@link org.apache.camel.spi.EndpointRegistry} and are <b>only</b> used by the route (not used by other routes) 772 * will also be removed. But {@link Endpoint}s which may have been created as part of routing messages by the route, 773 * and those endpoints are enlisted in the dynamic cache of {@link org.apache.camel.spi.EndpointRegistry} are 774 * <b>not</b> removed. To remove those dynamic kind of endpoints, use the {@link #removeEndpoints(String)} method. 775 * If not removing those endpoints, they will be kept in the dynamic cache of {@link org.apache.camel.spi.EndpointRegistry}, 776 * but my eventually be removed (evicted) when they have not been in use for a longer period of time; and the 777 * dynamic cache upper limit is hit, and it evicts the least used endpoints. 778 * <p/> 779 * End users can use this method to remove unwanted routes or temporary routes which no longer is in demand. 780 * 781 * @param routeId the route id 782 * @return <tt>true</tt> if the route was removed, <tt>false</tt> if the route could not be removed because its not stopped 783 * @throws Exception is thrown if the route could not be shutdown for whatever reason 784 */ 785 boolean removeRoute(String routeId) throws Exception; 786 787 /** 788 * Resumes the given route if it has been previously suspended 789 * <p/> 790 * If the route does <b>not</b> support suspension the route will be started instead 791 * 792 * @param routeId the route id 793 * @throws Exception is thrown if the route could not be resumed for whatever reason 794 */ 795 void resumeRoute(String routeId) throws Exception; 796 797 /** 798 * Suspends the given route using {@link org.apache.camel.spi.ShutdownStrategy}. 799 * <p/> 800 * Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support) 801 * otherwise the consumers will be stopped. 802 * <p/> 803 * By suspending the route services will be kept running (if possible) and therefore its faster to resume the route. 804 * <p/> 805 * If the route does <b>not</b> support suspension the route will be stopped instead 806 * 807 * @param routeId the route id 808 * @throws Exception is thrown if the route could not be suspended for whatever reason 809 */ 810 void suspendRoute(String routeId) throws Exception; 811 812 /** 813 * Suspends the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout. 814 * <p/> 815 * Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support) 816 * otherwise the consumers will be stopped. 817 * <p/> 818 * By suspending the route services will be kept running (if possible) and therefore its faster to resume the route. 819 * <p/> 820 * If the route does <b>not</b> support suspension the route will be stopped instead 821 * 822 * @param routeId the route id 823 * @param timeout timeout 824 * @param timeUnit the unit to use 825 * @throws Exception is thrown if the route could not be suspended for whatever reason 826 */ 827 void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception; 828 829 /** 830 * Returns the current status of the given route 831 * 832 * @param routeId the route id 833 * @return the status for the route 834 */ 835 ServiceStatus getRouteStatus(String routeId); 836 837 /** 838 * Indicates whether current thread is starting route(s). 839 * <p/> 840 * This can be useful to know by {@link LifecycleStrategy} or the likes, in case 841 * they need to react differently. 842 * 843 * @return <tt>true</tt> if current thread is starting route(s), or <tt>false</tt> if not. 844 */ 845 boolean isStartingRoutes(); 846 847 /** 848 * Indicates whether current thread is setting up route(s) as part of starting Camel from spring/blueprint. 849 * <p/> 850 * This can be useful to know by {@link LifecycleStrategy} or the likes, in case 851 * they need to react differently. 852 * <p/> 853 * As the startup procedure of {@link CamelContext} is slightly different when using plain Java versus 854 * Spring or Blueprint, then we need to know when Spring/Blueprint is setting up the routes, which 855 * can happen after the {@link CamelContext} itself is in started state, due the asynchronous event nature 856 * of especially Blueprint. 857 * 858 * @return <tt>true</tt> if current thread is setting up route(s), or <tt>false</tt> if not. 859 */ 860 boolean isSetupRoutes(); 861 862 // Properties 863 //----------------------------------------------------------------------- 864 865 /** 866 * Returns the type converter used to coerce types from one type to another 867 * 868 * @return the converter 869 */ 870 TypeConverter getTypeConverter(); 871 872 /** 873 * Returns the type converter registry where type converters can be added or looked up 874 * 875 * @return the type converter registry 876 */ 877 TypeConverterRegistry getTypeConverterRegistry(); 878 879 /** 880 * Returns the registry used to lookup components by name and type such as the Spring ApplicationContext, 881 * JNDI or the OSGi Service Registry 882 * 883 * @return the registry 884 */ 885 Registry getRegistry(); 886 887 /** 888 * Returns the registry used to lookup components by name and as the given type 889 * 890 * @param type the registry type such as {@link org.apache.camel.impl.JndiRegistry} 891 * @return the registry, or <tt>null</tt> if the given type was not found as a registry implementation 892 */ 893 <T> T getRegistry(Class<T> type); 894 895 /** 896 * Returns the injector used to instantiate objects by type 897 * 898 * @return the injector 899 */ 900 Injector getInjector(); 901 902 /** 903 * Returns the management mbean assembler 904 * 905 * @return the mbean assembler 906 */ 907 ManagementMBeanAssembler getManagementMBeanAssembler(); 908 909 /** 910 * Returns the lifecycle strategies used to handle lifecycle notifications 911 * 912 * @return the lifecycle strategies 913 */ 914 List<LifecycleStrategy> getLifecycleStrategies(); 915 916 /** 917 * Adds the given lifecycle strategy to be used. 918 * 919 * @param lifecycleStrategy the strategy 920 */ 921 void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy); 922 923 /** 924 * Resolves a language for creating expressions 925 * 926 * @param language name of the language 927 * @return the resolved language 928 */ 929 Language resolveLanguage(String language); 930 931 /** 932 * Parses the given text and resolve any property placeholders - using {{key}}. 933 * 934 * @param text the text such as an endpoint uri or the likes 935 * @return the text with resolved property placeholders 936 * @throws Exception is thrown if property placeholders was used and there was an error resolving them 937 */ 938 String resolvePropertyPlaceholders(String text) throws Exception; 939 940 /** 941 * Returns the configured property placeholder prefix token if and only if the context has 942 * property placeholder abilities, otherwise returns {@code null}. 943 * 944 * @return the prefix token or {@code null} 945 */ 946 String getPropertyPrefixToken(); 947 948 /** 949 * Returns the configured property placeholder suffix token if and only if the context has 950 * property placeholder abilities, otherwise returns {@code null}. 951 * 952 * @return the suffix token or {@code null} 953 */ 954 String getPropertySuffixToken(); 955 956 /** 957 * Gets a readonly list with the names of the languages currently registered. 958 * 959 * @return a readonly list with the names of the the languages 960 */ 961 List<String> getLanguageNames(); 962 963 /** 964 * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away. 965 * <p/> 966 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 967 * Why does Camel use too many threads with ProducerTemplate?</a> 968 * <p/> 969 * <b>Important:</b> Make sure to call {@link org.apache.camel.ProducerTemplate#stop()} when you are done using the template, 970 * to clean up any resources. 971 * <p/> 972 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 973 * If no key was defined then it will fallback to a default size of 1000. 974 * You can also use the {@link org.apache.camel.ProducerTemplate#setMaximumCacheSize(int)} method to use a custom value 975 * before starting the template. 976 * 977 * @return the template 978 * @throws RuntimeCamelException is thrown if error starting the template 979 */ 980 ProducerTemplate createProducerTemplate(); 981 982 /** 983 * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away. 984 * <p/> 985 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 986 * Why does Camel use too many threads with ProducerTemplate?</a> 987 * <p/> 988 * <b>Important:</b> Make sure to call {@link ProducerTemplate#stop()} when you are done using the template, 989 * to clean up any resources. 990 * 991 * @param maximumCacheSize the maximum cache size 992 * @return the template 993 * @throws RuntimeCamelException is thrown if error starting the template 994 */ 995 ProducerTemplate createProducerTemplate(int maximumCacheSize); 996 997 /** 998 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away. 999 * <p/> 1000 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 1001 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate. 1002 * <p/> 1003 * <b>Important:</b> Make sure to call {@link ConsumerTemplate#stop()} when you are done using the template, 1004 * to clean up any resources. 1005 * <p/> 1006 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 1007 * If no key was defined then it will fallback to a default size of 1000. 1008 * You can also use the {@link org.apache.camel.ConsumerTemplate#setMaximumCacheSize(int)} method to use a custom value 1009 * before starting the template. 1010 * 1011 * @return the template 1012 * @throws RuntimeCamelException is thrown if error starting the template 1013 */ 1014 ConsumerTemplate createConsumerTemplate(); 1015 1016 /** 1017 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away. 1018 * <p/> 1019 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 1020 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate. 1021 * <p/> 1022 * <b>Important:</b> Make sure to call {@link ConsumerTemplate#stop()} when you are done using the template, 1023 * to clean up any resources. 1024 * 1025 * @param maximumCacheSize the maximum cache size 1026 * @return the template 1027 * @throws RuntimeCamelException is thrown if error starting the template 1028 */ 1029 ConsumerTemplate createConsumerTemplate(int maximumCacheSize); 1030 1031 /** 1032 * Adds the given interceptor strategy 1033 * 1034 * @param interceptStrategy the strategy 1035 */ 1036 void addInterceptStrategy(InterceptStrategy interceptStrategy); 1037 1038 /** 1039 * Gets the interceptor strategies 1040 * 1041 * @return the list of current interceptor strategies 1042 */ 1043 List<InterceptStrategy> getInterceptStrategies(); 1044 1045 /** 1046 * Gets the default error handler builder which is inherited by the routes 1047 * 1048 * @return the builder 1049 * @deprecated The return type will be switched to {@link ErrorHandlerFactory} in Camel 3.0 1050 */ 1051 @Deprecated 1052 ErrorHandlerBuilder getErrorHandlerBuilder(); 1053 1054 /** 1055 * Sets the default error handler builder which is inherited by the routes 1056 * 1057 * @param errorHandlerBuilder the builder 1058 */ 1059 void setErrorHandlerBuilder(ErrorHandlerFactory errorHandlerBuilder); 1060 1061 /** 1062 * Gets the default shared thread pool for error handlers which 1063 * leverages this for asynchronous redelivery tasks. 1064 */ 1065 ScheduledExecutorService getErrorHandlerExecutorService(); 1066 1067 /** 1068 * Sets the data formats that can be referenced in the routes. 1069 * 1070 * @param dataFormats the data formats 1071 */ 1072 void setDataFormats(Map<String, DataFormatDefinition> dataFormats); 1073 1074 /** 1075 * Gets the data formats that can be referenced in the routes. 1076 * 1077 * @return the data formats available 1078 */ 1079 Map<String, DataFormatDefinition> getDataFormats(); 1080 1081 /** 1082 * Resolve a data format given its name 1083 * 1084 * @param name the data format name or a reference to it in the {@link Registry} 1085 * @return the resolved data format, or <tt>null</tt> if not found 1086 */ 1087 DataFormat resolveDataFormat(String name); 1088 1089 /** 1090 * Resolve a data format definition given its name 1091 * 1092 * @param name the data format definition name or a reference to it in the {@link Registry} 1093 * @return the resolved data format definition, or <tt>null</tt> if not found 1094 */ 1095 DataFormatDefinition resolveDataFormatDefinition(String name); 1096 1097 /** 1098 * Gets the current data format resolver 1099 * 1100 * @return the resolver 1101 */ 1102 DataFormatResolver getDataFormatResolver(); 1103 1104 /** 1105 * Sets a custom data format resolver 1106 * 1107 * @param dataFormatResolver the resolver 1108 */ 1109 void setDataFormatResolver(DataFormatResolver dataFormatResolver); 1110 1111 /** 1112 * Sets the properties that can be referenced in the camel context 1113 * 1114 * @param properties properties 1115 */ 1116 void setProperties(Map<String, String> properties); 1117 1118 /** 1119 * Gets the properties that can be referenced in the camel context 1120 * 1121 * @return the properties 1122 */ 1123 Map<String, String> getProperties(); 1124 1125 /** 1126 * Gets the property value that can be referenced in the camel context 1127 * 1128 * @return the string value of property 1129 */ 1130 String getProperty(String name); 1131 1132 /** 1133 * Gets the default FactoryFinder which will be used for the loading the factory class from META-INF 1134 * 1135 * @return the default factory finder 1136 */ 1137 FactoryFinder getDefaultFactoryFinder(); 1138 1139 /** 1140 * Sets the factory finder resolver to use. 1141 * 1142 * @param resolver the factory finder resolver 1143 */ 1144 void setFactoryFinderResolver(FactoryFinderResolver resolver); 1145 1146 /** 1147 * Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path 1148 * 1149 * @param path the META-INF path 1150 * @return the factory finder 1151 * @throws NoFactoryAvailableException is thrown if a factory could not be found 1152 */ 1153 FactoryFinder getFactoryFinder(String path) throws NoFactoryAvailableException; 1154 1155 /** 1156 * Returns the class resolver to be used for loading/lookup of classes. 1157 * 1158 * @return the resolver 1159 */ 1160 ClassResolver getClassResolver(); 1161 1162 /** 1163 * Returns the package scanning class resolver 1164 * 1165 * @return the resolver 1166 */ 1167 PackageScanClassResolver getPackageScanClassResolver(); 1168 1169 /** 1170 * Sets the class resolver to be use 1171 * 1172 * @param resolver the resolver 1173 */ 1174 void setClassResolver(ClassResolver resolver); 1175 1176 /** 1177 * Sets the package scanning class resolver to use 1178 * 1179 * @param resolver the resolver 1180 */ 1181 void setPackageScanClassResolver(PackageScanClassResolver resolver); 1182 1183 /** 1184 * Sets a pluggable service pool to use for {@link Producer} pooling. 1185 * 1186 * @param servicePool the pool 1187 */ 1188 void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool); 1189 1190 /** 1191 * Gets the service pool for {@link Producer} pooling. 1192 * 1193 * @return the service pool 1194 */ 1195 ServicePool<Endpoint, Producer> getProducerServicePool(); 1196 1197 /** 1198 * Sets a pluggable service pool to use for {@link PollingConsumer} pooling. 1199 * 1200 * @param servicePool the pool 1201 */ 1202 void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> servicePool); 1203 1204 /** 1205 * Gets the service pool for {@link Producer} pooling. 1206 * 1207 * @return the service pool 1208 */ 1209 ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool(); 1210 1211 /** 1212 * Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions 1213 * 1214 * @param factory custom factory to use 1215 */ 1216 void setNodeIdFactory(NodeIdFactory factory); 1217 1218 /** 1219 * Gets the node id factory 1220 * 1221 * @return the node id factory 1222 */ 1223 NodeIdFactory getNodeIdFactory(); 1224 1225 /** 1226 * Gets the management strategy 1227 * 1228 * @return the management strategy 1229 */ 1230 ManagementStrategy getManagementStrategy(); 1231 1232 /** 1233 * Sets the management strategy to use 1234 * 1235 * @param strategy the management strategy 1236 */ 1237 void setManagementStrategy(ManagementStrategy strategy); 1238 1239 /** 1240 * Gets the default tracer 1241 * 1242 * @return the default tracer 1243 */ 1244 InterceptStrategy getDefaultTracer(); 1245 1246 /** 1247 * Sets a custom tracer to be used as the default tracer. 1248 * <p/> 1249 * <b>Note:</b> This must be set before any routes are created, 1250 * changing the default tracer for existing routes is not supported. 1251 * 1252 * @param tracer the custom tracer to use as default tracer 1253 */ 1254 void setDefaultTracer(InterceptStrategy tracer); 1255 1256 /** 1257 * Gets the default backlog tracer 1258 * 1259 * @return the default backlog tracer 1260 */ 1261 InterceptStrategy getDefaultBacklogTracer(); 1262 1263 /** 1264 * Sets a custom backlog tracer to be used as the default backlog tracer. 1265 * <p/> 1266 * <b>Note:</b> This must be set before any routes are created, 1267 * changing the default backlog tracer for existing routes is not supported. 1268 * 1269 * @param backlogTracer the custom tracer to use as default backlog tracer 1270 */ 1271 void setDefaultBacklogTracer(InterceptStrategy backlogTracer); 1272 1273 /** 1274 * Gets the default backlog debugger 1275 * 1276 * @return the default backlog debugger 1277 */ 1278 InterceptStrategy getDefaultBacklogDebugger(); 1279 1280 /** 1281 * Sets a custom backlog debugger to be used as the default backlog debugger. 1282 * <p/> 1283 * <b>Note:</b> This must be set before any routes are created, 1284 * changing the default backlog debugger for existing routes is not supported. 1285 * 1286 * @param backlogDebugger the custom debugger to use as default backlog debugger 1287 */ 1288 void setDefaultBacklogDebugger(InterceptStrategy backlogDebugger); 1289 1290 /** 1291 * Disables using JMX as {@link org.apache.camel.spi.ManagementStrategy}. 1292 * <p/> 1293 * <b>Important:</b> This method must be called <b>before</b> the {@link CamelContext} is started. 1294 * 1295 * @throws IllegalStateException is thrown if the {@link CamelContext} is not in stopped state. 1296 */ 1297 void disableJMX() throws IllegalStateException; 1298 1299 /** 1300 * Gets the inflight repository 1301 * 1302 * @return the repository 1303 */ 1304 InflightRepository getInflightRepository(); 1305 1306 /** 1307 * Sets a custom inflight repository to use 1308 * 1309 * @param repository the repository 1310 */ 1311 void setInflightRepository(InflightRepository repository); 1312 1313 /** 1314 * Gets the {@link org.apache.camel.AsyncProcessor} await manager. 1315 * 1316 * @return the manager 1317 */ 1318 AsyncProcessorAwaitManager getAsyncProcessorAwaitManager(); 1319 1320 /** 1321 * Sets a custom {@link org.apache.camel.AsyncProcessor} await manager. 1322 * 1323 * @param manager the manager 1324 */ 1325 void setAsyncProcessorAwaitManager(AsyncProcessorAwaitManager manager); 1326 1327 /** 1328 * Gets the the application context class loader which may be helpful for running camel in other containers 1329 * 1330 * @return the application context class loader 1331 */ 1332 ClassLoader getApplicationContextClassLoader(); 1333 1334 /** 1335 * Sets the application context class loader 1336 * 1337 * @param classLoader the class loader 1338 */ 1339 void setApplicationContextClassLoader(ClassLoader classLoader); 1340 1341 /** 1342 * Gets the current shutdown strategy 1343 * 1344 * @return the strategy 1345 */ 1346 ShutdownStrategy getShutdownStrategy(); 1347 1348 /** 1349 * Sets a custom shutdown strategy 1350 * 1351 * @param shutdownStrategy the custom strategy 1352 */ 1353 void setShutdownStrategy(ShutdownStrategy shutdownStrategy); 1354 1355 /** 1356 * Gets the current {@link org.apache.camel.spi.ExecutorServiceManager} 1357 * 1358 * @return the manager 1359 */ 1360 ExecutorServiceManager getExecutorServiceManager(); 1361 1362 /** 1363 * Gets the current {@link org.apache.camel.spi.ExecutorServiceStrategy} 1364 * 1365 * @return the manager 1366 * @deprecated use {@link #getExecutorServiceManager()} 1367 */ 1368 @Deprecated 1369 org.apache.camel.spi.ExecutorServiceStrategy getExecutorServiceStrategy(); 1370 1371 /** 1372 * Sets a custom {@link org.apache.camel.spi.ExecutorServiceManager} 1373 * 1374 * @param executorServiceManager the custom manager 1375 */ 1376 void setExecutorServiceManager(ExecutorServiceManager executorServiceManager); 1377 1378 /** 1379 * Gets the current {@link org.apache.camel.spi.ProcessorFactory} 1380 * 1381 * @return the factory, can be <tt>null</tt> if no custom factory has been set 1382 */ 1383 ProcessorFactory getProcessorFactory(); 1384 1385 /** 1386 * Sets a custom {@link org.apache.camel.spi.ProcessorFactory} 1387 * 1388 * @param processorFactory the custom factory 1389 */ 1390 void setProcessorFactory(ProcessorFactory processorFactory); 1391 1392 /** 1393 * Gets the current {@link org.apache.camel.spi.MessageHistoryFactory} 1394 * 1395 * @return the factory 1396 */ 1397 MessageHistoryFactory getMessageHistoryFactory(); 1398 1399 /** 1400 * Sets a custom {@link org.apache.camel.spi.MessageHistoryFactory} 1401 * 1402 * @param messageHistoryFactory the custom factory 1403 */ 1404 void setMessageHistoryFactory(MessageHistoryFactory messageHistoryFactory); 1405 1406 /** 1407 * Gets the current {@link Debugger} 1408 * 1409 * @return the debugger 1410 */ 1411 Debugger getDebugger(); 1412 1413 /** 1414 * Sets a custom {@link Debugger} 1415 * 1416 * @param debugger the debugger 1417 */ 1418 void setDebugger(Debugger debugger); 1419 1420 /** 1421 * Gets the current {@link UuidGenerator} 1422 * 1423 * @return the uuidGenerator 1424 */ 1425 UuidGenerator getUuidGenerator(); 1426 1427 /** 1428 * Sets a custom {@link UuidGenerator} (should only be set once) 1429 * 1430 * @param uuidGenerator the UUID Generator 1431 */ 1432 void setUuidGenerator(UuidGenerator uuidGenerator); 1433 1434 /** 1435 * Whether or not type converters should be loaded lazy 1436 * 1437 * @return <tt>true</tt> to load lazy, <tt>false</tt> to load on startup 1438 * @deprecated this option is no longer supported, will be removed in a future Camel release. 1439 */ 1440 @Deprecated 1441 Boolean isLazyLoadTypeConverters(); 1442 1443 /** 1444 * Sets whether type converters should be loaded lazy 1445 * 1446 * @param lazyLoadTypeConverters <tt>true</tt> to load lazy, <tt>false</tt> to load on startup 1447 * @deprecated this option is no longer supported, will be removed in a future Camel release. 1448 */ 1449 @Deprecated 1450 void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters); 1451 1452 /** 1453 * Whether or not type converter statistics is enabled. 1454 * <p/> 1455 * By default the type converter utilization statistics is disabled. 1456 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 1457 * 1458 * @return <tt>true</tt> if enabled, <tt>false</tt> if disabled (default). 1459 */ 1460 Boolean isTypeConverterStatisticsEnabled(); 1461 1462 /** 1463 * Sets whether or not type converter statistics is enabled. 1464 * <p/> 1465 * By default the type converter utilization statistics is disabled. 1466 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 1467 * <p/> 1468 * You can enable/disable the statistics at runtime using the 1469 * {@link org.apache.camel.spi.TypeConverterRegistry#getStatistics()#setTypeConverterStatisticsEnabled(Boolean)} method, 1470 * or from JMX on the {@link org.apache.camel.api.management.mbean.ManagedTypeConverterRegistryMBean} mbean. 1471 * 1472 * @param typeConverterStatisticsEnabled <tt>true</tt> to enable, <tt>false</tt> to disable 1473 */ 1474 void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled); 1475 1476 /** 1477 * Whether or not <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> logging is being enabled. 1478 * 1479 * @return <tt>true</tt> if MDC logging is enabled 1480 */ 1481 Boolean isUseMDCLogging(); 1482 1483 /** 1484 * Set whether <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> is enabled. 1485 * 1486 * @param useMDCLogging <tt>true</tt> to enable MDC logging, <tt>false</tt> to disable 1487 */ 1488 void setUseMDCLogging(Boolean useMDCLogging); 1489 1490 /** 1491 * Whether or not breadcrumb is enabled. 1492 * 1493 * @return <tt>true</tt> if breadcrumb is enabled 1494 */ 1495 Boolean isUseBreadcrumb(); 1496 1497 /** 1498 * Set whether breadcrumb is enabled. 1499 * 1500 * @param useBreadcrumb <tt>true</tt> to enable breadcrumb, <tt>false</tt> to disable 1501 */ 1502 void setUseBreadcrumb(Boolean useBreadcrumb); 1503 1504 /** 1505 * Resolves a component's default name from its java type. 1506 * <p/> 1507 * A component may be used with a non default name such as <tt>activemq</tt>, <tt>wmq</tt> for the JMS component. 1508 * This method can resolve the default component name by its java type. 1509 * 1510 * @param javaType the FQN name of the java type 1511 * @return the default component name. 1512 */ 1513 String resolveComponentDefaultName(String javaType); 1514 1515 /** 1516 * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}. 1517 * 1518 * @return a map with the component name, and value with component details. 1519 * @throws LoadPropertiesException is thrown if error during classpath discovery of the components 1520 * @throws IOException is thrown if error during classpath discovery of the components 1521 */ 1522 Map<String, Properties> findComponents() throws LoadPropertiesException, IOException; 1523 1524 /** 1525 * Find information about all the EIPs from camel-core. 1526 * 1527 * @return a map with node id, and value with EIP details. 1528 * @throws LoadPropertiesException is thrown if error during classpath discovery of the EIPs 1529 * @throws IOException is thrown if error during classpath discovery of the EIPs 1530 */ 1531 Map<String, Properties> findEips() throws LoadPropertiesException, IOException; 1532 1533 /** 1534 * Returns the HTML documentation for the given Camel component 1535 * 1536 * @return the HTML or <tt>null</tt> if the component is <b>not</b> built with HTML document included. 1537 */ 1538 String getComponentDocumentation(String componentName) throws IOException; 1539 1540 /** 1541 * Returns the JSON schema representation of the component and endpoint parameters for the given component name. 1542 * 1543 * @return the json or <tt>null</tt> if the component is <b>not</b> built with JSon schema support 1544 */ 1545 String getComponentParameterJsonSchema(String componentName) throws IOException; 1546 1547 /** 1548 * Returns the JSON schema representation of the {@link DataFormat} parameters for the given data format name. 1549 * 1550 * @return the json or <tt>null</tt> if the data format does not exist 1551 */ 1552 String getDataFormatParameterJsonSchema(String dataFormatName) throws IOException; 1553 1554 /** 1555 * Returns the JSON schema representation of the {@link Language} parameters for the given language name. 1556 * 1557 * @return the json or <tt>null</tt> if the language does not exist 1558 */ 1559 String getLanguageParameterJsonSchema(String languageName) throws IOException; 1560 1561 /** 1562 * Returns the JSON schema representation of the EIP parameters for the given EIP name. 1563 * 1564 * @return the json or <tt>null</tt> if the EIP does not exist 1565 */ 1566 String getEipParameterJsonSchema(String eipName) throws IOException; 1567 1568 /** 1569 * Returns a JSON schema representation of the EIP parameters for the given EIP by its id. 1570 * 1571 * @param nameOrId the name of the EIP ({@link NamedNode#getShortName()} or a node id to refer to a specific node from the routes. 1572 * @param includeAllOptions whether to include non configured options also (eg default options) 1573 * @return the json or <tt>null</tt> if the eipName or the id was not found 1574 */ 1575 String explainEipJson(String nameOrId, boolean includeAllOptions); 1576 1577 /** 1578 * Returns a JSON schema representation of the component parameters (not endpoint parameters) for the given component by its id. 1579 * 1580 * @param componentName the name of the component. 1581 * @param includeAllOptions whether to include non configured options also (eg default options) 1582 * @return the json or <tt>null</tt> if the component was not found 1583 */ 1584 String explainComponentJson(String componentName, boolean includeAllOptions); 1585 1586 /** 1587 * Returns a JSON schema representation of the component parameters (not endpoint parameters) for the given component by its id. 1588 * 1589 * @param dataFormat the data format instance. 1590 * @param includeAllOptions whether to include non configured options also (eg default options) 1591 * @return the json 1592 */ 1593 String explainDataFormatJson(String dataFormatName, DataFormat dataFormat, boolean includeAllOptions); 1594 1595 /** 1596 * Returns a JSON schema representation of the endpoint parameters for the given endpoint uri. 1597 * 1598 * @param uri the endpoint uri 1599 * @param includeAllOptions whether to include non configured options also (eg default options) 1600 * @return the json or <tt>null</tt> if uri parameters is invalid, or the component is <b>not</b> built with JSon schema support 1601 */ 1602 String explainEndpointJson(String uri, boolean includeAllOptions); 1603 1604 /** 1605 * Creates a JSON representation of all the <b>static</b> and <b>dynamic</b> configured endpoints defined in the given route(s). 1606 * 1607 * @param routeId for a particular route, or <tt>null</tt> for all routes 1608 * @return a JSON string 1609 */ 1610 String createRouteStaticEndpointJson(String routeId); 1611 1612 /** 1613 * Creates a JSON representation of all the <b>static</b> (and possible <b>dynamic</b>) configured endpoints defined in the given route(s). 1614 * 1615 * @param routeId for a particular route, or <tt>null</tt> for all routes 1616 * @param includeDynamic whether to include dynamic endpoints 1617 * @return a JSON string 1618 */ 1619 String createRouteStaticEndpointJson(String routeId, boolean includeDynamic); 1620 1621 /** 1622 * Gets the {@link StreamCachingStrategy} to use. 1623 */ 1624 StreamCachingStrategy getStreamCachingStrategy(); 1625 1626 /** 1627 * Sets a custom {@link StreamCachingStrategy} to use. 1628 */ 1629 void setStreamCachingStrategy(StreamCachingStrategy streamCachingStrategy); 1630 1631 /** 1632 * Gets the {@link UnitOfWorkFactory} to use. 1633 */ 1634 UnitOfWorkFactory getUnitOfWorkFactory(); 1635 1636 /** 1637 * Sets a custom {@link UnitOfWorkFactory} to use. 1638 */ 1639 void setUnitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory); 1640 1641 /** 1642 * Gets the {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use, or <tt>null</tt> if none is in use. 1643 */ 1644 RuntimeEndpointRegistry getRuntimeEndpointRegistry(); 1645 1646 /** 1647 * Sets a custom {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use. 1648 */ 1649 void setRuntimeEndpointRegistry(RuntimeEndpointRegistry runtimeEndpointRegistry); 1650 1651 /** 1652 * Gets the {@link org.apache.camel.spi.RestRegistry} to use 1653 */ 1654 RestRegistry getRestRegistry(); 1655 1656 /** 1657 * Sets a custom {@link org.apache.camel.spi.RestRegistry} to use. 1658 */ 1659 void setRestRegistry(RestRegistry restRegistry); 1660 1661 /** 1662 * Adds the given route policy factory 1663 * 1664 * @param routePolicyFactory the factory 1665 */ 1666 void addRoutePolicyFactory(RoutePolicyFactory routePolicyFactory); 1667 1668 /** 1669 * Gets the route policy factories 1670 * 1671 * @return the list of current route policy factories 1672 */ 1673 List<RoutePolicyFactory> getRoutePolicyFactories(); 1674 1675 /** 1676 * Returns the JAXB Context factory used to create Models. 1677 * 1678 * @return the JAXB Context factory used to create Models. 1679 */ 1680 ModelJAXBContextFactory getModelJAXBContextFactory(); 1681 1682 /** 1683 * Sets a custom JAXB Context factory to be used 1684 * 1685 * @param modelJAXBContextFactory a JAXB Context factory 1686 */ 1687 void setModelJAXBContextFactory(ModelJAXBContextFactory modelJAXBContextFactory); 1688 1689}