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


Java PropertyResolver类代码示例

本文整理汇总了Java中org.springframework.core.env.PropertyResolver的典型用法代码示例。如果您正苦于以下问题:Java PropertyResolver类的具体用法?Java PropertyResolver怎么用?Java PropertyResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isTemplateAvailable

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
                                   ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment,
                "spring.velocity.");
        String loaderPath = resolver.getProperty("resource-loader-path",
                VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
        String prefix = resolver.getProperty("prefix",
                VelocityProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix",
                VelocityProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(loaderPath + prefix + view + suffix)
                             .exists();
    }
    return false;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:18,代码来源:VelocityTemplateAvailabilityProvider.java

示例2: createConfigBean

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
/**
 * 创建配置Bean
 *
 * @param propertyName               属性名
 * @param beanType                   配置Bean类型
 * @param converterType              转换器类型
 * @param configBeanPropertyResolver 属性解析器
 * @param conversionService          转换服务
 * @param <T>
 * @return
 */
public static <T> T createConfigBean(String propertyName, Class<T> beanType,
                                     Class<? extends ConfigBeanConverter> converterType,
                                     ConfigPropertyResolver configBeanPropertyResolver,
                                     ConfigBeanConversionService conversionService) {

    PropertyResolver propertyResolver = configBeanPropertyResolver.getObject();
    String propertyValue = propertyResolver.getRequiredProperty(propertyName);

    if (converterType != null && !converterType.isInterface()) {
        ConfigBeanConverter converter = BeanUtils.instantiate(converterType);
        return (T) converter.convert(propertyName, propertyValue, TypeDescriptor.valueOf(beanType));

    } else {
        return (T) conversionService.convert(propertyName, propertyValue, TypeDescriptor.valueOf(beanType));
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:28,代码来源:ConfigBeanFactory.java

示例3: RedisDatastore

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
public RedisDatastore(MappingContext mappingContext, PropertyResolver configuration,
            ConfigurableApplicationContext ctx) {
    super(mappingContext, configuration, ctx);

    int resourceCount = 10;
    if (configuration != null) {
        host = configuration.getProperty(CONFIG_HOST, DEFAULT_HOST);
        port = configuration.getProperty(CONFIG_PORT, Integer.class, DEFAULT_PORT);
        timeout = configuration.getProperty(CONFIG_TIMEOUT, Integer.class, 2000);
        pooled = configuration.getProperty(CONFIG_POOLED, Boolean.class, true);
        password = configuration.getProperty(CONFIG_PASSWORD, (String)null);
        resourceCount = configuration.getProperty(CONFIG_RESOURCE_COUNT, Integer.class, resourceCount);
    }
    if (pooled && useJedis()) {
        this.pool = JedisTemplateFactory.createPool(host, port, timeout, resourceCount, password);
    }

    initializeConverters(mappingContext);
}
 
开发者ID:grails,项目名称:gorm-redis,代码行数:20,代码来源:RedisDatastore.java

示例4: printBanner

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
		PrintStream out) {
	try {
		String banner = StreamUtils.copyToString(this.resource.getInputStream(),
				environment.getProperty("banner.charset", Charset.class,
						Charset.forName("UTF-8")));

		for (PropertyResolver resolver : getPropertyResolvers(environment,
				sourceClass)) {
			banner = resolver.resolvePlaceholders(banner);
		}
		out.println(banner);
	}
	catch (Exception ex) {
		logger.warn("Banner not printable: " + this.resource + " (" + ex.getClass()
				+ ": '" + ex.getMessage() + "')", ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:ResourceBanner.java

示例5: isTemplateAvailable

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
		ClassLoader classLoader, ResourceLoader resourceLoader) {
	if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
		PropertyResolver resolver = new RelaxedPropertyResolver(environment,
				"spring.velocity.");
		String loaderPath = resolver.getProperty("resource-loader-path",
				VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
		String prefix = resolver.getProperty("prefix",
				VelocityProperties.DEFAULT_PREFIX);
		String suffix = resolver.getProperty("suffix",
				VelocityProperties.DEFAULT_SUFFIX);
		return resourceLoader.getResource(loaderPath + prefix + view + suffix)
				.exists();
	}
	return false;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:VelocityTemplateAvailabilityProvider.java

示例6: getTestInstance

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
/**
 * Gets a test instance of this class that uses only the given mapping.
 *
 * @param instanceTypes       map of virtualization types to instance types
 * @param localizationContext the localization context
 * @return new mapping object
 */
public static VirtualizationMappings getTestInstance(
    final Map<String, List<String>> instanceTypes, LocalizationContext localizationContext) {
  Map<String, String> propertyMap =
      Maps.transformValues(instanceTypes,
          new Function<List<String>, String>() {
            @Override
            public String apply(@Nonnull List<String> input) {
              return JOINER.join(input);
            }
          });
  PropertyResolver virtualizationMappingsResolver =
      PropertyResolvers.newMapPropertyResolver(propertyMap);
  File tempDir = Files.createTempDir();
  tempDir.deleteOnExit();
  VirtualizationMappingsConfigProperties virtualizationMappingsConfigProperties =
      new VirtualizationMappingsConfigProperties(new SimpleConfiguration(),
          tempDir, localizationContext);
  return new VirtualizationMappings(virtualizationMappingsConfigProperties,
      virtualizationMappingsResolver);
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:28,代码来源:VirtualizationMappings.java

示例7: getTestInstance

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
/**
 * Gets a test instance of this class that uses only the given encryption
 * instance classes.
 *
 * @param encryptionInstanceClasses list of instance classes that support storage encryption
 * @param localizationContext the localization context
 * @return new encryption instance classes object
 */
public static RDSEncryptionInstanceClasses getTestInstance(
    final List<String> encryptionInstanceClasses, LocalizationContext localizationContext) {
  Map<String, String> encryptionInstanceClassesMap = Maps.newHashMap();
  for (String instanceClass : encryptionInstanceClasses) {
    encryptionInstanceClassesMap.put(instanceClass, "true");
  }
  PropertyResolver resolver =
      PropertyResolvers.newMapPropertyResolver(encryptionInstanceClassesMap);

  File tempDir = Files.createTempDir();
  tempDir.deleteOnExit();

  RDSEncryptionInstanceClassesConfigProperties configProperties =
      new RDSEncryptionInstanceClassesConfigProperties(new SimpleConfiguration(), tempDir,
                                                       localizationContext);
  return new RDSEncryptionInstanceClasses(configProperties, resolver);
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:26,代码来源:RDSEncryptionInstanceClasses.java

示例8: newMultiResourcePropertyResolver

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
/**
 * Creates a property resolver that pulls from multiple property resource
 * locations. The first "built-in" location must be successfully loaded, but
 * all other "custom" locations must load only if {code}allowMissing{code} is
 * false.
 *
 * @param allowMissing            true to allow custom resource locations to fail to load
 * @param builtInResourceLocation lowest precedence, required resource
 *                                location for properties
 * @param customResourceLocations additional resource locations for
 *                                properties, in increasing order of precedence
 * @return new property resolver
 * @throws IOException          if the built-in resource location could not be loaded,
 *                              or if {code}allowMissing{code} is false and any custom resource location
 *                              fails to load
 * @throws NullPointerException if any resource location is null
 */
public static PropertyResolver newMultiResourcePropertyResolver(boolean allowMissing,
    String builtInResourceLocation,
    String... customResourceLocations)
    throws IOException {
  MutablePropertySources sources = new MutablePropertySources();
  checkNotNull(builtInResourceLocation, "builtInResourceLocation is null");
  sources.addLast(buildPropertySource(BUILT_IN_NAME, builtInResourceLocation,
      false));
  String lastname = BUILT_IN_NAME;
  int customCtr = 1;
  for (String loc : customResourceLocations) {
    checkNotNull(loc, "customResourceLocations[" + (customCtr - 1) +
        "] is null");
    String thisname = CUSTOM_NAME_PREFIX + customCtr++;
    PropertySource source = buildPropertySource(thisname, loc, allowMissing);
    if (source != null) {
      sources.addBefore(lastname, source);
      lastname = thisname;
    }
  }

  return new PropertySourcesPropertyResolver(sources);
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:41,代码来源:PropertyResolvers.java

示例9: testDispatcher

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Test
public void testDispatcher() {
    Map<String, Object> properties = newHashMap();
    properties.put("check.targetTypes", "test.TestFirst,test.TestSecond");
    properties.put("check.TestFirst", "checkType");
    properties.put("check.TestSecond", "checkBoundaries");
    PropertyResolver propResolver = makePropertyResolver(properties);
    TypeBasedMatcherDispatcher<AnnotationFS> actualMatcher =
            new MatchingConfigurationInitializer(ts, propResolver).create();

    Type firstType = ts.getType("test.TestFirst");
    Type secondType = ts.getType("test.TestSecond");
    Builder<AnnotationFS> expectedBuilder = TypeBasedMatcherDispatcher.builder(ts);
    expectedBuilder.addSubmatcher(firstType,
            CompositeMatcher.builderForAnnotation(firstType).addTypeChecker().build());
    expectedBuilder.addSubmatcher(secondType,
            CompositeMatcher.builderForAnnotation(secondType).addBoundaryMatcher().build());

    assertMatchersEqual(expectedBuilder.build(), actualMatcher);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:21,代码来源:MatchingConfigurationInitializerTest.java

示例10: printBanner

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
		PrintStream out) {
	try {
		String banner = StreamUtils.copyToString(this.resource.getInputStream(),
				environment.getProperty("banner.charset", Charset.class,
						Charset.forName("UTF-8")));

		for (PropertyResolver resolver : getPropertyResolvers(environment,
				sourceClass)) {
			banner = resolver.resolvePlaceholders(banner);
		}
		out.println(banner);
	}
	catch (Exception ex) {
		log.warn("Banner not printable: " + this.resource + " (" + ex.getClass()
				+ ": '" + ex.getMessage() + "')", ex);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:20,代码来源:ResourceBanner.java

示例11: resolvePlaceholders

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
public static String resolvePlaceholders(Object applicationContext, String value, boolean throwIfNotResolved){
	String newValue = value;
	if (StringUtils.hasText(value) && DOLOR.isExpresstion(value)){
		if(applicationContext instanceof ConfigurableApplicationContext){
			ConfigurableApplicationContext appcontext = (ConfigurableApplicationContext)applicationContext;
			newValue = appcontext.getEnvironment().resolvePlaceholders(value);
		}else if(applicationContext instanceof PropertyResolver){
			PropertyResolver env = (PropertyResolver)applicationContext;
			newValue = env.resolvePlaceholders(value);
		}
		if(DOLOR.isExpresstion(newValue) && throwIfNotResolved){
			throw new BaseException("can not resolve placeholders value: " + value + ", resovled value: " + newValue);
		}
	}
	return newValue;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:17,代码来源:SpringUtils.java

示例12: sendPendingEmail

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Subscribe
public void sendPendingEmail(UserJoinedEvent userJoinedEvent) throws SignatureException {
  log.info("Sending pending review email: {}", userJoinedEvent.getPersistable());
  PropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "registration.");
  List<User> administrators = userRepository.findByRole("agate-administrator");
  Context ctx = new Context();
  User user = userJoinedEvent.getPersistable();
  String organization = configurationService.getConfiguration().getName();
  ctx.setLocale(LocaleUtils.toLocale(user.getPreferredLanguage()));
  ctx.setVariable("user", user);
  ctx.setVariable("organization", organization);
  ctx.setVariable("publicUrl", configurationService.getPublicUrl());

  administrators.stream().forEach(u -> mailService
    .sendEmail(u.getEmail(), "[" + organization + "] " + propertyResolver.getProperty("pendingForReviewSubject"),
      templateEngine.process("pendingForReviewEmail", ctx)));

  mailService
    .sendEmail(user.getEmail(), "[" + organization + "] " + propertyResolver.getProperty("pendingForApprovalSubject"),
      templateEngine.process("pendingForApprovalEmail", ctx));
}
 
开发者ID:obiba,项目名称:agate,代码行数:22,代码来源:UserService.java

示例13: sendConfirmationEmail

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Subscribe
public void sendConfirmationEmail(UserApprovedEvent userApprovedEvent) throws SignatureException {
  log.info("Sending confirmation email: {}", userApprovedEvent.getPersistable());
  PropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "registration.");
  Context ctx = new Context();
  User user = userApprovedEvent.getPersistable();
  String organization = configurationService.getConfiguration().getName();
  ctx.setLocale(LocaleUtils.toLocale(user.getPreferredLanguage()));
  ctx.setVariable("user", user);
  ctx.setVariable("organization", organization);
  ctx.setVariable("publicUrl", configurationService.getPublicUrl());
  ctx.setVariable("key", configurationService.encrypt(user.getName()));

  mailService
    .sendEmail(user.getEmail(), "[" + organization + "] " + propertyResolver.getProperty("confirmationSubject"),
      templateEngine.process("confirmationEmail", ctx));
}
 
开发者ID:obiba,项目名称:agate,代码行数:18,代码来源:UserService.java

示例14: verify

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
public boolean verify(String reCaptchaResponse) {
  PropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "recaptcha.");

  MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
  map.add("secret", propertyResolver.getProperty("secret"));
  map.add("response", reCaptchaResponse);

  ReCaptchaVerifyResponse recaptchaVerifyResponse = restTemplate
    .postForObject(propertyResolver.getProperty("verifyUrl"), map, ReCaptchaVerifyResponse.class);

  if(!recaptchaVerifyResponse.isSuccess() && (recaptchaVerifyResponse.getErrorCodes().contains("invalid-input-secret") ||
    recaptchaVerifyResponse.getErrorCodes().contains("missing-input-secret"))) {
    log.error("Error verifying recaptcha: " + reCaptchaResponse);
    throw new RuntimeException("Error verifying recaptcha.");
  }

  return recaptchaVerifyResponse.isSuccess();
}
 
开发者ID:obiba,项目名称:agate,代码行数:19,代码来源:ReCaptchaService.java

示例15: wroManagerFactory

import org.springframework.core.env.PropertyResolver; //导入依赖的package包/类
@Bean
public WroManagerFactory wroManagerFactory(WroModelFactory wroModelFactory, PropertyResolver propertyResolver) {
    ConfigurableWroManagerFactory factory = new ConfigurableWroManagerFactory();
    factory.setModelFactory(wroModelFactory);
    factory.setUriLocatorFactory(new MidPointUrlLocatorFactory(propertyResolver));

    SimpleProcessorsFactory processors = new SimpleProcessorsFactory();
    Collection<ResourcePreProcessor> preProcessors = new ArrayList<>();
    preProcessors.add(new CssUrlRewritingProcessor());
    preProcessors.add(new CssImportPreProcessor());
    preProcessors.add(new SemicolonAppenderPreProcessor());

    Collection<ResourcePostProcessor> postProcessors = new ArrayList<>();
    postProcessors.add(new Less4jProcessor());

    processors.setResourcePreProcessors(preProcessors);
    processors.setResourcePostProcessors(postProcessors);

    factory.setProcessorsFactory(processors);

    return factory;
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:23,代码来源:Wro4jConfig.java


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