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