예제 #1
0
  private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {
    AggregationStrategy strategy = getAggregationStrategy();
    if (strategy == null && aggregationStrategyRef != null) {
      Object aggStrategy = routeContext.lookup(aggregationStrategyRef, Object.class);
      if (aggStrategy instanceof AggregationStrategy) {
        strategy = (AggregationStrategy) aggStrategy;
      } else if (aggStrategy != null) {
        AggregationStrategyBeanAdapter adapter =
            new AggregationStrategyBeanAdapter(aggStrategy, getAggregationStrategyMethodName());
        if (getAggregationStrategyMethodAllowNull() != null) {
          adapter.setAllowNullNewExchange(getAggregationStrategyMethodAllowNull());
          adapter.setAllowNullOldExchange(getAggregationStrategyMethodAllowNull());
        }
        strategy = adapter;
      } else {
        throw new IllegalArgumentException(
            "Cannot find AggregationStrategy in Registry with name: " + aggregationStrategyRef);
      }
    }

    if (strategy != null && strategy instanceof CamelContextAware) {
      ((CamelContextAware) strategy).setCamelContext(routeContext.getCamelContext());
    }

    return strategy;
  }
예제 #2
0
 @Override
 protected void doStart() throws Exception {
   // inject CamelContext before starting
   if (jsonMarshal instanceof CamelContextAware) {
     ((CamelContextAware) jsonMarshal).setCamelContext(camelContext);
   }
   if (jsonUnmarshal instanceof CamelContextAware) {
     ((CamelContextAware) jsonUnmarshal).setCamelContext(camelContext);
   }
   if (xmlMarshal instanceof CamelContextAware) {
     ((CamelContextAware) xmlMarshal).setCamelContext(camelContext);
   }
   if (xmlUnmarshal instanceof CamelContextAware) {
     ((CamelContextAware) xmlUnmarshal).setCamelContext(camelContext);
   }
   ServiceHelper.startServices(jsonMarshal, jsonUnmarshal, xmlMarshal, xmlUnmarshal);
 }
 public Object beforeInit(
     Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanMetadata) {
   injectFields(bean, beanName);
   injectMethods(bean, beanName);
   if (bean instanceof CamelContextAware) {
     ((CamelContextAware) bean).setCamelContext(getCamelContext());
   }
   return bean;
 }
 @Bean(name = "pgp-dataformat")
 @Scope("prototype")
 @ConditionalOnClass(CamelContext.class)
 @ConditionalOnMissingBean(PGPDataFormat.class)
 public PGPDataFormat configurePGPDataFormat(
     CamelContext camelContext, PGPDataFormatConfiguration configuration) throws Exception {
   PGPDataFormat dataformat = new PGPDataFormat();
   if (CamelContextAware.class.isAssignableFrom(PGPDataFormat.class)) {
     CamelContextAware contextAware = CamelContextAware.class.cast(dataformat);
     if (contextAware != null) {
       contextAware.setCamelContext(camelContext);
     }
   }
   Map<String, Object> parameters = new HashMap<>();
   IntrospectionSupport.getProperties(configuration, parameters, null, false);
   IntrospectionSupport.setProperties(
       camelContext, camelContext.getTypeConverter(), dataformat, parameters);
   return dataformat;
 }
 @Bean(name = "ognl-language")
 @Scope("prototype")
 @ConditionalOnClass(CamelContext.class)
 @ConditionalOnMissingBean(OgnlLanguage.class)
 public OgnlLanguage configureOgnlLanguage(
     CamelContext camelContext, OgnlLanguageConfiguration configuration) throws Exception {
   OgnlLanguage language = new OgnlLanguage();
   if (CamelContextAware.class.isAssignableFrom(OgnlLanguage.class)) {
     CamelContextAware contextAware = CamelContextAware.class.cast(language);
     if (contextAware != null) {
       contextAware.setCamelContext(camelContext);
     }
   }
   Map<String, Object> parameters = new HashMap<>();
   IntrospectionSupport.getProperties(configuration, parameters, null, false);
   IntrospectionSupport.setProperties(
       camelContext, camelContext.getTypeConverter(), language, parameters);
   return language;
 }
 @Bean
 @ConditionalOnClass(CamelContext.class)
 @ConditionalOnMissingBean(GsonDataFormat.class)
 public GsonDataFormat configureGsonDataFormat(
     CamelContext camelContext, GsonDataFormatConfiguration configuration) throws Exception {
   GsonDataFormat dataformat = new GsonDataFormat();
   if (dataformat instanceof CamelContextAware) {
     ((CamelContextAware) dataformat).setCamelContext(camelContext);
   }
   Map<String, Object> parameters = new HashMap<>();
   IntrospectionSupport.getProperties(configuration, parameters, null, false);
   IntrospectionSupport.setProperties(
       camelContext, camelContext.getTypeConverter(), dataformat, parameters);
   return dataformat;
 }
 @Bean(name = "jsonpath-language")
 @ConditionalOnClass(CamelContext.class)
 @ConditionalOnMissingBean(JsonPathLanguage.class)
 public JsonPathLanguage configureJsonPathLanguage(
     CamelContext camelContext, JsonPathLanguageConfiguration configuration) throws Exception {
   JsonPathLanguage language = new JsonPathLanguage();
   if (language instanceof CamelContextAware) {
     ((CamelContextAware) language).setCamelContext(camelContext);
   }
   Map<String, Object> parameters = new HashMap<>();
   IntrospectionSupport.getProperties(configuration, parameters, null, false);
   IntrospectionSupport.setProperties(
       camelContext, camelContext.getTypeConverter(), language, parameters);
   return language;
 }