org.springframework.beans.factory.config.PropertiesFactoryBean#getObject ( )源码实例Demo

下面列出了org.springframework.beans.factory.config.PropertiesFactoryBean#getObject ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: seppb   文件: QuartzConfiguration.java
@Bean
public Properties quartzProperties() throws IOException {
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
	propertiesFactoryBean.afterPropertiesSet();
	Properties result = propertiesFactoryBean.getObject();

	// 从环境信息中剥离出配置好的环境信息,覆盖默认的配置
	String dsName = result.getProperty("org.quartz.jobStore.dataSource");
	if (StringUtils.isEmpty(dsName)) {
		throw new RuntimeException("quartz配置文件错误,org.quartz.jobStore.dataSource不能为空!");
	}
	result.setProperty("org.quartz.dataSource." + dsName + ".URL", jdbcUrl);
	result.setProperty("org.quartz.dataSource." + dsName + ".user", jdbcUserName);
	result.setProperty("org.quartz.dataSource." + dsName + ".password", jdbcPassword);
	return result;
}
 
源代码2 项目: micro-server   文件: PropertyFileConfig.java
@Bean
public Properties propertyFactory() throws IOException {
    List<Resource> resources = loadPropertyResource();
    PropertiesFactoryBean factory = new PropertiesFactoryBean();
    factory.setLocations(resources.toArray(new Resource[resources.size()]));
    factory.afterPropertiesSet();
    Properties props = factory.getObject();

    new ConfigAccessor().get()
                        .getProperties()
                        .stream()
                        .forEach(e -> {
                            if (props.getProperty(e._1()) == null) {
                                props.put(e._1(), e._2());
                            }
                        });

    System.getProperties()
          .entrySet()
          .forEach(e -> props.put(e.getKey(), e.getValue()));

    return props;
}
 
源代码3 项目: micro-server   文件: SSLConfig.java
@Bean
public static SSLProperties sslProperties() throws IOException {
	PropertiesFactoryBean factory = new PropertiesFactoryBean();
	URL url = SSLConfig.class.getClassLoader().getResource("ssl.properties");
	if (url != null) {
		Resource reource = new UrlResource(url);
		factory.setLocation(reource);
		factory.afterPropertiesSet();
		Properties properties = factory.getObject();
		return SSLProperties.builder()
				.keyStoreFile(properties.getProperty(keyStoreFile))
				.keyStorePass(properties.getProperty(keyStorePass))
				.trustStoreFile(properties.getProperty(trustStoreFile))
				.trustStorePass(properties.getProperty(trustStorePass))
				.keyStoreType(properties.getProperty(keyStoreType))
				.keyStoreProvider(properties.getProperty(keyStoreProvider))
				.trustStoreType(properties.getProperty(trustStoreType))
				.trustStoreProvider(properties.getProperty(trustStoreProvider))
				.clientAuth(properties.getProperty(clientAuth))
				.ciphers(properties.getProperty(ciphers))
				.protocol(properties.getProperty(protocol)).build();
	}
	return null;
}
 
源代码4 项目: vividus   文件: ConfigurationResolver.java
private static Properties loadProperties(Resource... propertyResources) throws IOException
{
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setFileEncoding(StandardCharsets.UTF_8.name());
    propertiesFactoryBean.setLocations(propertyResources);
    propertiesFactoryBean.setSingleton(false);
    return propertiesFactoryBean.getObject();
}
 
源代码5 项目: spring-boot-demo   文件: SchedulerConfig.java
/**
 * 加载配置属性
 *
 * @return
 * @throws IOException
 */
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/spring-quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
 
源代码6 项目: pacbot   文件: PacmanQuartzConfiguration.java
@Bean
public Properties quartzProperties() throws IOException {
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
	propertiesFactoryBean.afterPropertiesSet();
	return propertiesFactoryBean.getObject();
}
 
源代码7 项目: zkdoctor   文件: SchedulerConfig.java
/**
 * 初始化quartz配置
 *
 * @return
 * @throws IOException
 */
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
 
