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