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 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
633 * Why does Camel use too many threads with ProducerTemplate?</a>
634 *
635 * @param maximumCacheSize the maximum cache size
636 * @return the template
637 * @throws RuntimeCamelException is thrown if error starting the template
638 */
639 ProducerTemplate createProducerTemplate(int maximumCacheSize);
640
641 /**
642 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away.
643 * <p/>
644 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
645 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate.
646 * <p/>
647 * Will use cache size defined in Camel property with key {@link Exchange#MAXIMUM_CACHE_POOL_SIZE}.
648 * If no key was defined then it will fallback to a default size of 1000.
649 * You can also use the {@link org.apache.camel.ConsumerTemplate#setMaximumCacheSize(int)} method to use a custom value
650 * before starting the template.
651 *
652 * @return the template
653 * @throws RuntimeCamelException is thrown if error starting the template
654 */
655 ConsumerTemplate createConsumerTemplate();
656
657 /**
658 * Creates a new {@link ConsumerTemplate} which is <b>started</b> and therefore ready to use right away.
659 * <p/>
660 * See this FAQ before use: <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">
661 * Why does Camel use too many threads with ProducerTemplate?</a> as it also applies for ConsumerTemplate.
662 *
663 * @param maximumCacheSize the maximum cache size
664 * @return the template
665 * @throws RuntimeCamelException is thrown if error starting the template
666 */
667 ConsumerTemplate createConsumerTemplate(int maximumCacheSize);
668
669 /**
670 * Adds the given interceptor strategy
671 *
672 * @param interceptStrategy the strategy
673 */
674 void addInterceptStrategy(InterceptStrategy interceptStrategy);
675
676 /**
677 * Gets the interceptor strategies
678 *
679 * @return the list of current interceptor strategies
680 */
681 List<InterceptStrategy> getInterceptStrategies();
682
683 /**
684 * Gets the default error handler builder which is inherited by the routes
685 *
686 * @return the builder
687 */
688 ErrorHandlerBuilder getErrorHandlerBuilder();
689
690 /**
691 * Sets the default error handler builder which is inherited by the routes
692 *
693 * @param errorHandlerBuilder the builder
694 */
695 void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder);
696
697 /**
698 * Sets the data formats that can be referenced in the routes.
699 *
700 * @param dataFormats the data formats
701 */
702 void setDataFormats(Map<String, DataFormatDefinition> dataFormats);
703
704 /**
705 * Gets the data formats that can be referenced in the routes.
706 *
707 * @return the data formats available
708 */
709 Map<String, DataFormatDefinition> getDataFormats();
710
711 /**
712 * Resolve a data format given its name
713 *
714 * @param name the data format name or a reference to it in the {@link Registry}
715 * @return the resolved data format, or <tt>null</tt> if not found
716 */
717 DataFormat resolveDataFormat(String name);
718
719 /**
720 * Resolve a data format definition given its name
721 *
722 * @param name the data format definition name or a reference to it in the {@link Registry}
723 * @return the resolved data format definition, or <tt>null</tt> if not found
724 */
725 DataFormatDefinition resolveDataFormatDefinition(String name);
726
727 /**
728 * Gets the current data format resolver
729 *
730 * @return the resolver
731 */
732 DataFormatResolver getDataFormatResolver();
733
734 /**
735 * Sets a custom data format resolver
736 *
737 * @param dataFormatResolver the resolver
738 */
739 void setDataFormatResolver(DataFormatResolver dataFormatResolver);
740
741 /**
742 * Sets the properties that can be referenced in the camel context
743 *
744 * @param properties properties
745 */
746 void setProperties(Map<String, String> properties);
747
748 /**
749 * Gets the properties that can be referenced in the camel context
750 *
751 * @return the properties
752 */
753 Map<String, String> getProperties();
754
755 /**
756 * Gets the default FactoryFinder which will be used for the loading the factory class from META-INF
757 *
758 * @return the default factory finder
759 */
760 FactoryFinder getDefaultFactoryFinder();
761
762 /**
763 * Sets the factory finder resolver to use.
764 *
765 * @param resolver the factory finder resolver
766 */
767 void setFactoryFinderResolver(FactoryFinderResolver resolver);
768
769 /**
770 * Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path
771 *
772 * @param path the META-INF path
773 * @return the factory finder
774 * @throws NoFactoryAvailableException is thrown if a factory could not be found
775 */
776 FactoryFinder getFactoryFinder(String path) throws NoFactoryAvailableException;
777
778 /**
779 * Returns the class resolver to be used for loading/lookup of classes.
780 *
781 * @return the resolver
782 */
783 ClassResolver getClassResolver();
784
785 /**
786 * Returns the package scanning class resolver
787 *
788 * @return the resolver
789 */
790 PackageScanClassResolver getPackageScanClassResolver();
791
792 /**
793 * Sets the class resolver to be use
794 *
795 * @param resolver the resolver
796 */
797 void setClassResolver(ClassResolver resolver);
798
799 /**
800 * Sets the package scanning class resolver to use
801 *
802 * @param resolver the resolver
803 */
804 void setPackageScanClassResolver(PackageScanClassResolver resolver);
805
806 /**
807 * Sets a pluggable service pool to use for {@link Producer} pooling.
808 *
809 * @param servicePool the pool
810 */
811 void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool);
812
813 /**
814 * Gets the service pool for {@link Producer} pooling.
815 *
816 * @return the service pool
817 */
818 ServicePool<Endpoint, Producer> getProducerServicePool();
819
820 /**
821 * Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions
822 *
823 * @param factory custom factory to use
824 */
825 void setNodeIdFactory(NodeIdFactory factory);
826
827 /**
828 * Gets the node id factory
829 *
830 * @return the node id factory
831 */
832 NodeIdFactory getNodeIdFactory();
833
834 /**
835 * Gets the management strategy
836 *
837 * @return the management strategy
838 */
839 ManagementStrategy getManagementStrategy();
840
841 /**
842 * Sets the management strategy to use
843 *
844 * @param strategy the management strategy
845 */
846 void setManagementStrategy(ManagementStrategy strategy);
847
848 /**
849 * Gets the default tracer
850 *
851 * @return the default tracer
852 */
853 InterceptStrategy getDefaultTracer();
854
855 /**
856 * Sets a custom tracer to be used as the default tracer.
857 * <p/>
858 * <b>Note:</b> This must be set before any routes are created,
859 * changing the defaultTracer for existing routes is not supported.
860 *
861 * @param tracer the custom tracer to use as default tracer
862 */
863 void setDefaultTracer(InterceptStrategy tracer);
864
865 /**
866 * Disables using JMX as {@link org.apache.camel.spi.ManagementStrategy}.
867 */
868 void disableJMX();
869
870 /**
871 * Gets the inflight repository
872 *
873 * @return the repository
874 */
875 InflightRepository getInflightRepository();
876
877 /**
878 * Sets a custom inflight repository to use
879 *
880 * @param repository the repository
881 */
882 void setInflightRepository(InflightRepository repository);
883
884 /**
885 * Gets the the application context class loader which may be helpful for running camel in other containers
886 *
887 * @return the application context class loader
888 */
889 ClassLoader getApplicationContextClassLoader();
890
891 /**
892 * Sets the application context class loader
893 *
894 * @param classLoader the class loader
895 */
896 void setApplicationContextClassLoader(ClassLoader classLoader);
897
898 /**
899 * Gets the current shutdown strategy
900 *
901 * @return the strategy
902 */
903 ShutdownStrategy getShutdownStrategy();
904
905 /**
906 * Sets a custom shutdown strategy
907 *
908 * @param shutdownStrategy the custom strategy
909 */
910 void setShutdownStrategy(ShutdownStrategy shutdownStrategy);
911
912 /**
913 * Gets the current {@link org.apache.camel.spi.ExecutorServiceStrategy}
914 *
915 * @return the strategy
916 */
917 ExecutorServiceStrategy getExecutorServiceStrategy();
918
919 /**
920 * Sets a custom {@link org.apache.camel.spi.ExecutorServiceStrategy}
921 *
922 * @param executorServiceStrategy the custom strategy
923 */
924 void setExecutorServiceStrategy(ExecutorServiceStrategy executorServiceStrategy);
925
926 /**
927 * Gets the current {@link org.apache.camel.spi.ProcessorFactory}
928 *
929 * @return the factory, can be <tt>null</tt> if no custom factory has been set
930 */
931 ProcessorFactory getProcessorFactory();
932
933 /**
934 * Sets a custom {@link org.apache.camel.spi.ProcessorFactory}
935 *
936 * @param processorFactory the custom factory
937 */
938 void setProcessorFactory(ProcessorFactory processorFactory);
939
940 /**
941 * Gets the current {@link Debugger}
942 *
943 * @return the debugger
944 */
945 Debugger getDebugger();
946
947 /**
948 * Sets a custom {@link Debugger}
949 *
950 * @param debugger the debugger
951 */
952 void setDebugger(Debugger debugger);
953
954 /**
955 * Gets the current {@link UuidGenerator}
956 *
957 * @return the uuidGenerator
958 */
959 UuidGenerator getUuidGenerator();
960
961 /**
962 * Sets a custom {@link UuidGenerator} (should only be set once)
963 *
964 * @param uuidGenerator the UUID Generator
965 */
966 void setUuidGenerator(UuidGenerator uuidGenerator);
967
968 /**
969 * Whether or not type converters should be loaded lazy
970 *
971 * @return <tt>true</tt> to load lazy, <tt>false</tt> to load on startup
972 */
973 Boolean isLazyLoadTypeConverters();
974
975 /**
976 * Sets whether type converters should be loaded lazy
977 *
978 * @param lazyLoadTypeConverters <tt>true</tt> to load lazy, <tt>false</tt> to load on startup
979 */
980 void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters);
981
982 /**
983 * Whether or not <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> logging is being enabled.
984 *
985 * @return <tt>true</tt> if MDC logging is enabled
986 */
987 Boolean isUseMDCLogging();
988
989 /**
990 * Set whether <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> is enabled.
991 *
992 * @param useMDCLogging <tt>true</tt> to enable MDC logging, <tt>false</tt> to disable
993 */
994 void setUseMDCLogging(Boolean useMDCLogging);
995
996 /**
997 * Whether or not breadcrumb is enabled.
998 *
999 * @return <tt>true</tt> if breadcrumb is enabled
1000 */
1001 Boolean isUseBreadcrumb();
1002
1003 /**
1004 * Set whether breadcrumb is enabled.
1005 *
1006 * @param useBreadcrumb <tt>true</tt> to enable breadcrumb, <tt>false</tt> to disable
1007 */
1008 void setUseBreadcrumb(Boolean useBreadcrumb);
1009
1010
1011
1012 }