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