源代码8 项目: TAC   文件: SchedulerConfig.java
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    //在quartz.properties中的属性被读取并注入后再初始化对象
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
 
源代码9 项目: yyblog   文件: QuartzConfigration.java
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/config/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
 
源代码10 项目: griffin   文件: PropertiesUtil.java
public static Properties getProperties(String path, Resource resource) {
    PropertiesFactoryBean propFactoryBean = new PropertiesFactoryBean();
    Properties properties = null;
    try {
        propFactoryBean.setLocation(resource);
        propFactoryBean.afterPropertiesSet();
        properties = propFactoryBean.getObject();
        LOGGER.info("Read properties successfully from {}.", path);
    } catch (IOException e) {
        LOGGER.error("Get properties from {} failed. {}", path, e);
    }
    return properties;
}
 
/**
 * Instantiates a new application context state.
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
protected ApplicationContextState(boolean allowInitAccess ) throws IOException
{
    this.allowInitAccess = allowInitAccess;
    // Load the property defaults
    PropertiesFactoryBean factory = new PropertiesFactoryBean();
    factory.setPropertiesPersister(getPersister());
    factory.setLocations(getParent().getResources(
            ChildApplicationContextFactory.CLASSPATH_PREFIX + getCategory() + '/' + getTypeName()
                    + ChildApplicationContextFactory.PROPERTIES_SUFFIX));
    factory.afterPropertiesSet();
    this.properties = (Properties) factory.getObject();
}
 
/**
 * Configure quartz using properties file
 */
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
 
private static Properties loadConfigLocationProperties(ApplicationContext applicationContext, 
		QuartzSchedulerProperties properties) throws IOException {
	
	String location = properties.getPropertiesConfigLocation();
	if(null == location || location.trim().length() == 0) {
		location = QuartzSchedulerProperties.DEFAULT_CONFIG_LOCATION;
		LOGGER.debug("using default 'quartz.properties' from classpath: " + location);
	} else {
		LOGGER.debug("using 'quartz.properties' from location: " + location);
	}
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(applicationContext.getResource(location));
	propertiesFactoryBean.afterPropertiesSet();
	return propertiesFactoryBean.getObject();
}
 
@Bean(name = QuartzSchedulerAutoConfiguration.QUARTZ_PROPERTIES_BEAN_NAME)
public Properties quartzProperties(
		@Autowired ApplicationContext applicationContext,
		@Autowired QuartzSchedulerProperties properties) throws IOException {
	
	System.out.println("my overridden quartz.properties loading");
	
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(applicationContext.getResource("classpath:overriddenQuartzScheduler.properties"));
	propertiesFactoryBean.afterPropertiesSet();
	return propertiesFactoryBean.getObject();
}
 
源代码15 项目: springboot-quartz   文件: SchedulerConfig.java
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
 
源代码16 项目: lemonaid   文件: QuartzConfig.java
@Bean
public Properties quartzProperties() {
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
	Properties properties = null;
	try {
		propertiesFactoryBean.afterPropertiesSet();
		properties = propertiesFactoryBean.getObject();

	} catch (IOException e) {
		log.warn("Cannot load quartz.properties.");
	}

	return properties;
}
 
源代码17 项目: quartz-manager   文件: SchedulerConfig.java
@Bean
public Properties quartzProperties() throws IOException {
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
	propertiesFactoryBean.afterPropertiesSet();
	return propertiesFactoryBean.getObject();
}
 
源代码18 项目: onetwo   文件: SpringUtils.java
public static JFishProperties loadAsJFishProperties(String... classpaths){
	PropertiesFactoryBean pfb = createPropertiesBySptring(classpaths);
   	try {
		pfb.afterPropertiesSet();
		JFishProperties properties = (JFishProperties)pfb.getObject();
		return properties;
	} catch (IOException e) {
		throw new BaseException("load config error: " + e.getMessage(), e);
	}
}
 
源代码19 项目: tutorials   文件: QrtzScheduler.java
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}