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