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