Java Code Examples for org.springframework.core.io.support.ResourcePropertySource#getName()

The following examples show how to use org.springframework.core.io.support.ResourcePropertySource#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurationClassParser.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void addPropertySource(ResourcePropertySource propertySource) {
	String name = propertySource.getName();
	MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment).getPropertySources();
	if (propertySources.contains(name) && this.propertySourceNames.contains(name)) {
		// We've already added a version, we need to extend it
		PropertySource<?> existing = propertySources.get(name);
		if (existing instanceof CompositePropertySource) {
			((CompositePropertySource) existing).addFirstPropertySource(propertySource.withResourceName());
		}
		else {
			if (existing instanceof ResourcePropertySource) {
				existing = ((ResourcePropertySource) existing).withResourceName();
			}
			CompositePropertySource composite = new CompositePropertySource(name);
			composite.addPropertySource(propertySource.withResourceName());
			composite.addPropertySource(existing);
			propertySources.replace(name, composite);
		}
	}
	else {
		if (this.propertySourceNames.isEmpty()) {
			propertySources.addLast(propertySource);
		}
		else {
			String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1);
			propertySources.addBefore(firstProcessed, propertySource);
		}
	}
	this.propertySourceNames.add(name);
}
 
Example 2
Source File: JasyptConfiguration.java    From seed with Apache License 2.0 4 votes vote down vote up
PropertySourceWrapper(ResourcePropertySource propertySource) {
    super(propertySource.getName(), propertySource.getSource());
}