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     */
017    package org.apache.camel;
018    
019    import java.io.InputStream;
020    import java.util.Collection;
021    import java.util.List;
022    import java.util.Map;
023    import java.util.concurrent.TimeUnit;
024    
025    import org.apache.camel.builder.ErrorHandlerBuilder;
026    import org.apache.camel.model.DataFormatDefinition;
027    import org.apache.camel.model.RouteDefinition;
028    import org.apache.camel.model.RoutesDefinition;
029    import org.apache.camel.spi.CamelContextNameStrategy;
030    import org.apache.camel.spi.ClassResolver;
031    import org.apache.camel.spi.DataFormat;
032    import org.apache.camel.spi.DataFormatResolver;
033    import org.apache.camel.spi.Debugger;
034    import org.apache.camel.spi.EndpointStrategy;
035    import org.apache.camel.spi.ExecutorServiceStrategy;
036    import org.apache.camel.spi.FactoryFinder;
037    import org.apache.camel.spi.FactoryFinderResolver;
038    import org.apache.camel.spi.InflightRepository;
039    import org.apache.camel.spi.Injector;
040    import org.apache.camel.spi.InterceptStrategy;
041    import org.apache.camel.spi.Language;
042    import org.apache.camel.spi.LifecycleStrategy;
043    import org.apache.camel.spi.ManagementStrategy;
044    import org.apache.camel.spi.NodeIdFactory;
045    import org.apache.camel.spi.PackageScanClassResolver;
046    import org.apache.camel.spi.ProcessorFactory;
047    import org.apache.camel.spi.Registry;
048    import org.apache.camel.spi.ServicePool;
049    import org.apache.camel.spi.ShutdownStrategy;
050    import org.apache.camel.spi.TypeConverterRegistry;
051    import org.apache.camel.spi.UuidGenerator;
052    
053    /**
054     * Interface used to represent the context used to configure routes and the
055     * policies to use during message exchanges between endpoints.
056     * <p/>
057     * The context offers the following methods to control the lifecycle:
058     * <ul>
059     *   <li>{@link #start()}  - to start</li>
060     *   <li>{@link #stop()} - to shutdown (will stop all routes/components/endpoints etc and clear internal state/cache)</li>
061     *   <li>{@link #suspend()} - to pause routing messages</li>
062     *   <li>{@link #resume()} - to resume after a suspend</li>
063     * </ul>
064     * <p/>
065     * <b>Notice:</b> that {@link #stop()} and {@link #suspend()} will graceful stop/suspend routs ensuring any in progress
066     * messages is given time to complete. See more details at {@link org.apache.camel.spi.ShutdownStrategy}.
067     * <p/>
068     * If you are doing a hot restart then its adviced to use the suspend/resume methods which ensures a faster
069     * restart but also allows any internal state to be kept as is.
070     * The stop/start approach will do a <i>cold</i> restart of Camel, where all internal state is reset.
071     * <p/>
072     * End users is adviced to use suspend/resume. Using stop is for shutting down Camel and its not guaranteed that
073     * when its being started again using the start method that everything works out of the box.
074     *
075     * @version 
076     */
077    public interface CamelContext extends SuspendableService, RuntimeConfiguration {
078    
079        /**
080         * Gets the name (id) of the this context.
081         *
082         * @return the name
083         */
084        String getName();
085    
086        /**
087         * Gets the current name strategy
088         *
089         * @return name strategy
090         */
091        CamelContextNameStrategy getNameStrategy();
092    
093        /**
094         * Sets a custom name strategy
095         *
096         * @param nameStrategy name strategy
097         */
098        void setNameStrategy(CamelContextNameStrategy nameStrategy);
099    
100        /**
101         * Gets the name this {@link CamelContext} was registered in JMX.
102         * <p/>
103         * The reason that a {@link CamelContext} can have a different name in JMX is the fact to remedy for name clash
104         * in JMX when having multiple {@link CamelContext}s in the same JVM. Camel will automatic reassign and use
105         * a free name to avoid failing to start.
106         *
107         * @return the management name
108         */
109        String getManagementName();
110    
111        /**
112         * Sets the name this {@link CamelContext} was registered in JMX.
113         *
114         * @param name  the actual name used when registering this {@link CamelContext} in JMX
115         */
116        void setManagementName(String name);
117    
118        /**
119         * Gets the version of the this context.
120         *
121         * @return the version
122         */
123        String getVersion();
124    
125        /**
126         * Get the status of this context
127         *
128         * @return the status
129         */
130        ServiceStatus getStatus();
131    
132        /**
133         * Gets the uptime in a human readable format
134         *
135         * @return the uptime in days/hours/minutes
136         */
137        String getUptime();
138    
139        // Service Methods
140        //-----------------------------------------------------------------------
141    
142        /**
143         * Adds a service, starting it so that it will be stopped with this context
144         * <p/>
145         * The added service will also be enlisted in JMX for management (if JMX is enabled)
146         *
147         * @param object the service
148         * @throws Exception can be thrown when starting the service
149         */
150        void addService(Object object) throws Exception;
151    
152        /**
153         * Has the given service already been added?
154         *
155         * @param object the service
156         * @return <tt>true</tt> if already added, <tt>false</tt> if not.
157         */
158        boolean hasService(Object object);
159    
160        /**
161         * Adds the given listener to be invoked when {@link CamelContext} have just been started.
162         * <p/>
163         * This allows listeners to do any custom work after the routes and other services have been started and are running.
164         * <p/><b>Important:</b> The listener will always be invoked, also if the {@link CamelContext} has already been
165         * started, see the {@link org.apache.camel.StartupListener#onCamelContextStarted(CamelContext, boolean)} method.
166         *
167         * @param listener the listener
168         * @throws Exception can be thrown if {@link CamelContext} is already started and the listener is invoked
169         *                   and cause an exception to be thrown
170         */
171        void addStartupListener(StartupListener listener) throws Exception;
172    
173        // Component Management Methods
174        //-----------------------------------------------------------------------
175    
176        /**
177         * Adds a component to the context.
178         *
179         * @param componentName the name the component is registered as
180         * @param component     the component
181         */
182        void addComponent(String componentName, Component component);
183    
184        /**
185         * Is the given component already registered?
186         *
187         * @param componentName the name of the component
188         * @return the registered Component or <tt>null</tt> if not registered
189         */
190        Component hasComponent(String componentName);
191    
192        /**
193         * Gets a component from the context by name.
194         *
195         * @param componentName the name of the component
196         * @return the component
197         */
198        Component getComponent(String componentName);
199    
200        /**
201         * Gets a component from the context by name and specifying the expected type of component.
202         *
203         * @param name          the name to lookup
204         * @param componentType the expected type
205         * @return the component
206         */
207        <T extends Component> T getComponent(String name, Class<T> componentType);
208    
209        /**
210         * Gets a readonly list of names of the components currently registered
211         *
212         * @return a readonly list with the names of the the components
213         */
214        List<String> getComponentNames();
215    
216        /**
217         * Removes a previously added component.
218         *
219         * @param componentName the component name to remove
220         * @return the previously added component or null if it had not been previously added.
221         */
222        Component removeComponent(String componentName);
223    
224        // Endpoint Management Methods
225        //-----------------------------------------------------------------------
226    
227        /**
228         * Resolves the given name to an {@link Endpoint} of the specified type.
229         * If the name has a singleton endpoint registered, then the singleton is returned.
230         * Otherwise, a new {@link Endpoint} is created and registered.
231         *
232         * @param uri the URI of the endpoint
233         * @return the endpoint
234         */
235        Endpoint getEndpoint(String uri);
236    
237        /**
238         * Resolves the given name to an {@link Endpoint} of the specified type.
239         * If the name has a singleton endpoint registered, then the singleton is returned.
240         * Otherwise, a new {@link Endpoint} is created and registered.
241         *
242         * @param name         the name of the endpoint
243         * @param endpointType the expected type
244         * @return the endpoint
245         */
246        <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType);
247    
248        /**
249         * Returns the collection of all registered endpoints.
250         *
251         * @return all endpoints
252         */
253        Collection<Endpoint> getEndpoints();
254    
255        /**
256         * Returns a new Map containing all of the active endpoints with the key of the map being their
257         * unique key.
258         *
259         * @return map of active endpoints
260         */
261        Map<String, Endpoint> getEndpointMap();
262    
263        /**
264         * Is the given endpoint already registered?
265         *
266         * @param uri the URI of the endpoint
267         * @return the registered endpoint or <tt>null</tt> if not registered
268         */
269        Endpoint hasEndpoint(String uri);
270    
271        /**
272         * Adds the endpoint to the context using the given URI.
273         *
274         * @param uri      the URI to be used to resolve this endpoint
275         * @param endpoint the endpoint to be added to the context
276         * @return the old endpoint that was previously registered or <tt>null</tt> if none was registered
277         * @throws Exception if the new endpoint could not be started or the old endpoint could not be stopped
278         */
279        Endpoint addEndpoint(String uri, Endpoint endpoint) throws Exception;
280    
281        /**
282         * Removes all endpoints with the given URI.
283         *
284         * @param pattern an uri or pattern to match
285         * @return a collection of endpoints removed or null if there are no endpoints for this URI
286         * @throws Exception if at least one endpoint could not be stopped
287         * @see org.apache.camel.util.EndpointHelper#matchEndpoint(String, String) for pattern
288         */
289        Collection<Endpoint> removeEndpoints(String pattern) throws Exception;
290    
291        /**
292         * Registers a {@link org.apache.camel.spi.EndpointStrategy callback} to allow you to do custom
293         * logic when an {@link Endpoint} is about to be registered to the {@link CamelContext} endpoint registry.
294         * <p/>
295         * When a callback is added it will be executed on the already registered endpoints allowing you to catch-up
296         *
297         * @param strategy callback to be invoked
298         */
299        void addRegisterEndpointCallback(EndpointStrategy strategy);
300    
301        // Route Management Methods
302        //-----------------------------------------------------------------------
303    
304        /**
305         * Returns a list of the current route definitions
306         *
307         * @return list of the current route definitions
308         */
309        List<RouteDefinition> getRouteDefinitions();
310    
311        /**
312         * Gets the route definition with the given id
313         *
314         * @param id id of the route
315         * @return the route definition or <tt>null</tt> if not found
316         */
317        RouteDefinition getRouteDefinition(String id);
318    
319        /**
320         * Returns the current routes in this context
321         *
322         * @return the current routes
323         */
324        List<Route> getRoutes();
325    
326        /**
327         * Gets the route with the given id
328         *
329         * @param id id of the route
330         * @return the route or <tt>null</tt> if not found
331         */
332        Route getRoute(String id);
333    
334        /**
335         * Adds a collection of routes to this context using the given builder
336         * to build them
337         *
338         * @param builder the builder which will create the routes and add them to this context
339         * @throws Exception if the routes could not be created for whatever reason
340         */
341        void addRoutes(RoutesBuilder builder) throws Exception;
342    
343        /**
344         * Loads a collection of route definitions from the given {@link java.io.InputStream}.
345         *
346         * @param is input stream with the route(s) definition to add
347         * @throws Exception if the route definitions could not be loaded for whatever reason
348         * @return the route definitions
349         */
350        RoutesDefinition loadRoutesDefinition(InputStream is) throws Exception;
351    
352        /**
353         * Adds a collection of route definitions to the context
354         *
355         * @param routeDefinitions the route(s) definition to add
356         * @throws Exception if the route definitions could not be created for whatever reason
357         */
358        void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception;
359    
360        /**
361         * Add a route definition to the context
362         *
363         * @param routeDefinition the route definition to add
364         * @throws Exception if the route definition could not be created for whatever reason
365         */
366        void addRouteDefinition(RouteDefinition routeDefinition) throws Exception;
367    
368        /**
369         * Removes a collection of route definitions from the context - stopping any previously running
370         * routes if any of them are actively running
371         *
372         * @param routeDefinitions route(s) definitions to remove
373         * @throws Exception if the route definitions could not be removed for whatever reason
374         */
375        void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception;
376    
377        /**
378         * Removes a route definition from the context - stopping any previously running
379         * routes if any of them are actively running
380         *
381         * @param routeDefinition route definition to remove
382         * @throws Exception if the route definition could not be removed for whatever reason
383         */
384        void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception;
385    
386        /**
387         * Starts the given route if it has been previously stopped
388         *
389         * @param route the route to start
390         * @throws Exception is thrown if the route could not be started for whatever reason
391         */
392        void startRoute(RouteDefinition route) throws Exception;
393    
394        /**
395         * Starts the given route if it has been previously stopped
396         *
397         * @param routeId the route id
398         * @throws Exception is thrown if the route could not be started for whatever reason
399         */
400        void startRoute(String routeId) throws Exception;
401    
402        /**
403         * Stops the given route.
404         *
405         * @param route the route to stop
406         * @throws Exception is thrown if the route could not be stopped for whatever reason
407         */
408        void stopRoute(RouteDefinition route) throws Exception;
409    
410        /**
411         * Stops the given route using {@link org.apache.camel.spi.ShutdownStrategy}.
412         *
413         * @param routeId the route id
414         * @throws Exception is thrown if the route could not be stopped for whatever reason
415         * @see #suspendRoute(String)
416         */
417        void stopRoute(String routeId) throws Exception;
418    
419        /**
420         * Stops the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout.
421         *
422         * @param routeId the route id
423         * @param timeout  timeout
424         * @param timeUnit the unit to use
425         * @throws Exception is thrown if the route could not be stopped for whatever reason
426         * @see #suspendRoute(String, long, java.util.concurrent.TimeUnit)
427         */
428        void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception;
429    
430        /**
431         * Stops the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout 
432         * and optional abortAfterTimeout mode.
433         *
434         * @param routeId the route id
435         * @param timeout  timeout
436         * @param timeUnit the unit to use
437         * @param abortAfterTimeout should abort shutdown after timeout
438         * @return <tt>true</tt> if the route is stopped before the timeout
439         * @throws Exception is thrown if the route could not be stopped for whatever reason
440         * @see #suspendRoute(String, long, java.util.concurrent.TimeUnit)
441         */
442        boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception;
443        
444        /**
445         * Shutdown and <b>removes</b> the given route using {@link org.apache.camel.spi.ShutdownStrategy}.
446         *
447         * @param routeId the route id
448         * @throws Exception is thrown if the route could not be shutdown for whatever reason
449         * @deprecated use {@link #stopRoute(String)} and {@link #removeRoute(String)}
450         */
451        @Deprecated
452        void shutdownRoute(String routeId) throws Exception;
453    
454        /**
455         * Shutdown and <b>removes</b> the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout.
456         *
457         * @param routeId  the route id
458         * @param timeout  timeout
459         * @param timeUnit the unit to use
460         * @throws Exception is thrown if the route could not be shutdown for whatever reason
461         * @deprecated use {@link #stopRoute(String, long, java.util.concurrent.TimeUnit)} and {@link #removeRoute(String)}
462         */
463        @Deprecated
464        void shutdownRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception;
465    
466        /**
467         * Removes the given route (the route <b>must</b> be stopped before it can be removed).
468         * <p/>
469         * <br/>A route which is removed will be unregistered from JMX, have its services stopped/shutdown and the route
470         * definition etc. will also be removed. All the resources related to the route will be stopped and cleared.
471         * <p/>
472         * <br/>End users can use this method to remove unwanted routes or temporary routes which no longer is in demand.
473         *
474         * @param routeId the route id
475         * @return <tt>true</tt> if the route was removed, <tt>false</tt> if the route could not be removed because its not stopped
476         * @throws Exception is thrown if the route could not be shutdown for whatever reason
477         */
478        boolean removeRoute(String routeId) throws Exception;
479    
480        /**
481         * Resumes the given route if it has been previously suspended
482         * <p/>
483         * If the route does <b>not</b> support suspension the route will be started instead
484         *
485         * @param routeId the route id
486         * @throws Exception is thrown if the route could not be resumed for whatever reason
487         */
488        void resumeRoute(String routeId) throws Exception;
489    
490        /**
491         * Suspends the given route using {@link org.apache.camel.spi.ShutdownStrategy}.
492         * <p/>
493         * Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support)
494         * otherwise the consumers will be stopped.
495         * <p/>
496         * By suspending the route services will be kept running (if possible) and therefore its faster to resume the route.
497         * <p/>
498         * If the route does <b>not</b> support suspension the route will be stopped instead
499         *
500         * @param routeId the route id
501         * @throws Exception is thrown if the route could not be suspended for whatever reason
502         */
503        void suspendRoute(String routeId) throws Exception;
504    
505        /**
506         * Suspends the given route using {@link org.apache.camel.spi.ShutdownStrategy} with a specified timeout.
507         * <p/>
508         * Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support)
509         * otherwise the consumers will be stopped.
510         * <p/>
511         * By suspending the route services will be kept running (if possible) and therefore its faster to resume the route.
512         * <p/>
513         * If the route does <b>not</b> support suspension the route will be stopped instead
514         *
515         * @param routeId  the route id
516         * @param timeout  timeout
517         * @param timeUnit the unit to use
518         * @throws Exception is thrown if the route could not be suspended for whatever reason
519         */
520        void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception;
521    
522        /**
523         * Returns the current status of the given route
524         *
525         * @param routeId the route id
526         * @return the status for the route
527         */
528        ServiceStatus getRouteStatus(String routeId);
529    
530        /**
531         * Indicates whether current thread is starting route(s).
532         * <p/>
533         * This can be useful to know by {@link LifecycleStrategy} or the likes, in case
534         * they need to react differently.
535         *
536         * @return <tt>true</tt> if current thread is starting route(s), or <tt>false</tt> if not.
537         */
538        boolean isStartingRoutes();
539    
540        // Properties
541        //-----------------------------------------------------------------------
542    
543        /**
544         * Returns the type converter used to coerce types from one type to another
545         *
546         * @return the converter
547         */
548        TypeConverter getTypeConverter();
549    
550        /**
551         * Returns the type converter registry where type converters can be added or looked up
552         *
553         * @return the type converter registry
554         */
555        TypeConverterRegistry getTypeConverterRegistry();
556    
557        /**
558         * Returns the registry used to lookup components by name and type such as the Spring ApplicationContext,
559         * JNDI or the OSGi Service Registry
560         *
561         * @return the registry
562         */
563        Registry getRegistry();
564    
565        /**
566         * Returns the injector used to instantiate objects by type
567         *
568         * @return the injector
569         */
570        Injector getInjector();
571    
572        /**
573         * Returns the lifecycle strategies used to handle lifecycle notifications
574         *
575         * @return the lifecycle strategies
576         */
577        List<LifecycleStrategy> getLifecycleStrategies();
578    
579        /**
580         * Adds the given lifecycle strategy to be used.
581         *
582         * @param lifecycleStrategy the strategy
583         */
584        void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy);
585    
586        /**
587         * Resolves a language for creating expressions
588         *
589         * @param language name of the language
590         * @return the resolved language
591         */
592        Language resolveLanguage(String language);
593    
594        /**
595         * Parses the given text and resolve any property placeholders - using {{key}}.
596         *
597         * @param text the text such as an endpoint uri or the likes
598         * @return the text with resolved property placeholders
599         * @throws Exception is thrown if property placeholders was used and there was an error resolving them
600         */
601        String resolvePropertyPlaceholders(String text) throws Exception;
602    
603        /**
604         * Gets a readonly list with the names of the languages currently registered.
605         *
606         * @return a readonly list with the names of the the languages
607         */
608        List<String> getLanguageNames();
609    
610        /**
611         * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away.
612         * <p/>
613         * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
614         * Why does Camel use too many threads with ProducerTemplate?</a>
615         * <p/>
616         * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}.
617         * If no key was defined then it will fallback to a default size of 1000.
618         * You can also use the {@link org.apache.camel.ProducerTemplate#setMaximumCacheSize(int)} method to use a custom value
619         * before starting the template.
620         *
621         * @return the template
622         * @throws RuntimeCamelException is thrown if error starting the template
623         */
624        ProducerTemplate createProducerTemplate();
625    
626        /**
627         * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away.
628         * <p/>
629         * You <b>must</b> start the template before its being used.
630         * <p/>
631         * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
632         * Why does Camel use too many threads with ProducerTemplate?</a>
633         *
634         * @param maximumCacheSize the maximum cache size
635         * @return the template
636         * @throws RuntimeCamelException is thrown if error starting the template
637         */
638        ProducerTemplate createProducerTemplate(int maximumCacheSize);
639    
640        /**
641         * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away.
642         * <p/>
643         * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
644         * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate.
645         * <p/>
646         * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}.
647         * If no key was defined then it will fallback to a default size of 1000.
648         * You can also use the {@link org.apache.camel.ConsumerTemplate#setMaximumCacheSize(int)} method to use a custom value
649         * before starting the template.
650         *
651         * @return the template
652         * @throws RuntimeCamelException is thrown if error starting the template
653         */
654        ConsumerTemplate createConsumerTemplate();
655    
656        /**
657         * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away.
658         * <p/>
659         * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
660         * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate.
661         *
662         * @param maximumCacheSize the maximum cache size
663         * @return the template
664         * @throws RuntimeCamelException is thrown if error starting the template
665         */
666        ConsumerTemplate createConsumerTemplate(int maximumCacheSize);
667    
668        /**
669         * Adds the given interceptor strategy
670         *
671         * @param interceptStrategy the strategy
672         */
673        void addInterceptStrategy(InterceptStrategy interceptStrategy);
674    
675        /**
676         * Gets the interceptor strategies
677         *
678         * @return the list of current interceptor strategies
679         */
680        List<InterceptStrategy> getInterceptStrategies();
681    
682        /**
683         * Gets the default error handler builder which is inherited by the routes
684         *
685         * @return the builder
686         */
687        ErrorHandlerBuilder getErrorHandlerBuilder();
688    
689        /**
690         * Sets the default error handler builder which is inherited by the routes
691         *
692         * @param errorHandlerBuilder the builder
693         */
694        void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder);
695    
696        /**
697         * Sets the data formats that can be referenced in the routes.
698         *
699         * @param dataFormats the data formats
700         */
701        void setDataFormats(Map<String, DataFormatDefinition> dataFormats);
702    
703        /**
704         * Gets the data formats that can be referenced in the routes.
705         *
706         * @return the data formats available
707         */
708        Map<String, DataFormatDefinition> getDataFormats();
709    
710        /**
711         * Resolve a data format given its name
712         *
713         * @param name the data format name or a reference to it in the {@link Registry}
714         * @return the resolved data format, or <tt>null</tt> if not found
715         */
716        DataFormat resolveDataFormat(String name);
717    
718        /**
719         * Resolve a data format definition given its name
720         *
721         * @param name the data format definition name or a reference to it in the {@link Registry}
722         * @return the resolved data format definition, or <tt>null</tt> if not found
723         */
724        DataFormatDefinition resolveDataFormatDefinition(String name);
725    
726        /**
727         * Gets the current data format resolver
728         *
729         * @return the resolver
730         */
731        DataFormatResolver getDataFormatResolver();
732    
733        /**
734         * Sets a custom data format resolver
735         *
736         * @param dataFormatResolver the resolver
737         */
738        void setDataFormatResolver(DataFormatResolver dataFormatResolver);
739    
740        /**
741         * Sets the properties that can be referenced in the camel context
742         *
743         * @param properties properties
744         */
745        void setProperties(Map<String, String> properties);
746    
747        /**
748         * Gets the properties that can be referenced in the camel context
749         *
750         * @return the properties
751         */
752        Map<String, String> getProperties();
753    
754        /**
755         * Gets the default FactoryFinder which will be used for the loading the factory class from META-INF
756         *
757         * @return the default factory finder
758         */
759        FactoryFinder getDefaultFactoryFinder();
760    
761        /**
762         * Sets the factory finder resolver to use.
763         *
764         * @param resolver the factory finder resolver
765         */
766        void setFactoryFinderResolver(FactoryFinderResolver resolver);
767    
768        /**
769         * Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path
770         *
771         * @param path the META-INF path
772         * @return the factory finder
773         * @throws NoFactoryAvailableException is thrown if a factory could not be found
774         */
775        FactoryFinder getFactoryFinder(String path) throws NoFactoryAvailableException;
776    
777        /**
778         * Returns the class resolver to be used for loading/lookup of classes.
779         *
780         * @return the resolver
781         */
782        ClassResolver getClassResolver();
783    
784        /**
785         * Returns the package scanning class resolver
786         *
787         * @return the resolver
788         */
789        PackageScanClassResolver getPackageScanClassResolver();
790    
791        /**
792         * Sets the class resolver to be use
793         *
794         * @param resolver the resolver
795         */
796        void setClassResolver(ClassResolver resolver);
797    
798        /**
799         * Sets the package scanning class resolver to use
800         *
801         * @param resolver the resolver
802         */
803        void setPackageScanClassResolver(PackageScanClassResolver resolver);
804    
805        /**
806         * Sets a pluggable service pool to use for {@link Producer} pooling.
807         *
808         * @param servicePool the pool
809         */
810        void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool);
811    
812        /**
813         * Gets the service pool for {@link Producer} pooling.
814         *
815         * @return the service pool
816         */
817        ServicePool<Endpoint, Producer> getProducerServicePool();
818    
819        /**
820         * Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions
821         *
822         * @param factory custom factory to use
823         */
824        void setNodeIdFactory(NodeIdFactory factory);
825    
826        /**
827         * Gets the node id factory
828         *
829         * @return the node id factory
830         */
831        NodeIdFactory getNodeIdFactory();
832    
833        /**
834         * Gets the management strategy
835         *
836         * @return the management strategy
837         */
838        ManagementStrategy getManagementStrategy();
839    
840        /**
841         * Sets the management strategy to use
842         *
843         * @param strategy the management strategy
844         */
845        void setManagementStrategy(ManagementStrategy strategy);
846    
847        /**
848         * Gets the default tracer
849         *
850         * @return the default tracer
851         */
852        InterceptStrategy getDefaultTracer();
853    
854        /**
855         * Sets a custom tracer to be used as the default tracer.
856         * <p/>
857         * <b>Note:</b> This must be set before any routes are created,
858         * changing the defaultTracer for existing routes is not supported.
859         *
860         * @param tracer the custom tracer to use as default tracer
861         */
862        void setDefaultTracer(InterceptStrategy tracer);
863    
864        /**
865         * Disables using JMX as {@link org.apache.camel.spi.ManagementStrategy}.
866         */
867        void disableJMX();
868    
869        /**
870         * Gets the inflight repository
871         *
872         * @return the repository
873         */
874        InflightRepository getInflightRepository();
875    
876        /**
877         * Sets a custom inflight repository to use
878         *
879         * @param repository the repository
880         */
881        void setInflightRepository(InflightRepository repository);
882    
883        /**
884         * Gets the the application context class loader which may be helpful for running camel in other containers
885         *
886         * @return the application context class loader
887         */
888        ClassLoader getApplicationContextClassLoader();
889    
890        /**
891         * Sets the application context class loader
892         *
893         * @param classLoader the class loader
894         */
895        void setApplicationContextClassLoader(ClassLoader classLoader);
896    
897        /**
898         * Gets the current shutdown strategy
899         *
900         * @return the strategy
901         */
902        ShutdownStrategy getShutdownStrategy();
903    
904        /**
905         * Sets a custom shutdown strategy
906         *
907         * @param shutdownStrategy the custom strategy
908         */
909        void setShutdownStrategy(ShutdownStrategy shutdownStrategy);
910    
911        /**
912         * Gets the current {@link org.apache.camel.spi.ExecutorServiceStrategy}
913         *
914         * @return the strategy
915         */
916        ExecutorServiceStrategy getExecutorServiceStrategy();
917    
918        /**
919         * Sets a custom {@link org.apache.camel.spi.ExecutorServiceStrategy}
920         *
921         * @param executorServiceStrategy the custom strategy
922         */
923        void setExecutorServiceStrategy(ExecutorServiceStrategy executorServiceStrategy);
924    
925        /**
926         * Gets the current {@link org.apache.camel.spi.ProcessorFactory}
927         *
928         * @return the factory, can be <tt>null</tt> if no custom factory has been set
929         */
930        ProcessorFactory getProcessorFactory();
931    
932        /**
933         * Sets a custom {@link org.apache.camel.spi.ProcessorFactory}
934         *
935         * @param processorFactory the custom factory
936         */
937        void setProcessorFactory(ProcessorFactory processorFactory);
938    
939        /**
940         * Gets the current {@link Debugger}
941         *
942         * @return the debugger
943         */
944        Debugger getDebugger();
945    
946        /**
947         * Sets a custom {@link Debugger}
948         *
949         * @param debugger the debugger
950         */
951        void setDebugger(Debugger debugger);
952    
953        /**
954         * Gets the current {@link UuidGenerator}
955         *
956         * @return the uuidGenerator
957         */
958        UuidGenerator getUuidGenerator();
959        
960        /**
961         * Sets a custom {@link UuidGenerator} (should only be set once) 
962         *
963         * @param uuidGenerator the UUID Generator
964         */
965        void setUuidGenerator(UuidGenerator uuidGenerator);
966    
967        /**
968         * Whether or not type converters should be loaded lazy
969         *
970         * @return <tt>true</tt> to load lazy, <tt>false</tt> to load on startup
971         */
972        Boolean isLazyLoadTypeConverters();
973    
974        /**
975         * Sets whether type converters should be loaded lazy
976         *
977         * @param lazyLoadTypeConverters <tt>true</tt> to load lazy, <tt>false</tt> to load on startup
978         */
979        void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters);
980    
981        /**
982         * Whether or not <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> logging is being enabled.
983         *
984         * @return <tt>true</tt> if MDC logging is enabled
985         */
986        Boolean isUseMDCLogging();
987    
988        /**
989         * Set whether <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> is enabled.
990         *
991         * @param useMDCLogging <tt>true</tt> to enable MDC logging, <tt>false</tt> to disable
992         */
993        void setUseMDCLogging(Boolean useMDCLogging);
994    
995    }