use of org.springframework.core.env.PropertiesPropertySource in project spring-boot by spring-projects.
the class BuildInfoContributor method toSimplePropertySource.
@Override
protected PropertySource<?> toSimplePropertySource() {
Properties props = new Properties();
copyIfSet(props, "group");
copyIfSet(props, "artifact");
copyIfSet(props, "name");
copyIfSet(props, "version");
copyIfSet(props, "time");
return new PropertiesPropertySource("build", props);
}
use of org.springframework.core.env.PropertiesPropertySource in project spring-boot by spring-projects.
the class GitInfoContributor method toSimplePropertySource.
@Override
protected PropertySource<?> toSimplePropertySource() {
Properties props = new Properties();
copyIfSet(props, "branch");
String commitId = getProperties().getShortCommitId();
if (commitId != null) {
props.put("commit.id", commitId);
}
copyIfSet(props, "commit.time");
return new PropertiesPropertySource("git", props);
}
use of org.springframework.core.env.PropertiesPropertySource in project spring-framework by spring-projects.
the class CrossOriginAnnotationIntegrationTests method initApplicationContext.
@Override
protected ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(WebConfig.class);
Properties props = new Properties();
props.setProperty("myOrigin", "http://site1.com");
context.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("ps", props));
context.register(PropertySourcesPlaceholderConfigurer.class);
context.refresh();
return context;
}
use of org.springframework.core.env.PropertiesPropertySource in project Activiti by Activiti.
the class CustomMybatisMapperConfigurationTest method context.
private AnnotationConfigApplicationContext context(Class<?>... clzz) throws IOException {
AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
annotationConfigApplicationContext.register(clzz);
File springBootPropertiesFile = new File("src/test/resources/config/application.properties");
Properties springBootProperties = new Properties();
springBootProperties.load(new FileInputStream(springBootPropertiesFile));
annotationConfigApplicationContext.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("testProperties", springBootProperties));
annotationConfigApplicationContext.refresh();
return annotationConfigApplicationContext;
}
use of org.springframework.core.env.PropertiesPropertySource in project uPortal by Jasig.
the class PortalPropertySourcesPlaceholderConfigurer method postProcessBeanFactory.
/**
* Override the postProcessing. The default PropertySourcesPlaceholderConfigurer does not inject
* local properties into the Environment object. It builds a local list of properties files and
* then uses a transient Resolver to resolve the @Value annotations. That means that you are
* unable to get to "local" properties (eg. portal.properties) after bean post-processing has
* completed unless you are going to re-parse those file. This is similar to what
* PropertiesManager does, but it uses all the property files configured, not just
* portal.properties.
*
* <p>If we upgrade to spring 4, there are better/more efficient solutions available. I'm not
* aware of better solutions for spring 3.x.
*
* @param beanFactory the bean factory
* @throws BeansException if an error occurs while loading properties or wiring up beans
*/
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (propertyResolver == null) {
try {
MutablePropertySources sources = new MutablePropertySources();
PropertySource<?> localPropertySource = new PropertiesPropertySource(EXTENDED_PROPERTIES_SOURCE, mergeProperties());
sources.addLast(localPropertySource);
propertyResolver = new PropertySourcesPropertyResolver(sources);
} catch (IOException e) {
throw new BeanInitializationException("Could not load properties", e);
}
}
super.postProcessBeanFactory(beanFactory);
}
Aggregations