Search in sources :

Example 1 with ReloadablePropertiesFactoryBean

use of com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean in project disconf-spring-boot-starter by xjzrc.

the class DisconfAutoConfiguration method disconfPropertyPlaceholderConfigurer.

/**
 * 当配置文件改变,不会自动reload到系统
 *
 * @param factoryBean 不会自动reload配置工厂
 * @return PropertyPlaceholderConfigurer
 * @throws IOException IOException
 */
@Bean
@ConditionalOnBean(name = "disconfUnReloadablePropertiesFactoryBean")
public PropertyPlaceholderConfigurer disconfPropertyPlaceholderConfigurer(@Qualifier("disconfUnReloadablePropertiesFactoryBean") ReloadablePropertiesFactoryBean factoryBean) throws IOException {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    configurer.setOrder(1);
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    configurer.setProperties(factoryBean.getObject());
    addPropertiesPropertySource("disconfUnReloadableProperties", factoryBean.getObject());
    return configurer;
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) ReloadingPropertyPlaceholderConfigurer(com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) DisconfMgrBean(com.baidu.disconf.client.DisconfMgrBean) ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with ReloadablePropertiesFactoryBean

use of com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean in project disconf-spring-boot-starter by xjzrc.

the class DisconfAutoConfiguration method disconfUnReloadablePropertiesFactoryBean.

/**
 * 使用托管方式的disconf配置
 *
 * @return ReloadablePropertiesFactoryBean
 */
@Bean("disconfUnReloadablePropertiesFactoryBean")
@ConditionalOnExpression("'${spring.disconf.un-reload-files}' != '' and !'${spring.disconf.un-reload-files}'.startsWith('${')")
public ReloadablePropertiesFactoryBean disconfUnReloadablePropertiesFactoryBean() {
    ReloadablePropertiesFactoryBean factoryBean = new ReloadablePropertiesFactoryBean();
    factoryBean.setLocations(getFileNames(disconfProperties.getUnReloadFiles()));
    return factoryBean;
}
Also used : ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) ConditionalOnExpression(org.springframework.boot.autoconfigure.condition.ConditionalOnExpression) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) DisconfMgrBean(com.baidu.disconf.client.DisconfMgrBean) ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with ReloadablePropertiesFactoryBean

use of com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean in project disconf-spring-boot-starter by xjzrc.

the class DisconfAutoConfiguration method disconfReloadablePropertiesFactoryBean.

/**
 * 使用托管方式的disconf配置
 *
 * @return ReloadablePropertiesFactoryBean
 */
@Bean("disconfReloadablePropertiesFactoryBean")
@ConditionalOnExpression("'${spring.disconf.reload-files}' != '' and !'${spring.disconf.reload-files}'.startsWith('${')")
public ReloadablePropertiesFactoryBean disconfReloadablePropertiesFactoryBean() {
    ReloadablePropertiesFactoryBean factoryBean = new ReloadablePropertiesFactoryBean();
    factoryBean.setLocations(getFileNames(disconfProperties.getReloadFiles()));
    return factoryBean;
}
Also used : ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) ConditionalOnExpression(org.springframework.boot.autoconfigure.condition.ConditionalOnExpression) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) DisconfMgrBean(com.baidu.disconf.client.DisconfMgrBean) ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with ReloadablePropertiesFactoryBean

use of com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean in project disconf-spring-boot-starter by xjzrc.

the class DisconfAutoConfiguration method disconfReloadingPropertyPlaceholderConfigurer.

/**
 * 当配置文件改变,会自动reload到系统
 *
 * @param factoryBean 会自动reload配置工厂
 * @return ReloadingPropertyPlaceholderConfigurer
 * @throws IOException IOException
 */
@Bean
@ConditionalOnBean(name = "disconfReloadablePropertiesFactoryBean")
public ReloadingPropertyPlaceholderConfigurer disconfReloadingPropertyPlaceholderConfigurer(@Qualifier("disconfReloadablePropertiesFactoryBean") ReloadablePropertiesFactoryBean factoryBean) throws IOException {
    ReloadingPropertyPlaceholderConfigurer configurer = new ReloadingPropertyPlaceholderConfigurer();
    configurer.setOrder(1);
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    configurer.setProperties(factoryBean.getObject());
    addPropertiesPropertySource("disconfReloadableProperties", factoryBean.getObject());
    return configurer;
}
Also used : ReloadingPropertyPlaceholderConfigurer(com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) DisconfMgrBean(com.baidu.disconf.client.DisconfMgrBean) ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DisconfMgrBean (com.baidu.disconf.client.DisconfMgrBean)4 ReloadablePropertiesFactoryBean (com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean)4 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)4 Bean (org.springframework.context.annotation.Bean)4 ReloadingPropertyPlaceholderConfigurer (com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer)2 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)2 PropertyPlaceholderConfigurer (org.springframework.beans.factory.config.PropertyPlaceholderConfigurer)1