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