当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesComponent.setSuffixToken方法代码示例

本文整理汇总了Java中org.apache.camel.component.properties.PropertiesComponent.setSuffixToken方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesComponent.setSuffixToken方法的具体用法?Java PropertiesComponent.setSuffixToken怎么用?Java PropertiesComponent.setSuffixToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.component.properties.PropertiesComponent的用法示例。


在下文中一共展示了PropertiesComponent.setSuffixToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initPropertyPlaceholder

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
protected void initPropertyPlaceholder() throws Exception {
    if (getCamelPropertyPlaceholder() != null) {
        CamelPropertyPlaceholderDefinition def = getCamelPropertyPlaceholder();

        PropertiesComponent pc = new PropertiesComponent();
        pc.setLocation(def.getLocation());
        pc.setEncoding(def.getEncoding());

        if (def.isCache() != null) {
            pc.setCache(def.isCache());
        }

        if (def.isIgnoreMissingLocation() != null) {
            pc.setIgnoreMissingLocation(def.isIgnoreMissingLocation());
        }

        // if using a custom resolver
        if (ObjectHelper.isNotEmpty(def.getPropertiesResolverRef())) {
            PropertiesResolver resolver = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesResolverRef(),
                                                                             PropertiesResolver.class);
            pc.setPropertiesResolver(resolver);
        }

        // if using a custom parser
        if (ObjectHelper.isNotEmpty(def.getPropertiesParserRef())) {
            PropertiesParser parser = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesParserRef(),
                                                                         PropertiesParser.class);
            pc.setPropertiesParser(parser);
        }
        
        pc.setPropertyPrefix(def.getPropertyPrefix());
        pc.setPropertySuffix(def.getPropertySuffix());
        
        if (def.isFallbackToUnaugmentedProperty() != null) {
            pc.setFallbackToUnaugmentedProperty(def.isFallbackToUnaugmentedProperty());
        }
        
        pc.setPrefixToken(def.getPrefixToken());
        pc.setSuffixToken(def.getSuffixToken());

        if (def.getFunctions() != null && !def.getFunctions().isEmpty()) {
            for (CamelPropertyPlaceholderFunctionDefinition function : def.getFunctions()) {
                String ref = function.getRef();
                PropertiesFunction pf = CamelContextHelper.mandatoryLookup(getContext(), ref, PropertiesFunction.class);
                pc.addFunction(pf);
            }
        }

        // register the properties component
        getContext().addComponent("properties", pc);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:53,代码来源:AbstractCamelContextFactoryBean.java

示例2: configure

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Override
public void configure(final Env env, final Config config, final Binder binder) throws Throwable {
  Config $camel = config.getConfig("camel");
  DefaultCamelContext ctx = configure(new DefaultCamelContext(), $camel
      .withoutPath("shutdown")
      .withoutPath("threads")
      .withoutPath("jmx")
      .withoutPath("streamCaching"));

  if (!$camel.getBoolean("jmx")) {
    ctx.disableJMX();
  }

  /**
   * Executor and thread poll
   */
  ThreadPoolProfile threadPool = configure(new ThreadPoolProfile(), $camel.getConfig("threads"));
  ctx.getExecutorServiceManager().setDefaultThreadPoolProfile(threadPool);

  /**
   * Shutdown options.
   */
  configure(ctx.getShutdownStrategy(), $camel.getConfig("shutdown"));

  if ($camel.getBoolean("streamCaching.enabled")) {
    ctx.setStreamCaching(true);
    configure(ctx.getStreamCachingStrategy(), $camel.getConfig("streamCaching"));
  } else {
    ctx.setStreamCaching(false);
  }

  /**
   * Components etc..
   */
  if (configurer != null) {
    configurer.configure(ctx, config);
  }

  /**
   * Routes
   */
  if (routes != null) {
    routes(routes, ctx, config);
  }

  /**
   * Properties
   */
  PropertiesComponent properties = new PropertiesComponent(config.root().origin().description());
  properties.setIgnoreMissingLocation(true);
  properties.setPropertiesResolver((context, ignoreMissingLocation, location) -> {
    Properties props = new Properties();
    config.entrySet()
        .forEach(e -> props.setProperty(e.getKey(), e.getValue().unwrapped().toString()));
    return props;
  });
  properties.setPrefixToken("${");
  properties.setSuffixToken("}");
  ctx.addComponent("properties", properties);

  env.lifeCycle(CamelFinalizer.class);

  /**
   * Guice!
   */
  binder.bind(CamelContext.class).toInstance(ctx);
  binder.bind(DefaultCamelContext.class).toInstance(ctx);
  binder.bind(ProducerTemplate.class).toInstance(ctx.createProducerTemplate());
  binder.bind(FluentProducerTemplate.class).toInstance(ctx.createFluentProducerTemplate());
  binder.bind(ConsumerTemplate.class).toInstance(ctx.createConsumerTemplate());

  binder.bind(CamelFinalizer.class).asEagerSingleton();

  binder.bind(RouteBuilder.class).toInstance(rb());

  Multibinder<Object> routesBinder = Multibinder
      .newSetBinder(binder, Object.class, Names.named("camel.routes"));

  routeList.forEach(routeType -> routesBinder.addBinding().to(routeType));
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:81,代码来源:Camel.java


注:本文中的org.apache.camel.component.properties.PropertiesComponent.setSuffixToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。