001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.spring; 018 019import java.util.ArrayList; 020import java.util.List; 021import java.util.Map; 022 023import javax.xml.bind.annotation.XmlAccessType; 024import javax.xml.bind.annotation.XmlAccessorType; 025import javax.xml.bind.annotation.XmlAttribute; 026import javax.xml.bind.annotation.XmlElement; 027import javax.xml.bind.annotation.XmlElements; 028import javax.xml.bind.annotation.XmlRootElement; 029import javax.xml.bind.annotation.XmlTransient; 030 031import org.apache.camel.CamelContext; 032import org.apache.camel.LoggingLevel; 033import org.apache.camel.RoutesBuilder; 034import org.apache.camel.RuntimeCamelException; 035import org.apache.camel.ShutdownRoute; 036import org.apache.camel.ShutdownRunningTask; 037import org.apache.camel.TypeConverterExists; 038import org.apache.camel.builder.RouteBuilder; 039import org.apache.camel.component.properties.PropertiesComponent; 040import org.apache.camel.component.properties.PropertiesLocation; 041import org.apache.camel.core.xml.AbstractCamelContextFactoryBean; 042import org.apache.camel.core.xml.AbstractCamelFactoryBean; 043import org.apache.camel.core.xml.CamelJMXAgentDefinition; 044import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition; 045import org.apache.camel.core.xml.CamelProxyFactoryDefinition; 046import org.apache.camel.core.xml.CamelServiceExporterDefinition; 047import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition; 048import org.apache.camel.model.ContextScanDefinition; 049import org.apache.camel.model.GlobalOptionsDefinition; 050import org.apache.camel.model.HystrixConfigurationDefinition; 051import org.apache.camel.model.InterceptDefinition; 052import org.apache.camel.model.InterceptFromDefinition; 053import org.apache.camel.model.InterceptSendToEndpointDefinition; 054import org.apache.camel.model.OnCompletionDefinition; 055import org.apache.camel.model.OnExceptionDefinition; 056import org.apache.camel.model.PackageScanDefinition; 057import org.apache.camel.model.RestContextRefDefinition; 058import org.apache.camel.model.RouteBuilderDefinition; 059import org.apache.camel.model.RouteContextRefDefinition; 060import org.apache.camel.model.RouteDefinition; 061import org.apache.camel.model.ThreadPoolProfileDefinition; 062import org.apache.camel.model.cloud.ServiceCallConfigurationDefinition; 063import org.apache.camel.model.dataformat.DataFormatsDefinition; 064import org.apache.camel.model.rest.RestConfigurationDefinition; 065import org.apache.camel.model.rest.RestDefinition; 066import org.apache.camel.model.transformer.TransformersDefinition; 067import org.apache.camel.model.validator.ValidatorsDefinition; 068import org.apache.camel.spi.Metadata; 069import org.apache.camel.spi.PackageScanFilter; 070import org.apache.camel.spi.Registry; 071import org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer; 072import org.apache.camel.spring.spi.XmlCamelContextConfigurer; 073import org.apache.camel.support.CamelContextHelper; 074import org.apache.camel.util.StopWatch; 075import org.slf4j.Logger; 076import org.slf4j.LoggerFactory; 077import org.springframework.beans.factory.DisposableBean; 078import org.springframework.beans.factory.FactoryBean; 079import org.springframework.beans.factory.InitializingBean; 080import org.springframework.beans.factory.config.BeanPostProcessor; 081import org.springframework.context.ApplicationContext; 082import org.springframework.context.ApplicationContextAware; 083import org.springframework.context.ApplicationListener; 084import org.springframework.context.Lifecycle; 085import org.springframework.context.Phased; 086import org.springframework.context.event.ContextRefreshedEvent; 087import org.springframework.core.Ordered; 088 089import static org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException; 090 091/** 092 * CamelContext using XML configuration. 093 */ 094@Metadata(label = "spring,configuration") 095@XmlRootElement(name = "camelContext") 096@XmlAccessorType(XmlAccessType.FIELD) 097public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<SpringCamelContext> 098 implements FactoryBean<SpringCamelContext>, InitializingBean, DisposableBean, ApplicationContextAware, Lifecycle, 099 Phased, ApplicationListener<ContextRefreshedEvent>, Ordered { 100 101 private static final Logger LOG = LoggerFactory.getLogger(CamelContextFactoryBean.class); 102 103 @XmlAttribute(name = "depends-on") @Metadata(displayName = "Depends On") 104 private String dependsOn; 105 @XmlAttribute 106 private String trace; 107 @XmlAttribute 108 private String tracePattern; 109 @XmlAttribute @Metadata(defaultValue = "true") 110 private String messageHistory; 111 @XmlAttribute @Metadata(defaultValue = "false") 112 private String logMask; 113 @XmlAttribute 114 private String logExhaustedMessageBody; 115 @XmlAttribute 116 private String streamCache; 117 @XmlAttribute 118 private String delayer; 119 @XmlAttribute 120 private String errorHandlerRef; 121 @XmlAttribute @Metadata(defaultValue = "true") 122 private String autoStartup; 123 @XmlAttribute @Metadata(defaultValue = "true") 124 private String shutdownEager; 125 @XmlAttribute @Metadata(displayName = "Use MDC Logging") 126 private String useMDCLogging; 127 @XmlAttribute @Metadata(displayName = "MDC Logging Keys Pattern") 128 private String mdcLoggingKeysPattern; 129 @XmlAttribute 130 private String useDataType; 131 @XmlAttribute 132 private String useBreadcrumb; 133 @XmlAttribute 134 private String allowUseOriginalMessage; 135 @XmlAttribute 136 private String runtimeEndpointRegistryEnabled; 137 @XmlAttribute @Metadata(defaultValue = "#name#") 138 private String managementNamePattern; 139 @XmlAttribute @Metadata(defaultValue = "Camel (#camelId#) thread ##counter# - #name#") 140 private String threadNamePattern; 141 @XmlAttribute @Metadata(defaultValue = "Default") 142 private ShutdownRoute shutdownRoute; 143 @XmlAttribute @Metadata(defaultValue = "CompleteCurrentTaskOnly") 144 private ShutdownRunningTask shutdownRunningTask; 145 @XmlAttribute @Metadata(defaultValue = "true") 146 private Boolean loadTypeConverters; 147 @XmlAttribute 148 private Boolean typeConverterStatisticsEnabled; 149 @XmlAttribute @Metadata(defaultValue = "Override") 150 private TypeConverterExists typeConverterExists; 151 @XmlAttribute @Metadata(defaultValue = "WARN") 152 private LoggingLevel typeConverterExistsLoggingLevel; 153 @XmlElement(name = "globalOptions") 154 private GlobalOptionsDefinition globalOptions; 155 @XmlElement(name = "propertyPlaceholder", type = CamelPropertyPlaceholderDefinition.class) 156 private CamelPropertyPlaceholderDefinition camelPropertyPlaceholder; 157 @XmlElement(name = "package") 158 private String[] packages = {}; 159 @XmlElement(name = "packageScan", type = PackageScanDefinition.class) 160 private PackageScanDefinition packageScan; 161 @XmlElement(name = "contextScan", type = ContextScanDefinition.class) 162 private ContextScanDefinition contextScan; 163 @XmlElement(name = "streamCaching", type = CamelStreamCachingStrategyDefinition.class) 164 private CamelStreamCachingStrategyDefinition camelStreamCachingStrategy; 165 @XmlElement(name = "jmxAgent", type = CamelJMXAgentDefinition.class) @Metadata(displayName = "JMX Agent") 166 private CamelJMXAgentDefinition camelJMXAgent; 167 @XmlElements({ 168 @XmlElement(name = "template", type = CamelProducerTemplateFactoryBean.class), 169 @XmlElement(name = "fluentTemplate", type = CamelFluentProducerTemplateFactoryBean.class), 170 @XmlElement(name = "consumerTemplate", type = CamelConsumerTemplateFactoryBean.class)}) 171 private List<AbstractCamelFactoryBean<?>> beansFactory; 172 @XmlElements({ 173 @XmlElement(name = "proxy", type = CamelProxyFactoryDefinition.class), 174 @XmlElement(name = "export", type = CamelServiceExporterDefinition.class), 175 @XmlElement(name = "errorHandler", type = ErrorHandlerDefinition.class) }) 176 private List<?> beans; 177 @XmlElement(name = "defaultServiceCallConfiguration") 178 private ServiceCallConfigurationDefinition defaultServiceCallConfiguration; 179 @XmlElement(name = "serviceCallConfiguration", type = ServiceCallConfigurationDefinition.class) 180 private List<ServiceCallConfigurationDefinition> serviceCallConfigurations; 181 @XmlElement(name = "defaultHystrixConfiguration") 182 private HystrixConfigurationDefinition defaultHystrixConfiguration; 183 @XmlElement(name = "hystrixConfiguration", type = HystrixConfigurationDefinition.class) 184 private List<HystrixConfigurationDefinition> hystrixConfigurations; 185 @XmlElement(name = "routeBuilder") 186 private List<RouteBuilderDefinition> builderRefs = new ArrayList<>(); 187 @XmlElement(name = "routeContextRef") 188 private List<RouteContextRefDefinition> routeRefs = new ArrayList<>(); 189 @XmlElement(name = "restContextRef") 190 private List<RestContextRefDefinition> restRefs = new ArrayList<>(); 191 @XmlElement(name = "threadPoolProfile") 192 private List<ThreadPoolProfileDefinition> threadPoolProfiles; 193 @XmlElement(name = "threadPool") 194 private List<CamelThreadPoolFactoryBean> threadPools; 195 @XmlElement(name = "endpoint") 196 private List<CamelEndpointFactoryBean> endpoints; 197 @XmlElement(name = "dataFormats") 198 private DataFormatsDefinition dataFormats; 199 @XmlElement(name = "transformers") 200 private TransformersDefinition transformers; 201 @XmlElement(name = "validators") 202 private ValidatorsDefinition validators; 203 @XmlElement(name = "redeliveryPolicyProfile") 204 private List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies; 205 @XmlElement(name = "onException") 206 private List<OnExceptionDefinition> onExceptions = new ArrayList<>(); 207 @XmlElement(name = "onCompletion") 208 private List<OnCompletionDefinition> onCompletions = new ArrayList<>(); 209 @XmlElement(name = "intercept") 210 private List<InterceptDefinition> intercepts = new ArrayList<>(); 211 @XmlElement(name = "interceptFrom") 212 private List<InterceptFromDefinition> interceptFroms = new ArrayList<>(); 213 @XmlElement(name = "interceptSendToEndpoint") 214 private List<InterceptSendToEndpointDefinition> interceptSendToEndpoints = new ArrayList<>(); 215 @XmlElement(name = "restConfiguration") 216 private RestConfigurationDefinition restConfiguration; 217 @XmlElement(name = "rest") 218 private List<RestDefinition> rests = new ArrayList<>(); 219 @XmlElement(name = "route") 220 private List<RouteDefinition> routes = new ArrayList<>(); 221 @XmlTransient 222 private SpringCamelContext context; 223 @XmlTransient 224 private ClassLoader contextClassLoaderOnStart; 225 @XmlTransient 226 private ApplicationContext applicationContext; 227 @XmlTransient 228 private BeanPostProcessor beanPostProcessor; 229 @XmlTransient 230 private boolean implicitId; 231 232 @Override 233 public Class<SpringCamelContext> getObjectType() { 234 return SpringCamelContext.class; 235 } 236 237 @Override 238 protected <S> S getBeanForType(Class<S> clazz) { 239 S bean = null; 240 String[] names = getApplicationContext().getBeanNamesForType(clazz, true, true); 241 if (names.length == 1) { 242 bean = getApplicationContext().getBean(names[0], clazz); 243 } 244 if (bean == null) { 245 ApplicationContext parentContext = getApplicationContext().getParent(); 246 if (parentContext != null) { 247 names = parentContext.getBeanNamesForType(clazz, true, true); 248 if (names.length == 1) { 249 bean = parentContext.getBean(names[0], clazz); 250 } 251 } 252 } 253 return bean; 254 } 255 256 @Override 257 protected void findRouteBuildersByPackageScan(String[] packages, PackageScanFilter filter, List<RoutesBuilder> builders) throws Exception { 258 // add filter to class resolver which then will filter 259 getContext().getPackageScanClassResolver().addFilter(filter); 260 261 PackageScanRouteBuilderFinder finder = new PackageScanRouteBuilderFinder(getContext(), packages, getContextClassLoaderOnStart(), 262 getBeanPostProcessor(), getContext().getPackageScanClassResolver()); 263 finder.appendBuilders(builders); 264 265 // and remove the filter 266 getContext().getPackageScanClassResolver().removeFilter(filter); 267 } 268 269 @Override 270 protected void findRouteBuildersByContextScan(PackageScanFilter filter, boolean includeNonSingletons, List<RoutesBuilder> builders) throws Exception { 271 ContextScanRouteBuilderFinder finder = new ContextScanRouteBuilderFinder(getContext(), filter, includeNonSingletons); 272 finder.appendBuilders(builders); 273 } 274 275 @Override 276 protected void initBeanPostProcessor(SpringCamelContext context) { 277 if (beanPostProcessor != null) { 278 if (beanPostProcessor instanceof ApplicationContextAware) { 279 ((ApplicationContextAware) beanPostProcessor).setApplicationContext(applicationContext); 280 } 281 if (beanPostProcessor instanceof CamelBeanPostProcessor) { 282 ((CamelBeanPostProcessor) beanPostProcessor).setCamelContext(getContext()); 283 } 284 // register the bean post processor on camel context 285 if (beanPostProcessor instanceof org.apache.camel.spi.CamelBeanPostProcessor) { 286 context.setBeanPostProcessor((org.apache.camel.spi.CamelBeanPostProcessor) beanPostProcessor); 287 } 288 } 289 } 290 291 @Override 292 protected void postProcessBeforeInit(RouteBuilder builder) { 293 if (beanPostProcessor != null) { 294 // Inject the annotated resource 295 beanPostProcessor.postProcessBeforeInitialization(builder, builder.toString()); 296 } 297 } 298 299 @Override 300 public void afterPropertiesSet() throws Exception { 301 StopWatch watch = new StopWatch(); 302 303 super.afterPropertiesSet(); 304 305 Boolean shutdownEager = CamelContextHelper.parseBoolean(getContext(), getShutdownEager()); 306 if (shutdownEager != null) { 307 LOG.debug("Using shutdownEager: {}", shutdownEager); 308 getContext().setShutdownEager(shutdownEager); 309 } 310 311 LOG.debug("afterPropertiesSet() took {} millis", watch.taken()); 312 } 313 314 @Override 315 protected void initCustomRegistry(SpringCamelContext context) { 316 Registry registry = getBeanForType(Registry.class); 317 if (registry != null) { 318 LOG.info("Using custom Registry: {}", registry); 319 context.setRegistry(registry); 320 } 321 } 322 323 @Override 324 protected void initPropertyPlaceholder() throws Exception { 325 super.initPropertyPlaceholder(); 326 327 Map<String, BridgePropertyPlaceholderConfigurer> beans = applicationContext.getBeansOfType(BridgePropertyPlaceholderConfigurer.class); 328 if (beans.size() == 1) { 329 // setup properties component that uses this beans 330 BridgePropertyPlaceholderConfigurer configurer = beans.values().iterator().next(); 331 String id = beans.keySet().iterator().next(); 332 LOG.info("Bridging Camel and Spring property placeholder configurer with id: {}", id); 333 334 // get properties component 335 PropertiesComponent pc = (PropertiesComponent) getContext().getComponent("properties", false); 336 if (pc == null) { 337 // do not auto create the component as spring autowrire by constructor causes a side effect when using bridge 338 pc = new PropertiesComponent(); 339 getContext().addComponent("properties", pc); 340 } 341 // use the spring system properties mode which has a different value than Camel may have 342 pc.setSystemPropertiesMode(configurer.getSystemPropertiesMode()); 343 344 // replace existing resolver with us 345 configurer.setParser(pc.getPropertiesParser()); 346 // use the bridge to handle the resolve and parsing 347 pc.setPropertiesParser(configurer); 348 // use the bridge as property source 349 pc.addPropertiesSource(configurer); 350 351 } else if (beans.size() > 1) { 352 LOG.warn("Cannot bridge Camel and Spring property placeholders, as exact only 1 bean of type BridgePropertyPlaceholderConfigurer" 353 + " must be defined, was {} beans defined.", beans.size()); 354 } 355 } 356 357 @Override 358 public void start() { 359 try { 360 setupRoutes(); 361 } catch (Exception e) { 362 throw wrapRuntimeCamelException(e); 363 } 364 365 // when the routes are setup we need to start the Camel context 366 context.start(); 367 } 368 369 @Override 370 public void stop() { 371 if (context != null) { 372 context.stop(); 373 } 374 } 375 376 @Override 377 public boolean isRunning() { 378 return context != null && context.isRunning(); 379 } 380 381 @Override 382 public int getPhase() { 383 // the factory starts the context from 384 // onApplicationEvent(ContextRefreshedEvent) so the phase we're 385 // in only influences when the context is to be stopped, and 386 // we want the CamelContext to be first in line to get stopped 387 // if we wanted the phase to be considered while starting, we 388 // would need to implement SmartLifecycle (see 389 // DefaultLifecycleProcessor::startBeans) 390 // we use LOWEST_PRECEDENCE here as this is taken into account 391 // only when stopping and then in reversed order 392 return LOWEST_PRECEDENCE - 1; 393 } 394 395 @Override 396 public int getOrder() { 397 // CamelContextFactoryBean implements Ordered so that it's the 398 // second to last in ApplicationListener to receive events, 399 // SpringCamelContext should be the last one, this is important 400 // for startup as we want all resources to be ready and all 401 // routes added to the context (see setupRoutes() and 402 // org.apache.camel.spring.boot.RoutesCollector) 403 return LOWEST_PRECEDENCE - 1; 404 } 405 406 @Override 407 public void onApplicationEvent(final ContextRefreshedEvent event) { 408 // start the CamelContext when the Spring ApplicationContext is 409 // done initializing, as the last step in ApplicationContext 410 // being started/refreshed, there could be a race condition with 411 // other ApplicationListeners that react to 412 // ContextRefreshedEvent but this is the best that we can do 413 start(); 414 } 415 416 // Properties 417 // ------------------------------------------------------------------------- 418 419 public ApplicationContext getApplicationContext() { 420 if (applicationContext == null) { 421 throw new IllegalArgumentException("No applicationContext has been injected!"); 422 } 423 return applicationContext; 424 } 425 426 @Override 427 public void setApplicationContext(ApplicationContext applicationContext) { 428 this.applicationContext = applicationContext; 429 } 430 431 public void setBeanPostProcessor(BeanPostProcessor postProcessor) { 432 this.beanPostProcessor = postProcessor; 433 } 434 435 public BeanPostProcessor getBeanPostProcessor() { 436 return beanPostProcessor; 437 } 438 439 // Implementation methods 440 // ------------------------------------------------------------------------- 441 442 /** 443 * Create the context 444 */ 445 protected SpringCamelContext createContext() { 446 SpringCamelContext ctx = newCamelContext(); 447 ctx.setName(getId()); 448 449 return ctx; 450 } 451 452 /** 453 * Apply additional configuration to the context 454 */ 455 protected void configure(SpringCamelContext ctx) { 456 try { 457 // allow any custom configuration, such as when running in camel-spring-boot 458 if (applicationContext.containsBean("xmlCamelContextConfigurer")) { 459 XmlCamelContextConfigurer configurer = applicationContext.getBean("xmlCamelContextConfigurer", XmlCamelContextConfigurer.class); 460 if (configurer != null) { 461 configurer.configure(applicationContext, ctx); 462 } 463 } 464 } catch (Exception e) { 465 // error during configuration 466 throw RuntimeCamelException.wrapRuntimeCamelException(e); 467 } 468 } 469 470 protected SpringCamelContext newCamelContext() { 471 return new SpringCamelContext(getApplicationContext()); 472 } 473 474 @Override 475 public SpringCamelContext getContext(boolean create) { 476 if (context == null && create) { 477 context = createContext(); 478 configure(context); 479 context.init(); 480 } 481 return context; 482 } 483 484 public void setContext(SpringCamelContext context) { 485 this.context = context; 486 } 487 488 @Override 489 public List<RouteDefinition> getRoutes() { 490 return routes; 491 } 492 493 /** 494 * Contains the Camel routes 495 */ 496 @Override 497 public void setRoutes(List<RouteDefinition> routes) { 498 this.routes = routes; 499 } 500 501 @Override 502 public List<RestDefinition> getRests() { 503 return rests; 504 } 505 506 /** 507 * Contains the rest services defined using the rest-dsl 508 */ 509 @Override 510 public void setRests(List<RestDefinition> rests) { 511 this.rests = rests; 512 } 513 514 @Override 515 public RestConfigurationDefinition getRestConfiguration() { 516 return restConfiguration; 517 } 518 519 /** 520 * Configuration for rest-dsl 521 */ 522 public void setRestConfiguration(RestConfigurationDefinition restConfiguration) { 523 this.restConfiguration = restConfiguration; 524 } 525 526 @Override 527 public List<CamelEndpointFactoryBean> getEndpoints() { 528 return endpoints; 529 } 530 531 /** 532 * Configuration of endpoints 533 */ 534 public void setEndpoints(List<CamelEndpointFactoryBean> endpoints) { 535 this.endpoints = endpoints; 536 } 537 538 @Override 539 public List<CamelRedeliveryPolicyFactoryBean> getRedeliveryPolicies() { 540 return redeliveryPolicies; 541 } 542 543 @Override 544 public List<InterceptDefinition> getIntercepts() { 545 return intercepts; 546 } 547 548 /** 549 * Configuration of interceptors. 550 */ 551 public void setIntercepts(List<InterceptDefinition> intercepts) { 552 this.intercepts = intercepts; 553 } 554 555 @Override 556 public List<InterceptFromDefinition> getInterceptFroms() { 557 return interceptFroms; 558 } 559 560 /** 561 * Configuration of interceptors that triggers from the beginning of routes. 562 */ 563 public void setInterceptFroms(List<InterceptFromDefinition> interceptFroms) { 564 this.interceptFroms = interceptFroms; 565 } 566 567 @Override 568 public List<InterceptSendToEndpointDefinition> getInterceptSendToEndpoints() { 569 return interceptSendToEndpoints; 570 } 571 572 /** 573 * Configuration of interceptors that triggers sending messages to endpoints. 574 */ 575 public void setInterceptSendToEndpoints(List<InterceptSendToEndpointDefinition> interceptSendToEndpoints) { 576 this.interceptSendToEndpoints = interceptSendToEndpoints; 577 } 578 579 @Override 580 public GlobalOptionsDefinition getGlobalOptions() { 581 return globalOptions; 582 } 583 584 /** 585 * Configuration of CamelContext properties such as limit of debug logging 586 * and other general options. 587 */ 588 public void setGlobalOptions(GlobalOptionsDefinition globalOptions) { 589 this.globalOptions = globalOptions; 590 } 591 592 @Override 593 public String[] getPackages() { 594 return packages; 595 } 596 597 /** 598 * Sets the package names to be recursively searched for Java classes which 599 * extend {@link org.apache.camel.builder.RouteBuilder} to be auto-wired up to the 600 * {@link CamelContext} as a route. Note that classes are excluded if 601 * they are specifically configured in the spring.xml 602 * <p/> 603 * A more advanced configuration can be done using {@link #setPackageScan(org.apache.camel.model.PackageScanDefinition)} 604 * 605 * @param packages the package names which are recursively searched 606 * @see #setPackageScan(org.apache.camel.model.PackageScanDefinition) 607 */ 608 public void setPackages(String[] packages) { 609 this.packages = packages; 610 } 611 612 @Override 613 public PackageScanDefinition getPackageScan() { 614 return packageScan; 615 } 616 617 /** 618 * Sets the package scanning information. Package scanning allows for the 619 * automatic discovery of certain camel classes at runtime for inclusion 620 * e.g. {@link org.apache.camel.builder.RouteBuilder} implementations 621 * 622 * @param packageScan the package scan 623 */ 624 @Override 625 public void setPackageScan(PackageScanDefinition packageScan) { 626 this.packageScan = packageScan; 627 } 628 629 @Override 630 public ContextScanDefinition getContextScan() { 631 return contextScan; 632 } 633 634 /** 635 * Sets the context scanning (eg Spring's ApplicationContext) information. 636 * Context scanning allows for the automatic discovery of Camel routes runtime for inclusion 637 * e.g. {@link org.apache.camel.builder.RouteBuilder} implementations 638 * 639 * @param contextScan the context scan 640 */ 641 @Override 642 public void setContextScan(ContextScanDefinition contextScan) { 643 this.contextScan = contextScan; 644 } 645 646 @Override 647 public CamelPropertyPlaceholderDefinition getCamelPropertyPlaceholder() { 648 return camelPropertyPlaceholder; 649 } 650 651 /** 652 * Configuration of property placeholder 653 */ 654 public void setCamelPropertyPlaceholder(CamelPropertyPlaceholderDefinition camelPropertyPlaceholder) { 655 this.camelPropertyPlaceholder = camelPropertyPlaceholder; 656 } 657 658 @Override 659 public CamelStreamCachingStrategyDefinition getCamelStreamCachingStrategy() { 660 return camelStreamCachingStrategy; 661 } 662 663 /** 664 * Configuration of stream caching. 665 */ 666 public void setCamelStreamCachingStrategy(CamelStreamCachingStrategyDefinition camelStreamCachingStrategy) { 667 this.camelStreamCachingStrategy = camelStreamCachingStrategy; 668 } 669 670 /** 671 * Configuration of JMX Agent. 672 */ 673 public void setCamelJMXAgent(CamelJMXAgentDefinition agent) { 674 camelJMXAgent = agent; 675 } 676 677 @Override 678 public String getTrace() { 679 return trace; 680 } 681 682 /** 683 * Sets whether tracing is enabled or not. 684 */ 685 public void setTrace(String trace) { 686 this.trace = trace; 687 } 688 689 @Override 690 public String getTracePattern() { 691 return tracePattern; 692 } 693 694 /** 695 * Tracing pattern to match which node EIPs to trace. 696 * For example to match all To EIP nodes, use to*. 697 * The pattern matches by node and route id's 698 * Multiple patterns can be separated by comma. 699 */ 700 public void setTracePattern(String tracePattern) { 701 this.tracePattern = tracePattern; 702 } 703 704 @Override 705 public String getMessageHistory() { 706 return messageHistory; 707 } 708 709 /** 710 * Sets whether message history is enabled or not. 711 */ 712 public void setMessageHistory(String messageHistory) { 713 this.messageHistory = messageHistory; 714 } 715 716 @Override 717 public String getLogMask() { 718 return logMask; 719 } 720 721 /** 722 * Sets whether security mask for Logging is enabled or not. 723 */ 724 public void setLogMask(String logMask) { 725 this.logMask = logMask; 726 } 727 728 @Override 729 public String getLogExhaustedMessageBody() { 730 return logExhaustedMessageBody; 731 } 732 733 /** 734 * Sets whether to log exhausted message body with message history. 735 */ 736 public void setLogExhaustedMessageBody(String logExhaustedMessageBody) { 737 this.logExhaustedMessageBody = logExhaustedMessageBody; 738 } 739 740 @Override 741 public String getStreamCache() { 742 return streamCache; 743 } 744 745 /** 746 * Sets whether stream caching is enabled or not. 747 */ 748 public void setStreamCache(String streamCache) { 749 this.streamCache = streamCache; 750 } 751 752 @Override 753 public String getDelayer() { 754 return delayer; 755 } 756 757 /** 758 * Sets a delay value in millis that a message is delayed at every step it takes in the route path, 759 * slowing the process down to better observe what is occurring 760 */ 761 public void setDelayer(String delayer) { 762 this.delayer = delayer; 763 } 764 765 @Override 766 public String getAutoStartup() { 767 return autoStartup; 768 } 769 770 /** 771 * Sets whether the object should automatically start when Camel starts. 772 * <p/> 773 * <b>Important:</b> Currently only routes can be disabled, as {@link CamelContext}s are always started. 774 * <br/> 775 * <b>Note:</b> When setting auto startup <tt>false</tt> on {@link CamelContext} then that takes precedence 776 * and <i>no</i> routes is started. You would need to start {@link CamelContext} explicit using 777 * the {@link org.apache.camel.CamelContext#start()} method, to start the context, and then 778 * you would need to start the routes manually using {@link org.apache.camel.spi.RouteController#startRoute(String)}. 779 */ 780 public void setAutoStartup(String autoStartup) { 781 this.autoStartup = autoStartup; 782 } 783 784 public String getShutdownEager() { 785 return shutdownEager; 786 } 787 788 /** 789 * Whether to shutdown CamelContext eager when Spring is shutting down. 790 * This ensure a cleaner shutdown of Camel, as dependent bean's are not shutdown at this moment. 791 * The bean's will then be shutdown after camelContext. 792 */ 793 public void setShutdownEager(String shutdownEager) { 794 this.shutdownEager = shutdownEager; 795 } 796 797 @Override 798 public String getUseMDCLogging() { 799 return useMDCLogging; 800 } 801 802 /** 803 * Set whether <a href="http://www.slf4j.org/api/org/slf4j/MDC.html">MDC</a> is enabled. 804 */ 805 public void setUseMDCLogging(String useMDCLogging) { 806 this.useMDCLogging = useMDCLogging; 807 } 808 809 public String getMDCLoggingKeysPattern() { 810 return mdcLoggingKeysPattern; 811 } 812 813 /** 814 * Sets the pattern used for determine which custom MDC keys to propagate during message routing when 815 * the routing engine continues routing asynchronously for the given message. Setting this pattern to * will 816 * propagate all custom keys. Or setting the pattern to foo*,bar* will propagate any keys starting with 817 * either foo or bar. 818 * Notice that a set of standard Camel MDC keys are always propagated which starts with camel. as key name. 819 * 820 * The match rules are applied in this order (case insensitive): 821 * 822 * 1. exact match, returns true 823 * 2. wildcard match (pattern ends with a * and the name starts with the pattern), returns true 824 * 3. regular expression match, returns true 825 * 4. otherwise returns false 826 */ 827 public void setMDCLoggingKeysPattern(String mdcLoggingKeysPattern) { 828 this.mdcLoggingKeysPattern = mdcLoggingKeysPattern; 829 } 830 831 @Override 832 public String getUseDataType() { 833 return useDataType; 834 } 835 836 /** 837 * Whether to enable using data type on Camel messages. 838 * <p/> 839 * Data type are automatic turned on if: 840 * <ul> 841 * <li>one ore more routes has been explicit configured with input and output types</li> 842 * <li>when using rest-dsl with binding turned on</li> 843 * </ul> 844 * Otherwise data type is default off. 845 */ 846 public void setUseDataType(String useDataType) { 847 this.useDataType = useDataType; 848 } 849 850 @Override 851 public String getUseBreadcrumb() { 852 return useBreadcrumb; 853 } 854 855 /** 856 * Set whether breadcrumb is enabled. 857 */ 858 public void setUseBreadcrumb(String useBreadcrumb) { 859 this.useBreadcrumb = useBreadcrumb; 860 } 861 862 @Override 863 public String getAllowUseOriginalMessage() { 864 return allowUseOriginalMessage; 865 } 866 867 /** 868 * Sets whether to allow access to the original message from Camel's error handler, 869 * or from {@link org.apache.camel.spi.UnitOfWork#getOriginalInMessage()}. 870 * <p/> 871 * Turning this off can optimize performance, as defensive copy of the original message is not needed. 872 */ 873 public void setAllowUseOriginalMessage(String allowUseOriginalMessage) { 874 this.allowUseOriginalMessage = allowUseOriginalMessage; 875 } 876 877 @Override 878 public String getRuntimeEndpointRegistryEnabled() { 879 return runtimeEndpointRegistryEnabled; 880 } 881 882 /** 883 * Sets whether {@link org.apache.camel.spi.RuntimeEndpointRegistry} is enabled. 884 */ 885 public void setRuntimeEndpointRegistryEnabled(String runtimeEndpointRegistryEnabled) { 886 this.runtimeEndpointRegistryEnabled = runtimeEndpointRegistryEnabled; 887 } 888 889 @Override 890 public String getManagementNamePattern() { 891 return managementNamePattern; 892 } 893 894 /** 895 * The naming pattern for creating the CamelContext management name. 896 */ 897 public void setManagementNamePattern(String managementNamePattern) { 898 this.managementNamePattern = managementNamePattern; 899 } 900 901 @Override 902 public String getThreadNamePattern() { 903 return threadNamePattern; 904 } 905 906 /** 907 * Sets the thread name pattern used for creating the full thread name. 908 * <p/> 909 * The default pattern is: <tt>Camel (#camelId#) thread ##counter# - #name#</tt> 910 * <p/> 911 * Where <tt>#camelId#</tt> is the name of the {@link org.apache.camel.CamelContext} 912 * <br/>and <tt>#counter#</tt> is a unique incrementing counter. 913 * <br/>and <tt>#name#</tt> is the regular thread name. 914 * <br/>You can also use <tt>#longName#</tt> is the long thread name which can includes endpoint parameters etc. 915 */ 916 public void setThreadNamePattern(String threadNamePattern) { 917 this.threadNamePattern = threadNamePattern; 918 } 919 920 @Override 921 public Boolean getLoadTypeConverters() { 922 return loadTypeConverters; 923 } 924 925 /** 926 * Sets whether to load custom type converters by scanning classpath. 927 * This can be turned off if you are only using Camel components 928 * that does not provide type converters which is needed at runtime. 929 * In such situations setting this option to false, can speedup starting 930 * Camel. 931 * 932 * @param loadTypeConverters whether to load custom type converters. 933 */ 934 public void setLoadTypeConverters(Boolean loadTypeConverters) { 935 this.loadTypeConverters = loadTypeConverters; 936 } 937 938 @Override 939 public Boolean getTypeConverterStatisticsEnabled() { 940 return typeConverterStatisticsEnabled; 941 } 942 943 /** 944 * Sets whether or not type converter statistics is enabled. 945 * <p/> 946 * By default the type converter utilization statistics is disabled. 947 * <b>Notice:</b> If enabled then there is a slight performance impact under very heavy load. 948 * <p/> 949 * You can enable/disable the statistics at runtime using the 950 * {@link org.apache.camel.spi.TypeConverterRegistry#getStatistics()#setTypeConverterStatisticsEnabled(Boolean)} method, 951 * or from JMX on the {@link org.apache.camel.api.management.mbean.ManagedTypeConverterRegistryMBean} mbean. 952 */ 953 public void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled) { 954 this.typeConverterStatisticsEnabled = typeConverterStatisticsEnabled; 955 } 956 957 @Override 958 public TypeConverterExists getTypeConverterExists() { 959 return typeConverterExists; 960 } 961 962 /** 963 * What should happen when attempting to add a duplicate type converter. 964 * <p/> 965 * The default behavior is to override the existing. 966 */ 967 public void setTypeConverterExists(TypeConverterExists typeConverterExists) { 968 this.typeConverterExists = typeConverterExists; 969 } 970 971 @Override 972 public LoggingLevel getTypeConverterExistsLoggingLevel() { 973 return typeConverterExistsLoggingLevel; 974 } 975 976 /** 977 * The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter. 978 * <p/> 979 * The default logging level is <tt>WARN</tt> 980 */ 981 public void setTypeConverterExistsLoggingLevel(LoggingLevel typeConverterExistsLoggingLevel) { 982 this.typeConverterExistsLoggingLevel = typeConverterExistsLoggingLevel; 983 } 984 985 @Override 986 public CamelJMXAgentDefinition getCamelJMXAgent() { 987 return camelJMXAgent; 988 } 989 990 @Override 991 public List<RouteBuilderDefinition> getBuilderRefs() { 992 return builderRefs; 993 } 994 995 /** 996 * Refers to Java {@link RouteBuilder} instances to include as routes in this CamelContext. 997 */ 998 public void setBuilderRefs(List<RouteBuilderDefinition> builderRefs) { 999 this.builderRefs = builderRefs; 1000 } 1001 1002 @Override 1003 public List<RouteContextRefDefinition> getRouteRefs() { 1004 return routeRefs; 1005 } 1006 1007 /** 1008 * Refers to XML routes to include as routes in this CamelContext. 1009 */ 1010 public void setRouteRefs(List<RouteContextRefDefinition> routeRefs) { 1011 this.routeRefs = routeRefs; 1012 } 1013 1014 @Override 1015 public List<RestContextRefDefinition> getRestRefs() { 1016 return restRefs; 1017 } 1018 1019 /** 1020 * Refers to XML rest-dsl to include as REST services in this CamelContext. 1021 */ 1022 public void setRestRefs(List<RestContextRefDefinition> restRefs) { 1023 this.restRefs = restRefs; 1024 } 1025 1026 @Override 1027 public String getErrorHandlerRef() { 1028 return errorHandlerRef; 1029 } 1030 1031 /** 1032 * Sets the name of the error handler object used to default the error handling strategy 1033 */ 1034 public void setErrorHandlerRef(String errorHandlerRef) { 1035 this.errorHandlerRef = errorHandlerRef; 1036 } 1037 1038 /** 1039 * Configuration of data formats. 1040 */ 1041 public void setDataFormats(DataFormatsDefinition dataFormats) { 1042 this.dataFormats = dataFormats; 1043 } 1044 1045 @Override 1046 public DataFormatsDefinition getDataFormats() { 1047 return dataFormats; 1048 } 1049 1050 /** 1051 * Configuration of transformers. 1052 */ 1053 public void setTransformers(TransformersDefinition transformers) { 1054 this.transformers = transformers; 1055 } 1056 1057 @Override 1058 public TransformersDefinition getTransformers() { 1059 return transformers; 1060 } 1061 1062 /** 1063 * Configuration of validators. 1064 */ 1065 public void setValidators(ValidatorsDefinition validators) { 1066 this.validators = validators; 1067 } 1068 1069 @Override 1070 public ValidatorsDefinition getValidators() { 1071 return validators; 1072 } 1073 1074 /** 1075 * Configuration of redelivery settings. 1076 */ 1077 public void setRedeliveryPolicies(List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies) { 1078 this.redeliveryPolicies = redeliveryPolicies; 1079 } 1080 1081 @Override 1082 public List<AbstractCamelFactoryBean<?>> getBeansFactory() { 1083 return beansFactory; 1084 } 1085 1086 /** 1087 * Miscellaneous configurations 1088 */ 1089 public void setBeansFactory(List<AbstractCamelFactoryBean<?>> beansFactory) { 1090 this.beansFactory = beansFactory; 1091 } 1092 1093 @Override 1094 public List<?> getBeans() { 1095 return beans; 1096 } 1097 1098 /** 1099 * Miscellaneous configurations 1100 */ 1101 public void setBeans(List<?> beans) { 1102 this.beans = beans; 1103 } 1104 1105 @Override 1106 public ServiceCallConfigurationDefinition getDefaultServiceCallConfiguration() { 1107 return defaultServiceCallConfiguration; 1108 } 1109 1110 /** 1111 * ServiceCall EIP default configuration 1112 */ 1113 public void setDefaultServiceCallConfiguration(ServiceCallConfigurationDefinition defaultServiceCallConfiguration) { 1114 this.defaultServiceCallConfiguration = defaultServiceCallConfiguration; 1115 } 1116 1117 @Override 1118 public List<ServiceCallConfigurationDefinition> getServiceCallConfigurations() { 1119 return serviceCallConfigurations; 1120 } 1121 1122 /** 1123 * ServiceCall EIP configurations 1124 */ 1125 public void setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> serviceCallConfigurations) { 1126 this.serviceCallConfigurations = serviceCallConfigurations; 1127 } 1128 1129 @Override 1130 public List<HystrixConfigurationDefinition> getHystrixConfigurations() { 1131 return hystrixConfigurations; 1132 } 1133 1134 @Override 1135 public HystrixConfigurationDefinition getDefaultHystrixConfiguration() { 1136 return defaultHystrixConfiguration; 1137 } 1138 1139 /** 1140 * Hystrix EIP default configuration 1141 */ 1142 public void setDefaultHystrixConfiguration(HystrixConfigurationDefinition defaultHystrixConfiguration) { 1143 this.defaultHystrixConfiguration = defaultHystrixConfiguration; 1144 } 1145 1146 /** 1147 * Hystrix EIP configurations 1148 */ 1149 public void setHystrixConfigurations(List<HystrixConfigurationDefinition> hystrixConfigurations) { 1150 this.hystrixConfigurations = hystrixConfigurations; 1151 } 1152 1153 /** 1154 * Configuration of error handlers that triggers on exceptions thrown. 1155 */ 1156 public void setOnExceptions(List<OnExceptionDefinition> onExceptions) { 1157 this.onExceptions = onExceptions; 1158 } 1159 1160 @Override 1161 public List<OnExceptionDefinition> getOnExceptions() { 1162 return onExceptions; 1163 } 1164 1165 @Override 1166 public List<OnCompletionDefinition> getOnCompletions() { 1167 return onCompletions; 1168 } 1169 1170 /** 1171 * Configuration of sub routes to run at the completion of routing. 1172 */ 1173 public void setOnCompletions(List<OnCompletionDefinition> onCompletions) { 1174 this.onCompletions = onCompletions; 1175 } 1176 1177 @Override 1178 public ShutdownRoute getShutdownRoute() { 1179 return shutdownRoute; 1180 } 1181 1182 /** 1183 * Sets the ShutdownRoute option for routes. 1184 */ 1185 public void setShutdownRoute(ShutdownRoute shutdownRoute) { 1186 this.shutdownRoute = shutdownRoute; 1187 } 1188 1189 @Override 1190 public ShutdownRunningTask getShutdownRunningTask() { 1191 return shutdownRunningTask; 1192 } 1193 1194 /** 1195 * Sets the ShutdownRunningTask option to use when shutting down a route. 1196 */ 1197 public void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask) { 1198 this.shutdownRunningTask = shutdownRunningTask; 1199 } 1200 1201 @Override 1202 public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() { 1203 return threadPoolProfiles; 1204 } 1205 1206 /** 1207 * Configuration of thread pool profiles. 1208 */ 1209 public void setThreadPoolProfiles(List<ThreadPoolProfileDefinition> threadPoolProfiles) { 1210 this.threadPoolProfiles = threadPoolProfiles; 1211 } 1212 1213 public List<CamelThreadPoolFactoryBean> getThreadPools() { 1214 return threadPools; 1215 } 1216 1217 /** 1218 * Configuration of thread pool 1219 */ 1220 public void setThreadPools(List<CamelThreadPoolFactoryBean> threadPools) { 1221 this.threadPools = threadPools; 1222 } 1223 1224 @Override 1225 public String getDependsOn() { 1226 return dependsOn; 1227 } 1228 1229 /** 1230 * List of other bean id's this CamelContext depends up. Multiple bean id's can be separated by comma. 1231 */ 1232 public void setDependsOn(String dependsOn) { 1233 this.dependsOn = dependsOn; 1234 } 1235 1236 public boolean isImplicitId() { 1237 return implicitId; 1238 } 1239 1240 public void setImplicitId(boolean flag) { 1241 implicitId = flag; 1242 } 1243}