use of org.springframework.core.env.PropertiesPropertySource in project cas by apereo.
the class CasPropertiesConfiguration method init.
/**
* Init.
*/
@PostConstruct
public void init() {
final Properties sysProps = System.getProperties();
final Properties properties = new Properties();
if (CasVersion.getVersion() != null) {
properties.put("info.cas.version", CasVersion.getVersion());
}
properties.put("info.cas.date", CasVersion.getDateTime());
properties.put("info.cas.java.home", sysProps.get("java.home"));
properties.put("info.cas.java.vendor", sysProps.get("java.vendor"));
properties.put("info.cas.java.version", sysProps.get("java.version"));
final PropertiesPropertySource src = new PropertiesPropertySource(CasVersion.class.getName(), properties);
this.environment.getPropertySources().addFirst(src);
}
use of org.springframework.core.env.PropertiesPropertySource in project cas by apereo.
the class CasCoreBootstrapStandaloneConfiguration method locate.
@Override
public PropertySource<?> locate(final Environment environment) {
final Properties props = new Properties();
loadEmbeddedYamlOverriddenProperties(props);
final File config = configurationPropertiesEnvironmentManager().getStandaloneProfileConfigurationDirectory();
LOGGER.debug("Located CAS standalone configuration directory at [{}]", config);
if (config.isDirectory() && config.exists()) {
loadSettingsFromConfigurationSources(environment, props, config);
} else {
LOGGER.warn("Configuration directory [{}] is not a directory or cannot be found at the specific path", config);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Located setting(s) [{}] from [{}]", props.keySet(), config);
} else {
LOGGER.info("Found and loaded [{}] setting(s) from [{}]", props.size(), config);
}
return new PropertiesPropertySource("standaloneCasConfigService", props);
}
use of org.springframework.core.env.PropertiesPropertySource in project spring-framework by spring-projects.
the class CrossOriginTests method setup.
@Before
public void setup() {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
Properties props = new Properties();
props.setProperty("myOrigin", "http://example.com");
wac.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("ps", props));
wac.registerSingleton("ppc", PropertySourcesPlaceholderConfigurer.class);
wac.refresh();
this.handlerMapping.setRemoveSemicolonContent(false);
wac.getAutowireCapableBeanFactory().initializeBean(this.handlerMapping, "hm");
this.request.setMethod("GET");
this.request.addHeader(HttpHeaders.ORIGIN, "http://domain.com/");
}
use of org.springframework.core.env.PropertiesPropertySource in project spring-boot by spring-projects.
the class DevToolsHomePropertiesPostProcessor method postProcessEnvironment.
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
File home = getHomeFolder();
File propertyFile = (home == null ? null : new File(home, FILE_NAME));
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
FileSystemResource resource = new FileSystemResource(propertyFile);
Properties properties;
try {
properties = PropertiesLoaderUtils.loadProperties(resource);
environment.getPropertySources().addFirst(new PropertiesPropertySource("devtools-local", properties));
} catch (IOException ex) {
throw new IllegalStateException("Unable to load " + FILE_NAME, ex);
}
}
}
use of org.springframework.core.env.PropertiesPropertySource in project spring-boot by spring-projects.
the class SpringProfileDocumentMatcher method extractSpringProfiles.
protected List<String> extractSpringProfiles(Properties properties) {
SpringProperties springProperties = new SpringProperties();
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new PropertiesPropertySource("profiles", properties));
PropertyValues propertyValues = new PropertySourcesPropertyValues(propertySources);
new RelaxedDataBinder(springProperties, "spring").bind(propertyValues);
List<String> profiles = springProperties.getProfiles();
return profiles;
}
Aggregations