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 // Route Management Methods 508 //----------------------------------------------------------------------- 509 510 /** 511 * Sets a custom {@link RouteController} to use 512 * 513 * @param routeController the route controller 514 */ 515 void setRouteController(RouteController routeController); 516 517 /** 518 * Gets the {@link RouteController} 519 * 520 * @return the route controller. 521 */ 522 RouteController getRouteController(); 523 524 /** 525 * Returns the current routes in this CamelContext 526 * 527 * @return the current routes 528 */ 529 List<Route> getRoutes(); 530 531 /** 532 * Gets the route with the given id 533 * 534 * @param id id of the route 535 * @return the route or <tt>null</tt> if not found 536 */ 537 Route getRoute(String id); 538 539 /** 540 * Gets the processor from any of the routes which with the given id 541 * 542 * @param id id of the processor 543 * @return the processor or <tt>null</tt> if not found 544 */ 545 Processor getProcessor(String id); 546 547 /** 548 * Gets the processor from any of the routes which with the given id 549 * 550 * @param id id of the processor 551 * @param type the processor type 552 * @return the processor or <tt>null</tt> if not found 553 * @throws java.lang.ClassCastException is thrown if the type is not correct type 554 */ 555 <T extends Processor> T getProcessor(String id, Class<T> type); 556 557 /** 558 * Adds a collection of routes to this CamelContext using the given builder 559 * to build them. 560 * <p/> 561 * <b>Important:</b> The added routes will <b>only</b> be started, if {@link CamelContext} 562 * is already started. You may want to check the state of {@link CamelContext} before 563 * adding the routes, using the {@link org.apache.camel.CamelContext#getStatus()} method. 564 * <p/> 565 * <b>Important: </b> Each route in the same {@link org.apache.camel.CamelContext} must have an <b>unique</b> route id. 566 * If you use the API from {@link org.apache.camel.CamelContext} or {@link org.apache.camel.model.ModelCamelContext} to add routes, then any 567 * new routes which has a route id that matches an old route, then the old route is replaced by the new route. 568 * 569 * @param builder the builder which will create the routes and add them to this CamelContext 570 * @throws Exception if the routes could not be created for whatever reason 571 */ 572 void addRoutes(RoutesBuilder builder) throws Exception; 573 574 /** 575 * Removes the given route (the route <b>must</b> be stopped before it can be removed). 576 * <p/> 577 * A route which is removed will be unregistered from JMX, have its services stopped/shutdown and the route 578 * definition etc. will also be removed. All the resources related to the route will be stopped and cleared. 579 * <p/> 580 * <b>Important:</b> When removing a route, the {@link Endpoint}s which are in the static cache of 581 * {@link org.apache.camel.spi.EndpointRegistry} and are <b>only</b> used by the route (not used by other routes) 582 * will also be removed. But {@link Endpoint}s which may have been created as part of routing messages by the route, 583 * and those endpoints are enlisted in the dynamic cache of {@link org.apache.camel.spi.EndpointRegistry} are 584 * <b>not</b> removed. To remove those dynamic kind of endpoints, use the {@link #removeEndpoints(String)} method. 585 * If not removing those endpoints, they will be kept in the dynamic cache of {@link org.apache.camel.spi.EndpointRegistry}, 586 * but my eventually be removed (evicted) when they have not been in use for a longer period of time; and the 587 * dynamic cache upper limit is hit, and it evicts the least used endpoints. 588 * <p/> 589 * End users can use this method to remove unwanted routes or temporary routes which no longer is in demand. 590 * 591 * @param routeId the route id 592 * @return <tt>true</tt> if the route was removed, <tt>false</tt> if the route could not be removed because its not stopped 593 * @throws Exception is thrown if the route could not be shutdown for whatever reason 594 */ 595 boolean removeRoute(String routeId) throws Exception; 596 597 /** 598 * Adds the given route policy factory 599 * 600 * @param routePolicyFactory the factory 601 */ 602 void addRoutePolicyFactory(RoutePolicyFactory routePolicyFactory); 603 604 /** 605 * Gets the route policy factories 606 * 607 * @return the list of current route policy factories 608 */ 609 List<RoutePolicyFactory> getRoutePolicyFactories(); 610 611 // Rest Methods 612 //----------------------------------------------------------------------- 613 614 /** 615 * Sets a custom {@link org.apache.camel.spi.RestConfiguration} 616 * 617 * @param restConfiguration the REST configuration 618 */ 619 void setRestConfiguration(RestConfiguration restConfiguration); 620 621 /** 622 * Gets the default REST configuration 623 * 624 * @return the configuration, or <tt>null</tt> if none has been configured. 625 */ 626 RestConfiguration getRestConfiguration(); 627 628 /** 629 * Sets a custom {@link org.apache.camel.spi.RestConfiguration} 630 * 631 * @param restConfiguration the REST configuration 632 */ 633 void addRestConfiguration(RestConfiguration restConfiguration); 634 635 /** 636 * Gets the REST configuration for the given component 637 * 638 * @param component the component name to get the configuration 639 * @param defaultIfNotFound determine if the default configuration is returned if there isn't a 640 * specific configuration for the given component 641 * @return the configuration, or <tt>null</tt> if none has been configured. 642 */ 643 RestConfiguration getRestConfiguration(String component, boolean defaultIfNotFound); 644 645 /** 646 * Gets all the RestConfiguration's 647 */ 648 Collection<RestConfiguration> getRestConfigurations(); 649 650 /** 651 * Gets the {@link org.apache.camel.spi.RestRegistry} to use 652 */ 653 RestRegistry getRestRegistry(); 654 655 /** 656 * Sets a custom {@link org.apache.camel.spi.RestRegistry} to use. 657 */ 658 void setRestRegistry(RestRegistry restRegistry); 659 660 // Properties 661 //----------------------------------------------------------------------- 662 663 /** 664 * Returns the type converter used to coerce types from one type to another 665 * 666 * @return the converter 667 */ 668 TypeConverter getTypeConverter(); 669 670 /** 671 * Returns the type converter registry where type converters can be added or looked up 672 * 673 * @return the type converter registry 674 */ 675 TypeConverterRegistry getTypeConverterRegistry(); 676 677 /** 678 * Configures the type converter registry to use, where type converters can be added or looked up. 679 * 680 * @param typeConverterRegistry the registry to use 681 */ 682 void setTypeConverterRegistry(TypeConverterRegistry typeConverterRegistry); 683 684 /** 685 * Returns the registry used to lookup components by name and type such as SimpleRegistry, Spring ApplicationContext, 686 * JNDI, or the OSGi Service Registry. 687 * 688 * @return the registry 689 */ 690 Registry getRegistry(); 691 692 /** 693 * Returns the registry used to lookup components by name and as the given type 694 * 695 * @param type the registry type such as org.apache.camel.impl.JndiRegistry 696 * @return the registry, or <tt>null</tt> if the given type was not found as a registry implementation 697 */ 698 <T> T getRegistry(Class<T> type); 699 700 /** 701 * Returns the injector used to instantiate objects by type 702 * 703 * @return the injector 704 */ 705 Injector getInjector(); 706 707 /** 708 * Sets the injector to use 709 */ 710 void setInjector(Injector injector); 711 712 /** 713 * Returns the lifecycle strategies used to handle lifecycle notifications 714 * 715 * @return the lifecycle strategies 716 */ 717 List<LifecycleStrategy> getLifecycleStrategies(); 718 719 /** 720 * Adds the given lifecycle strategy to be used. 721 * 722 * @param lifecycleStrategy the strategy 723 */ 724 void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy); 725 726 /** 727 * Resolves a language for creating expressions 728 * 729 * @param language name of the language 730 * @return the resolved language 731 * @throws NoSuchLanguageException is thrown if language could not be resolved 732 */ 733 Language resolveLanguage(String language) throws NoSuchLanguageException; 734 735 /** 736 * Parses the given text and resolve any property placeholders - using {{key}}. 737 * 738 * @param text the text such as an endpoint uri or the likes 739 * @return the text with resolved property placeholders 740 * @throws IllegalArgumentException is thrown if property placeholders was used and there was an error resolving them 741 */ 742 String resolvePropertyPlaceholders(String text); 743 744 /** 745 * Returns the configured properties component or create one if none has been configured. 746 * 747 * @return the properties component 748 */ 749 PropertiesComponent getPropertiesComponent(); 750 751 /** 752 * Sets a custom properties component to be used. 753 */ 754 void setPropertiesComponent(PropertiesComponent propertiesComponent); 755 756 /** 757 * Gets a readonly list with the names of the languages currently registered. 758 * 759 * @return a readonly list with the names of the languages 760 * @deprecated not in use 761 */ 762 @Deprecated 763 List<String> getLanguageNames(); 764 765 /** 766 * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away. 767 * <p/> 768 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 769 * Why does Camel use too many threads with ProducerTemplate?</a> 770 * <p/> 771 * <b>Important:</b> Make sure to call {@link org.apache.camel.ProducerTemplate#stop()} when you are done using the template, 772 * to clean up any resources. 773 * <p/> 774 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 775 * If no key was defined then it will fallback to a default size of 1000. 776 * You can also use the {@link org.apache.camel.ProducerTemplate#setMaximumCacheSize(int)} method to use a custom value 777 * before starting the template. 778 * 779 * @return the template 780 * @throws RuntimeCamelException is thrown if error starting the template 781 */ 782 ProducerTemplate createProducerTemplate(); 783 784 /** 785 * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away. 786 * <p/> 787 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 788 * Why does Camel use too many threads with ProducerTemplate?</a> 789 * <p/> 790 * <b>Important:</b> Make sure to call {@link ProducerTemplate#stop()} when you are done using the template, 791 * to clean up any resources. 792 * 793 * @param maximumCacheSize the maximum cache size 794 * @return the template 795 * @throws RuntimeCamelException is thrown if error starting the template 796 */ 797 ProducerTemplate createProducerTemplate(int maximumCacheSize); 798 799 /** 800 * Creates a new {@link FluentProducerTemplate} which is <b>started</b> and therefore ready to use right away. 801 * <p/> 802 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 803 * Why does Camel use too many threads with ProducerTemplate?</a> 804 * <p/> 805 * <b>Important:</b> Make sure to call {@link org.apache.camel.FluentProducerTemplate#stop()} when you are done using the template, 806 * to clean up any resources. 807 * <p/> 808 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 809 * If no key was defined then it will fallback to a default size of 1000. 810 * You can also use the {@link org.apache.camel.FluentProducerTemplate#setMaximumCacheSize(int)} method to use a custom value 811 * before starting the template. 812 * 813 * @return the template 814 * @throws RuntimeCamelException is thrown if error starting the template 815 */ 816 FluentProducerTemplate createFluentProducerTemplate(); 817 818 /** 819 * Creates a new {@link FluentProducerTemplate} which is <b>started</b> and therefore ready to use right away. 820 * <p/> 821 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 822 * Why does Camel use too many threads with ProducerTemplate?</a> 823 * <p/> 824 * <b>Important:</b> Make sure to call {@link FluentProducerTemplate#stop()} when you are done using the template, 825 * to clean up any resources. 826 * 827 * @param maximumCacheSize the maximum cache size 828 * @return the template 829 * @throws RuntimeCamelException is thrown if error starting the template 830 */ 831 FluentProducerTemplate createFluentProducerTemplate(int maximumCacheSize); 832 833 /** 834 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away. 835 * <p/> 836 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 837 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate. 838 * <p/> 839 * <b>Important:</b> Make sure to call {@link ConsumerTemplate#stop()} when you are done using the template, 840 * to clean up any resources. 841 * <p/> 842 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}. 843 * If no key was defined then it will fallback to a default size of 1000. 844 * You can also use the {@link org.apache.camel.ConsumerTemplate#setMaximumCacheSize(int)} method to use a custom value 845 * before starting the template. 846 * 847 * @return the template 848 * @throws RuntimeCamelException is thrown if error starting the template 849 */ 850 ConsumerTemplate createConsumerTemplate(); 851 852 /** 853 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away. 854 * <p/> 855 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html"> 856 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate. 857 * <p/> 858 * <b>Important:</b> Make sure to call {@link ConsumerTemplate#stop()} when you are done using the template, 859 * to clean up any resources. 860 * 861 * @param maximumCacheSize the maximum cache size 862 * @return the template 863 * @throws RuntimeCamelException is thrown if error starting the template 864 */ 865 ConsumerTemplate createConsumerTemplate(int maximumCacheSize); 866 867 /** 868 * Resolve a data format given its name 869 * 870 * @param name the data format name or a reference to it in the {@link Registry} 871 * @return the resolved data format, or <tt>null</tt> if not found 872 */ 873 DataFormat resolveDataFormat(String name); 874 875 /** 876 * Creates the given data format given its name. 877 * 878 * @param name the data format name or a reference to a data format factory in the {@link Registry} 879 * @return the resolved data format, or <tt>null</tt> if not found 880 */ 881 DataFormat createDataFormat(String name); 882 883 /** 884 * Resolve a transformer given a scheme 885 * 886 * @param model data model name. 887 * @return the resolved transformer, or <tt>null</tt> if not found 888 */ 889 Transformer resolveTransformer(String model); 890 891 /** 892 * Resolve a transformer given from/to data type. 893 * 894 * @param from from data type 895 * @param to to data type 896 * @return the resolved transformer, or <tt>null</tt> if not found 897 */ 898 Transformer resolveTransformer(DataType from, DataType to); 899 900 /** 901 * Gets the {@link org.apache.camel.spi.TransformerRegistry} 902 * @return the TransformerRegistry 903 */ 904 TransformerRegistry<? extends ValueHolder<String>> getTransformerRegistry(); 905 906 /** 907 * Resolve a validator given from/to data type. 908 * 909 * @param type the data type 910 * @return the resolved validator, or <tt>null</tt> if not found 911 */ 912 Validator resolveValidator(DataType type); 913 914 /** 915 * Gets the {@link org.apache.camel.spi.ValidatorRegistry} 916 * @return the ValidatorRegistry 917 */ 918 ValidatorRegistry<? extends ValueHolder<String>> getValidatorRegistry(); 919 920 /** 921 * Sets global options that can be referenced in the camel context 922 * <p/> 923 * <b>Important:</b> This has nothing to do with property placeholders, and is just a plain set of key/value pairs 924 * which are used to configure global options on CamelContext, such as a maximum debug logging length etc. 925 * For property placeholders use {@link #resolvePropertyPlaceholders(String)} method and see more details 926 * at the <a href="http://camel.apache.org/using-propertyplaceholder.html">property placeholder</a> documentation. 927 * 928 * @param globalOptions global options that can be referenced in the camel context 929 */ 930 void setGlobalOptions(Map<String, String> globalOptions); 931 932 /** 933 * Gets global options that can be referenced in the camel context. 934 * <p/> 935 * <b>Important:</b> This has nothing to do with property placeholders, and is just a plain set of key/value pairs 936 * which are used to configure global options on CamelContext, such as a maximum debug logging length etc. 937 * For property placeholders use {@link #resolvePropertyPlaceholders(String)} method and see more details 938 * at the <a href="http://camel.apache.org/using-propertyplaceholder.html">property placeholder</a> documentation. 939 * 940 * @return global options for this context 941 */ 942 Map<String, String> getGlobalOptions(); 943 944 /** 945 * Gets the global option value that can be referenced in the camel context 946 * <p/> 947 * <b>Important:</b> This has nothing to do with property placeholders, and is just a plain set of key/value pairs 948 * which are used to configure global options on CamelContext, such as a maximum debug logging length etc. 949 * For property placeholders use {@link #resolvePropertyPlaceholders(String)} method and see more details 950 * at the <a href="http://camel.apache.org/using-propertyplaceholder.html">property placeholder</a> documentation. 951 * 952 * @return the string value of the global option 953 */ 954 String getGlobalOption(String key); 955 956 /** 957 * Returns the class resolver to be used for loading/lookup of classes. 958 * 959 * @return the resolver 960 */ 961 ClassResolver getClassResolver(); 962 963 /** 964 * Sets the class resolver to be use 965 * 966 * @param resolver the resolver 967 */ 968 void setClassResolver(ClassResolver resolver); 969 970 /** 971 * Gets the management strategy 972 * 973 * @return the management strategy 974 */ 975 ManagementStrategy getManagementStrategy(); 976 977 /** 978 * Sets the management strategy to use 979 * 980 * @param strategy the management strategy 981 */ 982 void setManagementStrategy(ManagementStrategy strategy); 983 984 /** 985 * Disables using JMX as {@link org.apache.camel.spi.ManagementStrategy}. 986 * <p/> 987 * <b>Important:</b> This method must be called <b>before</b> the {@link CamelContext} is started. 988 * 989 * @throws IllegalStateException is thrown if the {@link CamelContext} is not in stopped state. 990 */ 991 void disableJMX() throws IllegalStateException; 992 993 /** 994 * Gets the inflight repository 995 * 996 * @return the repository 997 */ 998 InflightRepository getInflightRepository(); 999 1000 /** 1001 * Sets a custom inflight repository to use 1002 * 1003 * @param repository the repository 1004 */ 1005 void setInflightRepository(InflightRepository repository); 1006 1007 /** 1008 * Gets the application CamelContext class loader which may be helpful for running camel in other containers 1009 * 1010 * @return the application CamelContext class loader 1011 */ 1012 ClassLoader getApplicationContextClassLoader(); 1013 1014 /** 1015 * Sets the application CamelContext class loader 1016 * 1017 * @param classLoader the class loader 1018 */ 1019 void setApplicationContextClassLoader(ClassLoader classLoader); 1020 1021 /** 1022 * Gets the current shutdown strategy 1023 * 1024 * @return the strategy 1025 */ 1026 ShutdownStrategy getShutdownStrategy(); 1027 1028 /** 1029 * Sets a custom shutdown strategy 1030 * 1031 * @param shutdownStrategy the custom strategy 1032 */ 1033 void setShutdownStrategy(ShutdownStrategy shutdownStrategy); 1034 1035 /** 1036 * Gets the current {@link org.apache.camel.spi.ExecutorServiceManager} 1037 * 1038 * @return the manager 1039 */ 1040 ExecutorServiceManager getExecutorServiceManager(); 1041 1042 /** 1043 * Sets a custom {@link org.apache.camel.spi.ExecutorServiceManager} 1044 * 1045 * @param executorServiceManager the custom manager 1046 */ 1047 void setExecutorServiceManager(ExecutorServiceManager executorServiceManager); 1048 1049 /** 1050 * Gets the current {@link org.apache.camel.spi.MessageHistoryFactory} 1051 * 1052 * @return the factory 1053 */ 1054 MessageHistoryFactory getMessageHistoryFactory(); 1055 1056 /** 1057 * Sets a custom {@link org.apache.camel.spi.MessageHistoryFactory} 1058 * 1059 * @param messageHistoryFactory the custom factory 1060 */ 1061 void setMessageHistoryFactory(MessageHistoryFactory messageHistoryFactory); 1062 1063 /** 1064 * Gets the current {@link Debugger} 1065 * 1066 * @return the debugger 1067 */ 1068 Debugger getDebugger(); 1069 1070 /** 1071 * Sets a custom {@link Debugger} 1072 * 1073 * @param debugger the debugger 1074 */ 1075 void setDebugger(Debugger debugger); 1076 1077 /** 1078 * Gets the current {@link Tracer} 1079 * 1080 * @return the tracer 1081 */ 1082 Tracer getTracer(); 1083 1084 /** 1085 * Sets a custom {@link Tracer} 1086 */ 1087 void setTracer(Tracer tracer); 1088 1089 /** 1090 * Gets the current {@link UuidGenerator} 1091 * 1092 * @return the uuidGenerator 1093 */ 1094 UuidGenerator getUuidGenerator(); 1095 1096 /** 1097 * Sets a custom {@link UuidGenerator} (should only be set once) 1098 * 1099 * @param uuidGenerator the UUID Generator 1100 */ 1101 void setUuidGenerator(UuidGenerator uuidGenerator); 1102 1103 /** 1104 * Whether to load custom type converters by scanning classpath. 1105 * This is used for backwards compatibility with Camel 2.x. 1106 * Its recommended to migrate to use fast type converter loading 1107 * by setting <tt>@Converter(loader = true)</tt> on your custom 1108 * type converter classes. 1109 */ 1110 Boolean isLoadTypeConverters(); 1111 1112 /** 1113 * Whether to load custom type converters by scanning classpath. 1114 * This is used for backwards compatibility with Camel 2.x. 1115 * Its recommended to migrate to use fast type converter loading 1116 * by setting <tt>@Converter(loader = true)</tt> on your custom 1117 * type converter classes. 1118 * 1119 * @param loadTypeConverters whether to load custom type converters using classpath scanning. 1120 */ 1121 void setLoadTypeConverters(Boolean loadTypeConverters); 1122 1123 /** 1124 * Whether or not type converter statistics is enabled. 1125 * <p/> 1126 * By default the type converter utilization statistics is disabled. 1127 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 1128 * 1129 * @return <tt>true</tt> if enabled, <tt>false</tt> if disabled (default). 1130 */ 1131 Boolean isTypeConverterStatisticsEnabled(); 1132 1133 /** 1134 * Sets whether or not type converter statistics is enabled. 1135 * <p/> 1136 * By default the type converter utilization statistics is disabled. 1137 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 1138 * <p/> 1139 * You can enable/disable the statistics at runtime using the 1140 * {@link org.apache.camel.spi.TypeConverterRegistry#getStatistics()#setTypeConverterStatisticsEnabled(Boolean)} method, 1141 * or from JMX on the {@link org.apache.camel.api.management.mbean.ManagedTypeConverterRegistryMBean} mbean. 1142 * 1143 * @param typeConverterStatisticsEnabled <tt>true</tt> to enable, <tt>false</tt> to disable 1144 */ 1145 void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled); 1146 1147 /** 1148 * Whether or not <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> logging is being enabled. 1149 * 1150 * @return <tt>true</tt> if MDC logging is enabled 1151 */ 1152 Boolean isUseMDCLogging(); 1153 1154 /** 1155 * Set whether <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> is enabled. 1156 * 1157 * @param useMDCLogging <tt>true</tt> to enable MDC logging, <tt>false</tt> to disable 1158 */ 1159 void setUseMDCLogging(Boolean useMDCLogging); 1160 1161 /** 1162 * Gets the pattern used for determine which custom MDC keys to propagate during message routing when 1163 * the routing engine continues routing asynchronously for the given message. Setting this pattern to <tt>*</tt> will 1164 * propagate all custom keys. Or setting the pattern to <tt>foo*,bar*</tt> will propagate any keys starting with 1165 * either foo or bar. 1166 * Notice that a set of standard Camel MDC keys are always propagated which starts with <tt>camel.</tt> as key name. 1167 * <p/> 1168 * The match rules are applied in this order (case insensitive): 1169 * <ul> 1170 * <li>exact match, returns true</li> 1171 * <li>wildcard match (pattern ends with a * and the name starts with the pattern), returns true</li> 1172 * <li>regular expression match, returns true</li> 1173 * <li>otherwise returns false</li> 1174 * </ul> 1175 */ 1176 String getMDCLoggingKeysPattern(); 1177 1178 /** 1179 * Sets the pattern used for determine which custom MDC keys to propagate during message routing when 1180 * the routing engine continues routing asynchronously for the given message. Setting this pattern to <tt>*</tt> will 1181 * propagate all custom keys. Or setting the pattern to <tt>foo*,bar*</tt> will propagate any keys starting with 1182 * either foo or bar. 1183 * Notice that a set of standard Camel MDC keys are always propagated which starts with <tt>camel.</tt> as key name. 1184 * <p/> 1185 * The match rules are applied in this order (case insensitive): 1186 * <ul> 1187 * <li>exact match, returns true</li> 1188 * <li>wildcard match (pattern ends with a * and the name starts with the pattern), returns true</li> 1189 * <li>regular expression match, returns true</li> 1190 * <li>otherwise returns false</li> 1191 * </ul> 1192 * 1193 * @param pattern the pattern 1194 */ 1195 void setMDCLoggingKeysPattern(String pattern); 1196 1197 /** 1198 * Whether to enable using data type on Camel messages. 1199 * <p/> 1200 * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. 1201 * Otherwise data type is default off. 1202 * 1203 * @return <tt>true</tt> if data type is enabled 1204 */ 1205 Boolean isUseDataType(); 1206 1207 /** 1208 * Whether to enable using data type on Camel messages. 1209 * <p/> 1210 * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. 1211 * Otherwise data type is default off. 1212 * 1213 * @param useDataType <tt>true</tt> to enable data type on Camel messages. 1214 */ 1215 void setUseDataType(Boolean useDataType); 1216 1217 /** 1218 * Whether or not breadcrumb is enabled. 1219 * 1220 * @return <tt>true</tt> if breadcrumb is enabled 1221 */ 1222 Boolean isUseBreadcrumb(); 1223 1224 /** 1225 * Set whether breadcrumb is enabled. 1226 * 1227 * @param useBreadcrumb <tt>true</tt> to enable breadcrumb, <tt>false</tt> to disable 1228 */ 1229 void setUseBreadcrumb(Boolean useBreadcrumb); 1230 1231 /** 1232 * Gets the {@link StreamCachingStrategy} to use. 1233 */ 1234 StreamCachingStrategy getStreamCachingStrategy(); 1235 1236 /** 1237 * Sets a custom {@link StreamCachingStrategy} to use. 1238 */ 1239 void setStreamCachingStrategy(StreamCachingStrategy streamCachingStrategy); 1240 1241 /** 1242 * Gets the {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use, or <tt>null</tt> if none is in use. 1243 */ 1244 RuntimeEndpointRegistry getRuntimeEndpointRegistry(); 1245 1246 /** 1247 * Sets a custom {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use. 1248 */ 1249 void setRuntimeEndpointRegistry(RuntimeEndpointRegistry runtimeEndpointRegistry); 1250 1251 /** 1252 * Sets the global SSL context parameters. 1253 */ 1254 void setSSLContextParameters(SSLContextParameters sslContextParameters); 1255 1256 /** 1257 * Gets the global SSL context parameters if configured. 1258 */ 1259 SSLContextParameters getSSLContextParameters(); 1260 1261 /** 1262 * Gets the {@link HeadersMapFactory} to use. 1263 */ 1264 HeadersMapFactory getHeadersMapFactory(); 1265 1266 /** 1267 * Sets a custom {@link HeadersMapFactory} to be used. 1268 */ 1269 void setHeadersMapFactory(HeadersMapFactory factory); 1270 1271 ReactiveExecutor getReactiveExecutor(); 1272 1273 /** 1274 * Sets a custom {@link ReactiveExecutor} to be used. 1275 */ 1276 void setReactiveExecutor(ReactiveExecutor reactiveExecutor); 1277 1278}