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


Java YamlPropertiesFactoryBean.getObject方法代码示例

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


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

示例1: graviteeProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
@Bean(name = "graviteeProperties")
public static Properties graviteeProperties() throws IOException {
    LOGGER.info("Loading configuration.");

    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();

    String yamlConfiguration = System.getProperty(GRAVITEE_CONFIGURATION);
    Resource yamlResource = new FileSystemResource(yamlConfiguration);

    LOGGER.info("\tConfiguration loaded from {}", yamlResource.getURL().getPath());

    yaml.setResources(yamlResource);
    Properties properties = yaml.getObject();
    LOGGER.info("Loading configuration. DONE");

    return properties;
}
 
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:18,代码来源:PropertiesConfiguration.java

示例2: graviteeProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
@Bean(name = "graviteeProperties")
public static Properties graviteeProperties() throws IOException {
    LOGGER.info("Loading Gravitee Management configuration.");

    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();

    String yamlConfiguration = System.getProperty(GRAVITEE_CONFIGURATION);
    Resource yamlResource = new FileSystemResource(yamlConfiguration);

    LOGGER.info("\tGravitee Management configuration loaded from {}", yamlResource.getURL().getPath());

    yaml.setResources(yamlResource);
    Properties properties = yaml.getObject();
    LOGGER.info("Loading Gravitee Management configuration. DONE");

    return properties;
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:18,代码来源:PropertiesConfiguration.java

示例3: graviteeProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
@Bean(name = "graviteeProperties")
public static Properties graviteeProperties() throws IOException {
    LOGGER.info("Loading Gravitee configuration.");

    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();

    String yamlConfiguration = System.getProperty(GRAVITEE_CONFIGURATION);
    Resource yamlResource = new FileSystemResource(yamlConfiguration);

    LOGGER.info("\tGravitee configuration loaded from {}", yamlResource.getURL().getPath());

    yaml.setResources(yamlResource);
    Properties properties = yaml.getObject();
    LOGGER.info("Loading Gravitee configuration. DONE");

    return properties;
}
 
开发者ID:gravitee-io,项目名称:gravitee-gateway,代码行数:18,代码来源:PropertiesConfiguration.java

示例4: generateProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
protected Properties generateProperties(String value,
		ConsulConfigProperties.Format format) {
	final Properties props = new Properties();

	if (format == PROPERTIES) {
		try {
			// Must use the ISO-8859-1 encoding because Properties.load(stream)
			// expects it.
			props.load(new ByteArrayInputStream(value.getBytes("ISO-8859-1")));
		}
		catch (IOException e) {
			throw new IllegalArgumentException(value
					+ " can't be encoded using ISO-8859-1");
		}

		return props;
	}
	else if (format == YAML) {
		final YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
		yaml.setResources(new ByteArrayResource(value.getBytes()));

		return yaml.getObject();
	}

	return props;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:27,代码来源:ConsulPropertySource.java

示例5: loadYamlProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
private static Map<Object, Object> loadYamlProperties(final Resource... resource) {
    final YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE);
    factory.setResources(resource);
    factory.setSingleton(true);
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:9,代码来源:CasCoreBootstrapStandaloneConfiguration.java

示例6: readProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
/**
 * Load application.yml from classpath.
 */
private static Properties readProperties() {
    try {
        YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
        factory.setResources(new ClassPathResource("config/application.yml"));
        return factory.getObject();
    } catch (Exception e) {
        log.error("Failed to read application.yml to get default profile");
        return null;
    }
}
 
开发者ID:mraible,项目名称:devoxxus-jhipster-microservices-demo,代码行数:14,代码来源:DefaultProfileUtil.java

示例7: contributeDefaults

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
private static void contributeDefaults(Map<String, Object> defaults, Resource resource) {
	if (resource.exists()) {
		YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
		yamlPropertiesFactoryBean.setResources(resource);
		yamlPropertiesFactoryBean.afterPropertiesSet();
		Properties p = yamlPropertiesFactoryBean.getObject();
		for (Object k : p.keySet()) {
			String key = k.toString();
			defaults.put(key, p.get(key));
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:13,代码来源:DefaultEnvironmentPostProcessor.java

示例8: readProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
/**
 * Load application.yml from classpath.
 */
private static Properties readProperties() {
    try {
        YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
        factory.setResources(new ClassPathResource("config/application.yml"));
        return factory.getObject();
    } catch (Exception e) {
        log.error("Failed to read application.yml to get default profile");
    }
    return null;
}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:14,代码来源:DefaultProfileUtil.java

示例9: readProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
/**
 * Load application.yml from classpath.
 *
 * @return the YAML Properties
 */
private static Properties readProperties() {
    try {
        YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
        factory.setResources(new ClassPathResource("config/application.yml"));
        return factory.getObject();
    } catch (Exception e) {
        log.error("Failed to read application.yml to get default profile");
    }
    return null;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:16,代码来源:DefaultProfileUtil.java

示例10: convertYamlToProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
public static Properties convertYamlToProperties(String yamlFile) {
	
	YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
	yamlPropertiesFactoryBean.setResources(new ClassPathResource(yamlFile));
	yamlPropertiesFactoryBean.setResolutionMethod(ResolutionMethod.FIRST_FOUND);
	
	return yamlPropertiesFactoryBean.getObject();
}
 
开发者ID:colddew,项目名称:micro-service-netflix,代码行数:9,代码来源:YamlUtils.java

示例11: getDeploymentProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
protected Map<String, String> getDeploymentProperties(@CliOption(key = {
		PROPERTIES_OPTION }, help = "the properties for this deployment") String deploymentProperties,
		@CliOption(key = {
				PROPERTIES_FILE_OPTION }, help = "the properties for this deployment (as a File)") File propertiesFile,
		int which) throws IOException {
	Map<String, String> propertiesToUse;
	switch (which) {
	case 0:
		propertiesToUse = DeploymentPropertiesUtils.parse(deploymentProperties);
		break;
	case 1:
		String extension = FilenameUtils.getExtension(propertiesFile.getName());
		Properties props = null;
		if (extension.equals("yaml") || extension.equals("yml")) {
			YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
			yamlPropertiesFactoryBean.setResources(new FileSystemResource(propertiesFile));
			yamlPropertiesFactoryBean.afterPropertiesSet();
			props = yamlPropertiesFactoryBean.getObject();
		}
		else {
			props = new Properties();
			try (FileInputStream fis = new FileInputStream(propertiesFile)) {
				props.load(fis);
			}
		}
		propertiesToUse = DeploymentPropertiesUtils.convert(props);
		break;
	case -1: // Neither option specified
		propertiesToUse = new HashMap<>(1);
		break;
	default:
		throw new AssertionError();
	}
	return propertiesToUse;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:36,代码来源:AbstractStreamCommands.java

示例12: findOne

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
@Override
public Environment findOne(String application, String profile, String label) {

	String state = request.getHeader(STATE_HEADER);
	String newState = this.watch.watch(state);

	String[] profiles = StringUtils.commaDelimitedListToStringArray(profile);
	List<String> scrubbedProfiles = scrubProfiles(profiles);

	List<String> keys = findKeys(application, scrubbedProfiles);

	Environment environment = new Environment(application, profiles, label, null, newState);

	for (String key : keys) {
		// read raw 'data' key from vault
		String data = read(key);
		if (data != null) {
			// data is in json format of which, yaml is a superset, so parse
			final YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
			yaml.setResources(new ByteArrayResource(data.getBytes()));
			Properties properties = yaml.getObject();

			if (!properties.isEmpty()) {
				environment.add(new PropertySource("vault:" + key, properties));
			}
		}
	}

	return environment;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:31,代码来源:VaultEnvironmentRepository.java

示例13: getPropertiesFromApplicationYml

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
public static Properties getPropertiesFromApplicationYml() {
    YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
    yamlPropertiesFactoryBean.setResources(new ClassPathResource("application.yml"));
    return yamlPropertiesFactoryBean.getObject();
}
 
开发者ID:sw360,项目名称:sw360rest,代码行数:6,代码来源:AccessTokenPrinter.java

示例14: before

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
@Override
protected void before() throws Throwable {
	try {
		String awsCredentialsDir = System.getProperty("aws.credentials.path");
		File awsCredentialsFile = new File(awsCredentialsDir, "aws.credentials.properties");
		Properties awsCredentials = new Properties();
		awsCredentials.load(new FileReader(awsCredentialsFile));
		String accessKey = awsCredentials.getProperty("cloud.aws.credentials.accessKey");
		String secretKey = awsCredentials.getProperty("cloud.aws.credentials.secretKey");
		this.cloudFormation = new AmazonCloudFormationClient(new BasicAWSCredentials(accessKey, secretKey));

		YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
		yamlPropertiesFactoryBean.setResources(new ClassPathResource("application.yml"));
		Properties applicationProperties = yamlPropertiesFactoryBean.getObject();

		this.stackName = applicationProperties.getProperty("cloud.aws.stack.name");

		after();

		ClassPathResource stackTemplate = new ClassPathResource("AwsIntegrationTestTemplate.json");
		String templateBody = FileCopyUtils.copyToString(new InputStreamReader(stackTemplate.getInputStream()));

		this.cloudFormation.createStack(
				new CreateStackRequest()
						.withTemplateBody(templateBody)
						.withOnFailure(OnFailure.DELETE)
						.withStackName(this.stackName));

		waitForCompletion();

		System.setProperty("cloud.aws.credentials.accessKey", accessKey);
		System.setProperty("cloud.aws.credentials.secretKey", secretKey);
	}
	catch (Exception e) {
		if (!(e instanceof AssumptionViolatedException)) {
			Assume.assumeTrue("Can't perform AWS integration test because of: " + e.getMessage(), false);
		}
		else {
			throw e;
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:43,代码来源:AwsIntegrationTestStackRule.java

示例15: secretProperties

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; //导入方法依赖的package包/类
public static Properties secretProperties(String profile) {
    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
    yaml.setResources(new ClassPathResource("config/application-" + profile + "-secret.yml"));
    yaml.afterPropertiesSet();
    return yaml.getObject();
}
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:7,代码来源:ArgumentResolver.java


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