001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel; 018 019import java.util.Collection; 020import java.util.List; 021import java.util.Map; 022import java.util.Set; 023 024import org.apache.camel.spi.CamelContextNameStrategy; 025import org.apache.camel.spi.ClassResolver; 026import org.apache.camel.spi.DataFormat; 027import org.apache.camel.spi.DataType; 028import org.apache.camel.spi.Debugger; 029import org.apache.camel.spi.EndpointRegistry; 030import org.apache.camel.spi.ExecutorServiceManager; 031import org.apache.camel.spi.HeadersMapFactory; 032import org.apache.camel.spi.InflightRepository; 033import org.apache.camel.spi.Injector; 034import org.apache.camel.spi.Language; 035import org.apache.camel.spi.LifecycleStrategy; 036import org.apache.camel.spi.ManagementNameStrategy; 037import org.apache.camel.spi.ManagementStrategy; 038import org.apache.camel.spi.MessageHistoryFactory; 039import org.apache.camel.spi.PropertiesComponent; 040import org.apache.camel.spi.ReactiveExecutor; 041import org.apache.camel.spi.Registry; 042import org.apache.camel.spi.RestConfiguration; 043import org.apache.camel.spi.RestRegistry; 044import org.apache.camel.spi.RouteController; 045import org.apache.camel.spi.RoutePolicyFactory; 046import org.apache.camel.spi.RuntimeEndpointRegistry; 047import org.apache.camel.spi.ShutdownStrategy; 048import org.apache.camel.spi.StreamCachingStrategy; 049import org.apache.camel.spi.Tracer; 050import org.apache.camel.spi.Transformer; 051import org.apache.camel.spi.TransformerRegistry; 052import org.apache.camel.spi.TypeConverterRegistry; 053import org.apache.camel.spi.UuidGenerator; 054import org.apache.camel.spi.Validator; 055import org.apache.camel.spi.ValidatorRegistry; 056import org.apache.camel.support.jsse.SSLContextParameters; 057 058/** 059 * Interface used to represent the CamelContext used to configure routes and the 060 * policies to use during message exchanges between endpoints. 061 * <p/> 062 * The CamelContext offers the following methods to control the lifecycle: 063 * <ul> 064 * <li>{@link #start()} - to start (<b>important:</b> the start method is not blocked, see more details 065 * <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li> 066 * <li>{@link #stop()} - to shutdown (will stop all routes/components/endpoints etc and clear internal state/cache)</li> 067 * <li>{@link #suspend()} - to pause routing messages</li> 068 * <li>{@link #resume()} - to resume after a suspend</li> 069 * </ul> 070 * <p/> 071 * <b>Notice:</b> {@link #stop()} and {@link #suspend()} will gracefully stop/suspend routes ensuring any messages 072 * in progress will be given time to complete. See more details at {@link org.apache.camel.spi.ShutdownStrategy}. 073 * <p/> 074 * If you are doing a hot restart then it's advised to use the suspend/resume methods which ensure a faster 075 * restart but also allows any internal state to be kept as is. 076 * The stop/start approach will do a <i>cold</i> restart of Camel, where all internal state is reset. 077 * <p/> 078 * End users are advised to use suspend/resume. Using stop is for shutting down Camel and it's not guaranteed that 079 * when it's being started again using the start method that Camel will operate consistently. 080 * <p/> 081 * For more advanced APIs with {@link CamelContext} see {@link ExtendedCamelContext}, which you can obtain via the adapt method. 082 */ 083public interface CamelContext extends StatefulService, RuntimeConfiguration { 084 085 /** 086 * Adapts this {@link org.apache.camel.CamelContext} to the specialized type. 087 * <p/> 088 * For example to adapt to <tt>ModelCamelContext</tt>, 089 * or <tt>SpringCamelContext</tt>, or <tt>CdiCamelContext</tt>, etc. 090 * 091 * @param type the type to adapt to 092 * @return this {@link org.apache.camel.CamelContext} adapted to the given type 093 */ 094 <T extends CamelContext> T adapt(Class<T> type); 095 096 /** 097 * Gets the extension of the given type. 098 * 099 * @param type the type of the extension 100 * @return the extension, or <tt>null</tt> if no extension has been installed. 101 */ 102 <T> T getExtension(Class<T> type); 103 104 /** 105 * Allows to install custom extensions to the Camel context. 106 * 107 * @param type the type of the extension 108 * @param module the instance of the extension 109 */ 110 <T> void setExtension(Class<T> type, T module); 111 112 /** 113 * If CamelContext during the start procedure was vetoed, and therefore causing Camel to not start. 114 */ 115 boolean isVetoStarted(); 116 117 /** 118 * Starts the {@link CamelContext} (<b>important:</b> the start method is not blocked, see more details 119 * <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li>. 120 * <p/> 121 * See more details at the class-level javadoc of this class. 122 * 123 * @throws RuntimeCamelException is thrown if starting failed 124 */ 125 @Override 126 void start(); 127 128 /** 129 * Stop and shutdown the {@link CamelContext} (will stop all routes/components/endpoints etc and clear internal state/cache). 130 * <p/> 131 * See more details at the class-level javadoc of this class. 132 * 133 * @throws RuntimeCamelException is thrown if stopping failed 134 */ 135 @Override 136 void stop(); 137 138 /** 139 * Gets the name (id) of the this CamelContext. 140 * 141 * @return the name 142 */ 143 String getName(); 144 145 /** 146 * Gets the current name strategy 147 * 148 * @return name strategy 149 */ 150 CamelContextNameStrategy getNameStrategy(); 151 152 /** 153 * Sets a custom name strategy 154 * 155 * @param nameStrategy name strategy 156 */ 157 void setNameStrategy(CamelContextNameStrategy nameStrategy); 158 159 /** 160 * Gets the current management name strategy 161 * 162 * @return management name strategy 163 */ 164 ManagementNameStrategy getManagementNameStrategy(); 165 166 /** 167 * Sets a custom management name strategy 168 * 169 * @param nameStrategy name strategy 170 */ 171 void setManagementNameStrategy(ManagementNameStrategy nameStrategy); 172 173 /** 174 * Gets the name this {@link CamelContext} was registered in JMX. 175 * <p/> 176 * The reason that a {@link CamelContext} can have a different name in JMX is the fact to remedy for name clash 177 * in JMX when having multiple {@link CamelContext}s in the same JVM. Camel will automatic reassign and use 178 * a free name to avoid failing to start. 179 * 180 * @return the management name 181 */ 182 String getManagementName(); 183 184 /** 185 * Sets the name this {@link CamelContext} will be registered in JMX. 186 */ 187 void setManagementName(String name); 188 189 /** 190 * Gets the version of the this CamelContext. 191 * 192 * @return the version 193 */ 194 String getVersion(); 195 196 /** 197 * Get the status of this CamelContext 198 * 199 * @return the status 200 */ 201 @Override 202 ServiceStatus getStatus(); 203 204 /** 205 * Gets the uptime in a human readable format 206 * 207 * @return the uptime in days/hours/minutes 208 */ 209 String getUptime(); 210 211 /** 212 * Gets the uptime in milli seconds 213 * 214 * @return the uptime in millis seconds 215 */ 216 long getUptimeMillis(); 217 218 // Service Methods 219 //----------------------------------------------------------------------- 220 221 /** 222 * Adds a service to this CamelContext, which allows this CamelContext to control the lifecycle, ensuring 223 * the service is stopped when the CamelContext stops. 224 * <p/> 225 * The service will also have {@link CamelContext} injected if its {@link CamelContextAware}. 226 * The service will also be enlisted in JMX for management (if JMX is enabled). 227 * The service will be started, if its not already started. 228 * 229 * @param object the service 230 * @throws Exception can be thrown when starting the service 231 */ 232 void addService(Object object) throws Exception; 233 234 /** 235 * Adds a service to this CamelContext. 236 * <p/> 237 * The service will also have {@link CamelContext} injected if its {@link CamelContextAware}. 238 * The service will also be enlisted in JMX for management (if JMX is enabled). 239 * The service will be started, if its not already started. 240 * <p/> 241 * If the option <tt>closeOnShutdown</tt> is <tt>true</tt> then this CamelContext will control the lifecycle, ensuring 242 * the service is stopped when the CamelContext stops. 243 * If the option <tt>closeOnShutdown</tt> is <tt>false</tt> then this CamelContext will not stop the service when the CamelContext stops. 244 * 245 * @param object the service 246 * @param stopOnShutdown whether to stop the service when this CamelContext shutdown. 247 * @throws Exception can be thrown when starting the service 248 */ 249 void addService(Object object, boolean stopOnShutdown) throws Exception; 250 251 /** 252 * Adds a service to this CamelContext. 253 * <p/> 254 * The service will also have {@link CamelContext} injected if its {@link CamelContextAware}. 255 * The service will also be enlisted in JMX for management (if JMX is enabled). 256 * The service will be started, if its not already started. 257 * <p/> 258 * If the option <tt>closeOnShutdown</tt> is <tt>true</tt> then this CamelContext will control the lifecycle, ensuring 259 * the service is stopped when the CamelContext stops. 260 * If the option <tt>closeOnShutdown</tt> is <tt>false</tt> then this CamelContext will not stop the service when the CamelContext stops. 261 * 262 * @param object the service 263 * @param stopOnShutdown whether to stop the service when this CamelContext shutdown. 264 * @param forceStart whether to force starting the service right now, as otherwise the service may be deferred being started 265 * to later using {@link #deferStartService(Object, boolean)} 266 * @throws Exception can be thrown when starting the service 267 */ 268 void addService(Object object, boolean stopOnShutdown, boolean forceStart) throws Exception; 269 270 /** 271 * Removes a service from this CamelContext. 272 * <p/> 273 * The service is assumed to have been previously added using {@link #addService(Object)} method. 274 * This method will <b>not</b> change the service lifecycle. 275 * 276 * @param object the service 277 * @throws Exception can be thrown if error removing the service 278 * @return <tt>true</tt> if the service was removed, <tt>false</tt> if no service existed 279 */ 280 boolean removeService(Object object) throws Exception; 281 282 /** 283 * Has the given service already been added to this CamelContext? 284 * 285 * @param object the service 286 * @return <tt>true</tt> if already added, <tt>false</tt> if not. 287 */ 288 boolean hasService(Object object); 289 290 /** 291 * Has the given service type already been added to this CamelContext? 292 * 293 * @param type the class type 294 * @return the service instance or <tt>null</tt> if not already added. 295 */ 296 <T> T hasService(Class<T> type); 297 298 /** 299 * Has the given service type already been added to this CamelContext? 300 * 301 * @param type the class type 302 * @return the services instance or empty set. 303 */ 304 <T> Set<T> hasServices(Class<T> type); 305 306 /** 307 * Defers starting the service until {@link CamelContext} is (almost started) or started and has initialized all its prior services and routes. 308 * <p/> 309 * If {@link CamelContext} is already started then the service is started immediately. 310 * 311 * @param object the service 312 * @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 313 * this {@link CamelContext} until the CamelContext is stopped. So do not use it for short lived services. 314 * @throws Exception can be thrown when starting the service, which is only attempted if {@link CamelContext} has already been started when calling this method. 315 */ 316 void deferStartService(Object object, boolean stopOnShutdown) throws Exception; 317 318 /** 319 * Adds the given listener to be invoked when {@link CamelContext} have just been started. 320 * <p/> 321 * This allows listeners to do any custom work after the routes and other services have been started and are running. 322 * <p/><b>Important:</b> The listener will always be invoked, also if the {@link CamelContext} has already been 323 * started, see the {@link org.apache.camel.StartupListener#onCamelContextStarted(CamelContext, boolean)} method. 324 * 325 * @param listener the listener 326 * @throws Exception can be thrown if {@link CamelContext} is already started and the listener is invoked 327 * and cause an exception to be thrown 328 */ 329 void addStartupListener(StartupListener listener) throws Exception; 330 331 // Component Management Methods 332 //----------------------------------------------------------------------- 333 334 /** 335 * Adds a component to the context. 336 * 337 * @param componentName the name the component is registered as 338 * @param component the component 339 */ 340 void addComponent(String componentName, Component component); 341 342 /** 343 * Is the given component already registered? 344 * 345 * @param componentName the name of the component 346 * @return the registered Component or <tt>null</tt> if not registered 347 */ 348 Component hasComponent(String componentName); 349 350 /** 351 * Gets a component from the CamelContext by name. 352 * <p/> 353 * Notice the returned component will be auto-started. If you do not intend to do that 354 * then use {@link #getComponent(String, boolean, boolean)}. 355 * 356 * @param componentName the name of the component 357 * @return the component 358 */ 359 Component getComponent(String componentName); 360 361 /** 362 * Gets a component from the CamelContext by name. 363 * <p/> 364 * Notice the returned component will be auto-started. If you do not intend to do that 365 * then use {@link #getComponent(String, boolean, boolean)}. 366 * 367 * @param name the name of the component 368 * @param autoCreateComponents whether or not the component should 369 * be lazily created if it does not already exist 370 * @return the component 371 */ 372 Component getComponent(String name, boolean autoCreateComponents); 373 374 /** 375 * Gets a component from the CamelContext by name. 376 * 377 * @param name the name of the component 378 * @param autoCreateComponents whether or not the component should 379 * be lazily created if it does not already exist 380 * @param autoStart whether to auto start the component if {@link CamelContext} is already started. 381 * @return the component 382 */ 383 Component getComponent(String name, boolean autoCreateComponents, boolean autoStart); 384 385 /** 386 * Gets a component from the CamelContext by name and specifying the expected type of component. 387 * 388 * @param name the name to lookup 389 * @param componentType the expected type 390 * @return the component 391 */ 392 <T extends Component> T getComponent(String name, Class<T> componentType); 393 394 /** 395 * Gets a readonly list of names of the components currently registered 396 * 397 * @return a readonly list with the names of the components 398 */ 399 List<String> getComponentNames(); 400 401 /** 402 * Removes a previously added component. 403 * <p/> 404 * The component being removed will be stopped first. 405 * 406 * @param componentName the component name to remove 407 * @return the previously added component or null if it had not been previously added. 408 */ 409 Component removeComponent(String componentName); 410 411 // Endpoint Management Methods 412 //----------------------------------------------------------------------- 413 414 /** 415 * Gets the {@link org.apache.camel.spi.EndpointRegistry} 416 */ 417 EndpointRegistry<? extends ValueHolder<String>> getEndpointRegistry(); 418 419 /** 420 * Resolves the given name to an {@link Endpoint} of the specified type. 421 * If the name has a singleton endpoint registered, then the singleton is returned. 422 * Otherwise, a new {@link Endpoint} is created and registered in the {@link org.apache.camel.spi.EndpointRegistry}. 423 * 424 * @param uri the URI of the endpoint 425 * @return the endpoint 426 */ 427 Endpoint getEndpoint(String uri); 428 429 /** 430 * Resolves the given name to an {@link Endpoint} of the specified type. 431 * If the name has a singleton endpoint registered, then the singleton is returned. 432 * Otherwise, a new {@link Endpoint} is created and registered in the {@link org.apache.camel.spi.EndpointRegistry}. 433 * 434 * @param uri the URI of the endpoint 435 * @param parameters the parameters to customize the endpoint 436 * @return the endpoint 437 */ 438 Endpoint getEndpoint(String uri, Map<String, Object> parameters); 439 440 /** 441 * Resolves the given name to an {@link Endpoint} of the specified type. 442 * If the name has a singleton endpoint registered, then the singleton is returned. 443 * Otherwise, a new {@link Endpoint} is created and registered in the {@link org.apache.camel.spi.EndpointRegistry}. 444 * 445 * @param name the name of the endpoint 446 * @param endpointType the expected type 447 * @return the endpoint 448 */ 449 <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType); 450 451 /** 452 * Returns a new {@link Collection} of all of the endpoints from the {@link org.apache.camel.spi.EndpointRegistry} 453 * 454 * @return all endpoints 455 */ 456 Collection<Endpoint> getEndpoints(); 457 458 /** 459 * Returns a new {@link Map} containing all of the endpoints from the {@link org.apache.camel.spi.EndpointRegistry} 460 * 461 * @return map of endpoints 462 * @deprecated use {@link #getEndpointRegistry()} 463 */ 464 @Deprecated 465 Map<String, Endpoint> getEndpointMap(); 466 467 /** 468 * Is the given endpoint already registered in the {@link org.apache.camel.spi.EndpointRegistry} 469 * 470 * @param uri the URI of the endpoint 471 * @return the registered endpoint or <tt>null</tt> if not registered 472 */ 473 Endpoint hasEndpoint(String uri); 474 475 /** 476 * Adds and starts the endpoint to the {@link org.apache.camel.spi.EndpointRegistry} using the given URI. 477 * 478 * @param uri the URI to be used to resolve this endpoint 479 * @param endpoint the endpoint to be started and added to the registry 480 * @return the old endpoint that was previously registered or <tt>null</tt> if none was registered 481 * @throws Exception if the new endpoint could not be started or the old endpoint could not be stopped 482 */ 483 Endpoint addEndpoint(String uri, Endpoint endpoint) throws Exception; 484 485 /** 486 * Removes the endpoint from the {@link org.apache.camel.spi.EndpointRegistry}. 487 * <p/> 488 * The endpoint being removed will be stopped first. 489 * 490 * @param endpoint the endpoint 491 * @throws Exception if the endpoint could not be stopped 492 */ 493 void removeEndpoint(Endpoint endpoint) throws Exception; 494 495 /** 496 * Removes all endpoints with the given URI from the {@link org.apache.camel.spi.EndpointRegistry}. 497 * <p/> 498 * The endpoints being removed will be stopped first. 499 * 500 * @param pattern an uri or pattern to match 501 * @return a collection of endpoints removed which could be empty if there are no endpoints found for the given <tt>pattern</tt> 502 * @throws Exception if at least one endpoint could not be stopped 503 * @see org.apache.camel.support.EndpointHelper#matchEndpoint(CamelContext, String, String) for pattern 504 */ 505 Collection<Endpoint> removeEndpoints(String pattern) throws Exception; 506 507 /** 508 * Gets the global endpoint configuration, where you can configure common endpoint options. 509 */ 510 GlobalEndpointConfiguration getGlobalEndpointConfiguration(); 511 512 // Route Management Methods 513 //----------------------------------------------------------------------- 514 515 /** 516 * Sets a custom {@link RouteController} to use 517 * 518 * @param routeController the route controller 519 */ 520 void setRouteController(RouteController routeController); 521 522 /** 523 * Gets the {@link RouteController} 524 * 525 * @return the route controller. 526 */ 527 RouteController getRouteController(); 528 529 /** 530 * Returns the current routes in this CamelContext 531 * 532 * @return the current routes 533 */ 534 List<Route> getRoutes(); 535 536 /** 537 * Gets the route with the given id 538 * 539 * @param id id of the route 540 * @return the route or <tt>null</tt> if not found 541 */ 542 Route getRoute(String id); 543 544 /** 545 * Gets the processor from any of the routes which with the given id 546 * 547 * @param id id of the processor 548 * @return the processor or <tt>null</tt> if not found 549 */ 550 Processor getProcessor(String id); 551 552 /** 553 * Gets the processor from any of the routes which with the given id 554 * 555 * @param id id of the processor 556 * @param type the processor type 557 * @return the processor or <tt>null</tt> if not found 558 * @throws java.lang.ClassCastException is thrown if the type is not correct type 559 */ 560 <T extends Processor> T getProcessor(String id, Class<T> type); 561 562 /** 563 * Adds a collection of routes to this CamelContext using the given builder 564 * to build them. 565 * <p/> 566 * <b>Important:</b> The added routes will <b>only</b> be started, if {@link CamelContext} 567 * is already started. You may want to check the state of {@link CamelContext} before 568 * adding the routes, using the {@link org.apache.camel.CamelContext#getStatus()} method. 569 * <p/> 570 * <b>Important: </b> Each route in the same {@link org.apache.camel.CamelContext} must have an <b>unique</b> route id. 571 * If you use the API from {@link org.apache.camel.CamelContext} or {@link org.apache.camel.model.ModelCamelContext} to add routes, then any 572 * new routes which has a route id that matches an old route, then the old route is replaced by the new route. 573 * 574 * @param builder the builder which will create the routes and add them to this CamelContext 575 * @throws Exception if the routes could not be created for whatever reason 576 */ 577 void addRoutes(RoutesBuilder builder) throws Exception; 578 579 /** 580 * Removes the given route (the route <b>must</b> be stopped before it can be removed). 581 * <p/> 582 * A route which is removed will be unregistered from JMX, have its services stopped/shutdown and the route 583 * definition etc. will also be removed. All the resources related to the route will be stopped and cleared. 584 * <p/> 585 * <b>Important:</b> When removing a route, the {@link Endpoint}s which are in the static cache of 586 * {@link org.apache.camel.spi.EndpointRegistry} and are <b>only</b> used by the route (not used by other routes) 587 * will also be removed. But {@link Endpoint}s which may have been created as part of routing messages by the route, 588 * and those endpoints are enlisted in the dynamic cache of {@link org.apache.camel.spi.EndpointRegistry} are 589 * <b>not</b> removed. To remove those dynamic kind of endpoints, use the {@link #removeEndpoints(String)} method. 590 * If not removing those endpoints, they will be kept in the dynamic cache of {@link org.apache.camel.spi.EndpointRegistry}, 591 * but my eventually be removed (evicted) when they have not been in use for a longer period of time; and the 592 * dynamic cache upper limit is hit, and it evicts the least used endpoints. 593 * <p/> 594 * End users can use this method to remove unwanted routes or temporary routes which no longer is in demand. 595 * 596 * @param routeId the route id 597 * @return <tt>true</tt> if the route was removed, <tt>false</tt> if the route could not be removed because its not stopped 598 * @throws Exception is thrown if the route could not be shutdown for whatever reason 599 */ 600 boolean removeRoute(String routeId) throws Exception; 601 602 /** 603 * Adds the given route policy factory 604 * 605 * @param routePolicyFactory the factory 606 */ 607 void addRoutePolicyFactory(RoutePolicyFactory routePolicyFactory); 608 609 /** 610 * Gets the route policy factories 611 * 612 * @return the list of current route policy factories 613 */ 614 List<RoutePolicyFactory> getRoutePolicyFactories(); 615 616 // Rest Methods 617 //----------------------------------------------------------------------- 618 619 /** 620 * Sets a custom {@link org.apache.camel.spi.RestConfiguration} 621 * 622 * @param restConfiguration the REST configuration 623 */ 624 void setRestConfiguration(RestConfiguration restConfiguration); 625 626 /** 627 * Gets the default REST configuration 628 * 629 * @return the configuration, or <tt>null</tt> if none has been configured. 630 */ 631 RestConfiguration getRestConfiguration(); 632 633 /** 634 * Sets a custom {@link org.apache.camel.spi.RestConfiguration} 635 * 636 * @param restConfiguration the REST configuration 637 */ 638 @Deprecated 639 void addRestConfiguration(RestConfiguration restConfiguration); 640 641 /** 642 * Gets the REST configuration for the given component 643 * 644 * @param component the component name to get the configuration 645 * @param defaultIfNotFound determine if the default configuration is returned if there isn't a 646 * specific configuration for the given component 647 * @return the configuration, or <tt>null</tt> if none has been configured. 648 */ 649 RestConfiguration getRestConfiguration(String component, boolean defaultIfNotFound); 650 651 /** 652 * Gets all the RestConfiguration's 653 */ 654 @Deprecated 655 Collection<RestConfiguration> getRestConfigurations(); 656 657 /** 658 * Gets the {@link org.apache.camel.spi.RestRegistry} to use 659 */ 660 RestRegistry getRestRegistry(); 661 662 /** 663 * Sets a custom {@link org.apache.camel.spi.RestRegistry} to use. 664 */ 665 void setRestRegistry(RestRegistry restRegistry); 666 667 // Properties 668 //----------------------------------------------------------------------- 669 670 /** 671 * Returns the type converter used to coerce types from one type to another 672 * 673 * @return the converter 674 */ 675 TypeConverter getTypeConverter(); 676 677 /** 678 * Returns the type converter registry where type converters can be added or looked up 679 * 680 * @return the type converter registry 681 */ 682 TypeConverterRegistry getTypeConverterRegistry(); 683 684 /** 685 * Configures the type converter registry to use, where type converters can be added or looked up. 686 * 687 * @param typeConverterRegistry the registry to use 688 */ 689 void setTypeConverterRegistry(TypeConverterRegistry typeConverterRegistry); 690 691 /** 692 * Returns the registry used to lookup components by name and type such as SimpleRegistry, Spring ApplicationContext, 693 * JNDI, or the OSGi Service Registry. 694 * 695 * @return the registry 696 */ 697 Registry getRegistry(); 698 699 /** 700 * Returns the registry used to lookup components by name and as the given type 701 * 702 * @param type the registry type such as org.apache.camel.impl.JndiRegistry 703 * @return the registry, or <tt>null</tt> if the given type was not found as a registry implementation 704 */ 705 <T> T getRegistry(Class<T> type); 706 707 /** 708 * Returns the injector used to instantiate objects by type 709 * 710 * @return the injector 711 */ 712 Injector getInjector(); 713 714 /** 715 * Sets the injector to use 716 */ 717 void setInjector(Injector injector); 718 719 /** 720 * Returns the lifecycle strategies used to handle lifecycle notifications 721 * 722 * @return the lifecycle strategies 723 */ 724 List<LifecycleStrategy> getLifecycleStrategies(); 725 726 /** 727 * Adds the given lifecycle strategy to be used. 728 * 729 * @param lifecycleStrategy the strategy 730 */ 731 void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy); 732 733 /** 734 * Resolves a language for creating expressions 735 * 736 * @param language name of the language 737 * @return the resolved language 738 * @throws NoSuchLanguageException is thrown if language could not be resolved 739 */ 740 Language resolveLanguage(String language) throws NoSuchLanguageException; 741 742 /** 743 * Parses the given text and resolve any property placeholders - using {{key}}. 744 * 745 * @param text the text such as an endpoint uri or the likes 746 * @return the text with resolved property placeholders 747 * @throws IllegalArgumentException is thrown if property placeholders was used and there was an error resolving them 748 */ 749 String resolvePropertyPlaceholders(String text); 750 751 /** 752 * Returns the configured properties component or create one if none has been configured. 753 * 754 * @return the properties component 755 */ 756 PropertiesComponent getPropertiesComponent(); 757 758 /** 759 * Sets a custom properties component to be used. 760 */ 761 void setPropertiesComponent(PropertiesComponent propertiesComponent); 762 763 /** 764 * Gets a readonly list with the names of the languages currently registered. 765 * 766 * @return a readonly list with the names of the languages 767 * @deprecated not in use 768 */ 769 @Deprecated 770 List<String> getLanguageNames(); 771 772 /** 773 * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away. 774 * <p/> 775 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 776 * Why does Camel use too many threads with ProducerTemplate?</a> 777 * <p/> 778 * <b>Important:</b> Make sure to call {@link org.apache.camel.ProducerTemplate#stop()} when you are done using the template, 779 * to clean up any resources. 780 * <p/> 781 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 782 * If no key was defined then it will fallback to a default size of 1000. 783 * You can also use the {@link org.apache.camel.ProducerTemplate#setMaximumCacheSize(int)} method to use a custom value 784 * before starting the template. 785 * 786 * @return the template 787 * @throws RuntimeCamelException is thrown if error starting the template 788 */ 789 ProducerTemplate createProducerTemplate(); 790 791 /** 792 * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away. 793 * <p/> 794 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 795 * Why does Camel use too many threads with ProducerTemplate?</a> 796 * <p/> 797 * <b>Important:</b> Make sure to call {@link ProducerTemplate#stop()} when you are done using the template, 798 * to clean up any resources. 799 * 800 * @param maximumCacheSize the maximum cache size 801 * @return the template 802 * @throws RuntimeCamelException is thrown if error starting the template 803 */ 804 ProducerTemplate createProducerTemplate(int maximumCacheSize); 805 806 /** 807 * Creates a new {@link FluentProducerTemplate} which is <b>started</b> and therefore ready to use right away. 808 * <p/> 809 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 810 * Why does Camel use too many threads with ProducerTemplate?</a> 811 * <p/> 812 * <b>Important:</b> Make sure to call {@link org.apache.camel.FluentProducerTemplate#stop()} when you are done using the template, 813 * to clean up any resources. 814 * <p/> 815 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 816 * If no key was defined then it will fallback to a default size of 1000. 817 * You can also use the {@link org.apache.camel.FluentProducerTemplate#setMaximumCacheSize(int)} method to use a custom value 818 * before starting the template. 819 * 820 * @return the template 821 * @throws RuntimeCamelException is thrown if error starting the template 822 */ 823 FluentProducerTemplate createFluentProducerTemplate(); 824 825 /** 826 * Creates a new {@link FluentProducerTemplate} which is <b>started</b> and therefore ready to use right away. 827 * <p/> 828 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 829 * Why does Camel use too many threads with ProducerTemplate?</a> 830 * <p/> 831 * <b>Important:</b> Make sure to call {@link FluentProducerTemplate#stop()} when you are done using the template, 832 * to clean up any resources. 833 * 834 * @param maximumCacheSize the maximum cache size 835 * @return the template 836 * @throws RuntimeCamelException is thrown if error starting the template 837 */ 838 FluentProducerTemplate createFluentProducerTemplate(int maximumCacheSize); 839 840 /** 841 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away. 842 * <p/> 843 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 844 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate. 845 * <p/> 846 * <b>Important:</b> Make sure to call {@link ConsumerTemplate#stop()} when you are done using the template, 847 * to clean up any resources. 848 * <p/> 849 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 850 * If no key was defined then it will fallback to a default size of 1000. 851 * You can also use the {@link org.apache.camel.ConsumerTemplate#setMaximumCacheSize(int)} method to use a custom value 852 * before starting the template. 853 * 854 * @return the template 855 * @throws RuntimeCamelException is thrown if error starting the template 856 */ 857 ConsumerTemplate createConsumerTemplate(); 858 859 /** 860 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away. 861 * <p/> 862 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 863 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate. 864 * <p/> 865 * <b>Important:</b> Make sure to call {@link ConsumerTemplate#stop()} when you are done using the template, 866 * to clean up any resources. 867 * 868 * @param maximumCacheSize the maximum cache size 869 * @return the template 870 * @throws RuntimeCamelException is thrown if error starting the template 871 */ 872 ConsumerTemplate createConsumerTemplate(int maximumCacheSize); 873 874 /** 875 * Resolve a data format given its name 876 * 877 * @param name the data format name or a reference to it in the {@link Registry} 878 * @return the resolved data format, or <tt>null</tt> if not found 879 */ 880 DataFormat resolveDataFormat(String name); 881 882 /** 883 * Creates the given data format given its name. 884 * 885 * @param name the data format name or a reference to a data format factory in the {@link Registry} 886 * @return the resolved data format, or <tt>null</tt> if not found 887 */ 888 DataFormat createDataFormat(String name); 889 890 /** 891 * Resolve a transformer given a scheme 892 * 893 * @param model data model name. 894 * @return the resolved transformer, or <tt>null</tt> if not found 895 */ 896 Transformer resolveTransformer(String model); 897 898 /** 899 * Resolve a transformer given from/to data type. 900 * 901 * @param from from data type 902 * @param to to data type 903 * @return the resolved transformer, or <tt>null</tt> if not found 904 */ 905 Transformer resolveTransformer(DataType from, DataType to); 906 907 /** 908 * Gets the {@link org.apache.camel.spi.TransformerRegistry} 909 * @return the TransformerRegistry 910 */ 911 TransformerRegistry<? extends ValueHolder<String>> getTransformerRegistry(); 912 913 /** 914 * Resolve a validator given from/to data type. 915 * 916 * @param type the data type 917 * @return the resolved validator, or <tt>null</tt> if not found 918 */ 919 Validator resolveValidator(DataType type); 920 921 /** 922 * Gets the {@link org.apache.camel.spi.ValidatorRegistry} 923 * @return the ValidatorRegistry 924 */ 925 ValidatorRegistry<? extends ValueHolder<String>> getValidatorRegistry(); 926 927 /** 928 * Sets global options that can be referenced in the camel context 929 * <p/> 930 * <b>Important:</b> This has nothing to do with property placeholders, and is just a plain set of key/value pairs 931 * which are used to configure global options on CamelContext, such as a maximum debug logging length etc. 932 * For property placeholders use {@link #resolvePropertyPlaceholders(String)} method and see more details 933 * at the <a href="http://camel.apache.org/using-propertyplaceholder.html">property placeholder</a> documentation. 934 * 935 * @param globalOptions global options that can be referenced in the camel context 936 */ 937 void setGlobalOptions(Map<String, String> globalOptions); 938 939 /** 940 * Gets global options that can be referenced in the camel context. 941 * <p/> 942 * <b>Important:</b> This has nothing to do with property placeholders, and is just a plain set of key/value pairs 943 * which are used to configure global options on CamelContext, such as a maximum debug logging length etc. 944 * For property placeholders use {@link #resolvePropertyPlaceholders(String)} method and see more details 945 * at the <a href="http://camel.apache.org/using-propertyplaceholder.html">property placeholder</a> documentation. 946 * 947 * @return global options for this context 948 */ 949 Map<String, String> getGlobalOptions(); 950 951 /** 952 * Gets the global option value that can be referenced in the camel context 953 * <p/> 954 * <b>Important:</b> This has nothing to do with property placeholders, and is just a plain set of key/value pairs 955 * which are used to configure global options on CamelContext, such as a maximum debug logging length etc. 956 * For property placeholders use {@link #resolvePropertyPlaceholders(String)} method and see more details 957 * at the <a href="http://camel.apache.org/using-propertyplaceholder.html">property placeholder</a> documentation. 958 * 959 * @return the string value of the global option 960 */ 961 String getGlobalOption(String key); 962 963 /** 964 * Returns the class resolver to be used for loading/lookup of classes. 965 * 966 * @return the resolver 967 */ 968 ClassResolver getClassResolver(); 969 970 /** 971 * Sets the class resolver to be use 972 * 973 * @param resolver the resolver 974 */ 975 void setClassResolver(ClassResolver resolver); 976 977 /** 978 * Gets the management strategy 979 * 980 * @return the management strategy 981 */ 982 ManagementStrategy getManagementStrategy(); 983 984 /** 985 * Sets the management strategy to use 986 * 987 * @param strategy the management strategy 988 */ 989 void setManagementStrategy(ManagementStrategy strategy); 990 991 /** 992 * Disables using JMX as {@link org.apache.camel.spi.ManagementStrategy}. 993 * <p/> 994 * <b>Important:</b> This method must be called <b>before</b> the {@link CamelContext} is started. 995 * 996 * @throws IllegalStateException is thrown if the {@link CamelContext} is not in stopped state. 997 */ 998 void disableJMX() throws IllegalStateException; 999 1000 /** 1001 * Gets the inflight repository 1002 * 1003 * @return the repository 1004 */ 1005 InflightRepository getInflightRepository(); 1006 1007 /** 1008 * Sets a custom inflight repository to use 1009 * 1010 * @param repository the repository 1011 */ 1012 void setInflightRepository(InflightRepository repository); 1013 1014 /** 1015 * Gets the application CamelContext class loader which may be helpful for running camel in other containers 1016 * 1017 * @return the application CamelContext class loader 1018 */ 1019 ClassLoader getApplicationContextClassLoader(); 1020 1021 /** 1022 * Sets the application CamelContext class loader 1023 * 1024 * @param classLoader the class loader 1025 */ 1026 void setApplicationContextClassLoader(ClassLoader classLoader); 1027 1028 /** 1029 * Gets the current shutdown strategy 1030 * 1031 * @return the strategy 1032 */ 1033 ShutdownStrategy getShutdownStrategy(); 1034 1035 /** 1036 * Sets a custom shutdown strategy 1037 * 1038 * @param shutdownStrategy the custom strategy 1039 */ 1040 void setShutdownStrategy(ShutdownStrategy shutdownStrategy); 1041 1042 /** 1043 * Gets the current {@link org.apache.camel.spi.ExecutorServiceManager} 1044 * 1045 * @return the manager 1046 */ 1047 ExecutorServiceManager getExecutorServiceManager(); 1048 1049 /** 1050 * Sets a custom {@link org.apache.camel.spi.ExecutorServiceManager} 1051 * 1052 * @param executorServiceManager the custom manager 1053 */ 1054 void setExecutorServiceManager(ExecutorServiceManager executorServiceManager); 1055 1056 /** 1057 * Gets the current {@link org.apache.camel.spi.MessageHistoryFactory} 1058 * 1059 * @return the factory 1060 */ 1061 MessageHistoryFactory getMessageHistoryFactory(); 1062 1063 /** 1064 * Sets a custom {@link org.apache.camel.spi.MessageHistoryFactory} 1065 * 1066 * @param messageHistoryFactory the custom factory 1067 */ 1068 void setMessageHistoryFactory(MessageHistoryFactory messageHistoryFactory); 1069 1070 /** 1071 * Gets the current {@link Debugger} 1072 * 1073 * @return the debugger 1074 */ 1075 Debugger getDebugger(); 1076 1077 /** 1078 * Sets a custom {@link Debugger} 1079 * 1080 * @param debugger the debugger 1081 */ 1082 void setDebugger(Debugger debugger); 1083 1084 /** 1085 * Gets the current {@link Tracer} 1086 * 1087 * @return the tracer 1088 */ 1089 Tracer getTracer(); 1090 1091 /** 1092 * Sets a custom {@link Tracer} 1093 */ 1094 void setTracer(Tracer tracer); 1095 1096 /** 1097 * Gets the current {@link UuidGenerator} 1098 * 1099 * @return the uuidGenerator 1100 */ 1101 UuidGenerator getUuidGenerator(); 1102 1103 /** 1104 * Sets a custom {@link UuidGenerator} (should only be set once) 1105 * 1106 * @param uuidGenerator the UUID Generator 1107 */ 1108 void setUuidGenerator(UuidGenerator uuidGenerator); 1109 1110 /** 1111 * Whether to load custom type converters by scanning classpath. 1112 * This is used for backwards compatibility with Camel 2.x. 1113 * Its recommended to migrate to use fast type converter loading 1114 * by setting <tt>@Converter(loader = true)</tt> on your custom 1115 * type converter classes. 1116 */ 1117 Boolean isLoadTypeConverters(); 1118 1119 /** 1120 * Whether to load custom type converters by scanning classpath. 1121 * This is used for backwards compatibility with Camel 2.x. 1122 * Its recommended to migrate to use fast type converter loading 1123 * by setting <tt>@Converter(loader = true)</tt> on your custom 1124 * type converter classes. 1125 * 1126 * @param loadTypeConverters whether to load custom type converters using classpath scanning. 1127 */ 1128 void setLoadTypeConverters(Boolean loadTypeConverters); 1129 1130 /** 1131 * Whether or not type converter statistics is enabled. 1132 * <p/> 1133 * By default the type converter utilization statistics is disabled. 1134 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 1135 * 1136 * @return <tt>true</tt> if enabled, <tt>false</tt> if disabled (default). 1137 */ 1138 Boolean isTypeConverterStatisticsEnabled(); 1139 1140 /** 1141 * Sets whether or not type converter statistics is enabled. 1142 * <p/> 1143 * By default the type converter utilization statistics is disabled. 1144 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 1145 * <p/> 1146 * You can enable/disable the statistics at runtime using the 1147 * {@link org.apache.camel.spi.TypeConverterRegistry#getStatistics()#setTypeConverterStatisticsEnabled(Boolean)} method, 1148 * or from JMX on the {@link org.apache.camel.api.management.mbean.ManagedTypeConverterRegistryMBean} mbean. 1149 * 1150 * @param typeConverterStatisticsEnabled <tt>true</tt> to enable, <tt>false</tt> to disable 1151 */ 1152 void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled); 1153 1154 /** 1155 * Whether or not <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> logging is being enabled. 1156 * 1157 * @return <tt>true</tt> if MDC logging is enabled 1158 */ 1159 Boolean isUseMDCLogging(); 1160 1161 /** 1162 * Set whether <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> is enabled. 1163 * 1164 * @param useMDCLogging <tt>true</tt> to enable MDC logging, <tt>false</tt> to disable 1165 */ 1166 void setUseMDCLogging(Boolean useMDCLogging); 1167 1168 /** 1169 * Gets the pattern used for determine which custom MDC keys to propagate during message routing when 1170 * the routing engine continues routing asynchronously for the given message. Setting this pattern to <tt>*</tt> will 1171 * propagate all custom keys. Or setting the pattern to <tt>foo*,bar*</tt> will propagate any keys starting with 1172 * either foo or bar. 1173 * Notice that a set of standard Camel MDC keys are always propagated which starts with <tt>camel.</tt> as key name. 1174 * <p/> 1175 * The match rules are applied in this order (case insensitive): 1176 * <ul> 1177 * <li>exact match, returns true</li> 1178 * <li>wildcard match (pattern ends with a * and the name starts with the pattern), returns true</li> 1179 * <li>regular expression match, returns true</li> 1180 * <li>otherwise returns false</li> 1181 * </ul> 1182 */ 1183 String getMDCLoggingKeysPattern(); 1184 1185 /** 1186 * Sets the pattern used for determine which custom MDC keys to propagate during message routing when 1187 * the routing engine continues routing asynchronously for the given message. Setting this pattern to <tt>*</tt> will 1188 * propagate all custom keys. Or setting the pattern to <tt>foo*,bar*</tt> will propagate any keys starting with 1189 * either foo or bar. 1190 * Notice that a set of standard Camel MDC keys are always propagated which starts with <tt>camel.</tt> as key name. 1191 * <p/> 1192 * The match rules are applied in this order (case insensitive): 1193 * <ul> 1194 * <li>exact match, returns true</li> 1195 * <li>wildcard match (pattern ends with a * and the name starts with the pattern), returns true</li> 1196 * <li>regular expression match, returns true</li> 1197 * <li>otherwise returns false</li> 1198 * </ul> 1199 * 1200 * @param pattern the pattern 1201 */ 1202 void setMDCLoggingKeysPattern(String pattern); 1203 1204 /** 1205 * Whether to enable using data type on Camel messages. 1206 * <p/> 1207 * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. 1208 * Otherwise data type is default off. 1209 * 1210 * @return <tt>true</tt> if data type is enabled 1211 */ 1212 Boolean isUseDataType(); 1213 1214 /** 1215 * Whether to enable using data type on Camel messages. 1216 * <p/> 1217 * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. 1218 * Otherwise data type is default off. 1219 * 1220 * @param useDataType <tt>true</tt> to enable data type on Camel messages. 1221 */ 1222 void setUseDataType(Boolean useDataType); 1223 1224 /** 1225 * Whether or not breadcrumb is enabled. 1226 * 1227 * @return <tt>true</tt> if breadcrumb is enabled 1228 */ 1229 Boolean isUseBreadcrumb(); 1230 1231 /** 1232 * Set whether breadcrumb is enabled. 1233 * 1234 * @param useBreadcrumb <tt>true</tt> to enable breadcrumb, <tt>false</tt> to disable 1235 */ 1236 void setUseBreadcrumb(Boolean useBreadcrumb); 1237 1238 /** 1239 * Gets the {@link StreamCachingStrategy} to use. 1240 */ 1241 StreamCachingStrategy getStreamCachingStrategy(); 1242 1243 /** 1244 * Sets a custom {@link StreamCachingStrategy} to use. 1245 */ 1246 void setStreamCachingStrategy(StreamCachingStrategy streamCachingStrategy); 1247 1248 /** 1249 * Gets the {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use, or <tt>null</tt> if none is in use. 1250 */ 1251 RuntimeEndpointRegistry getRuntimeEndpointRegistry(); 1252 1253 /** 1254 * Sets a custom {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use. 1255 */ 1256 void setRuntimeEndpointRegistry(RuntimeEndpointRegistry runtimeEndpointRegistry); 1257 1258 /** 1259 * Sets the global SSL context parameters. 1260 */ 1261 void setSSLContextParameters(SSLContextParameters sslContextParameters); 1262 1263 /** 1264 * Gets the global SSL context parameters if configured. 1265 */ 1266 SSLContextParameters getSSLContextParameters(); 1267 1268 /** 1269 * Gets the {@link HeadersMapFactory} to use. 1270 */ 1271 HeadersMapFactory getHeadersMapFactory(); 1272 1273 /** 1274 * Sets a custom {@link HeadersMapFactory} to be used. 1275 */ 1276 void setHeadersMapFactory(HeadersMapFactory factory); 1277 1278 ReactiveExecutor getReactiveExecutor(); 1279 1280 /** 1281 * Sets a custom {@link ReactiveExecutor} to be used. 1282 */ 1283 void setReactiveExecutor(ReactiveExecutor reactiveExecutor); 1284 1285}