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