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