org.springframework.util.PropertiesPersister Java Examples

The following examples show how to use org.springframework.util.PropertiesPersister. 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: PropertyConfigurer.java    From cougar with Apache License 2.0 6 votes vote down vote up
protected PropertyConfigurer(StringEncryptor encryptor) {
	this.propertyPlaceholderConfigurer = encryptor != null ? new EncryptablePropertyPlaceholderConfigurer(encryptor) : new PropertyPlaceholderConfigurer();

	// Ensure that system properties override the spring-set properties.
	propertyPlaceholderConfigurer.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);

	PropertiesPersister savingPropertiesPersister = new DefaultPropertiesPersister() {

           @Override
           public void load(Properties props, InputStream is) throws IOException {
               props.put(HOSTNAME_KEY, HOSTNAME);
               CougarNodeId.initialiseNodeId(props);
               super.load(props, is);
               for (String propName: props.stringPropertyNames()) {
                   allLoadedProperties.put(propName, System.getProperty(propName, props.getProperty(propName)));
               }
           }};
       propertyPlaceholderConfigurer.setPropertiesPersister(savingPropertiesPersister);
}
 
Example #2
Source File: PropertiesLoaderUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
Example #3
Source File: PropertiesLoaderUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
Example #4
Source File: PropertiesLoaderUtils.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
Example #5
Source File: PropertiesLoaderUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
Example #6
Source File: PropertiesBeanDefinitionReader.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Return the PropertiesPersister to use for parsing properties files.
 */
public PropertiesPersister getPropertiesPersister() {
	return this.propertiesPersister;
}
 
Example #7
Source File: SakaiProperties.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
    this.propertiesPersister =
            (propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #8
Source File: PropertiesBeanDefinitionReader.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Return the PropertiesPersister to use for parsing properties files.
 */
public PropertiesPersister getPropertiesPersister() {
	return this.propertiesPersister;
}
 
Example #9
Source File: ChildApplicationContextFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return the persister
 */
public PropertiesPersister getPersister() 
{
	return persister;
}
 
Example #10
Source File: ChildApplicationContextFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param persister the persister to set
 */
public void setPersister(PropertiesPersister persister) 
{
	this.persister = persister;
}
 
Example #11
Source File: SakaiProperties.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
    this.propertiesPersister =
            (propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #12
Source File: PropertiesBeanDefinitionReader.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Return the PropertiesPersister to use for parsing properties files.
 */
public PropertiesPersister getPropertiesPersister() {
	return this.propertiesPersister;
}
 
Example #13
Source File: PropertiesBeanDefinitionReader.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the PropertiesPersister to use for parsing properties files.
 */
public PropertiesPersister getPropertiesPersister() {
	return this.propertiesPersister;
}
 
Example #14
Source File: PropertiesBeanDefinitionReader.java    From blog_demos with Apache License 2.0 4 votes vote down vote up
/**
 * Return the PropertiesPersister to use for parsing properties files.
 */
public PropertiesPersister getPropertiesPersister() {
	return this.propertiesPersister;
}
 
Example #15
Source File: ReloadableResourceBundleMessageSource.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * <p>The default is a DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #16
Source File: ReloadableResourceBundleMessageSource.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * <p>The default is a DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #17
Source File: PropertiesBeanDefinitionReader.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #18
Source File: PropertiesLoaderSupport.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #19
Source File: PropertiesLoaderSupport.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #20
Source File: ReloadableResourceBundleMessageSource.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * <p>The default is a DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #21
Source File: PropertiesBeanDefinitionReader.java    From blog_demos with Apache License 2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #22
Source File: PropertiesLoaderSupport.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #23
Source File: PropertiesBeanDefinitionReader.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #24
Source File: PropertiesBeanDefinitionReader.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #25
Source File: ReloadableResourceBundleMessageSource.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * <p>The default is a DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #26
Source File: PropertiesBeanDefinitionReader.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
 
Example #27
Source File: PropertiesLoaderSupport.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the PropertiesPersister to use for parsing properties files.
 * The default is DefaultPropertiesPersister.
 * @see org.springframework.util.DefaultPropertiesPersister
 */
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
	this.propertiesPersister =
			(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}