org.springframework.util.DefaultPropertiesPersister Java Examples

The following examples show how to use org.springframework.util.DefaultPropertiesPersister. 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: NotificationPropertyPlaceholderConfigurer.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * This method consolidates config properties.
 * @param properties
 * @return Properties
 * @throws IOException
 */
protected Properties transformProperties(Properties properties) throws IOException {
    String cfgLocation = System.getProperty(CFG_LOCATION_PROPERTY);

    if (cfgLocation != null) {
        Resource resource = new FileSystemResourceLoader().getResource(cfgLocation);
        if (resource != null && resource.exists()) {
            new DefaultPropertiesPersister().load(properties, resource.getInputStream());
        }
    }
    
    return properties;
}
 
Example #3
Source File: PropertiesUtil.java    From j-road with Apache License 2.0 5 votes vote down vote up
public static Properties readProperties(Resource resource) throws IOException {
  if (resource == null) {
    return null;
  }
  Properties props = new Properties();
  new DefaultPropertiesPersister().load(props, resource.getInputStream());
  return props;
}
 
Example #4
Source File: JavaFxSettingsManager.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * saves settings to settings file
 */
public void save() {
    JavaFxSettings javaFxSettings = load();
    try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) {
        DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
        persister.store(javaFxSettings.getProperties(), outputStream, "Phoenicis JavaFX User JavaFxSettings");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #5
Source File: SettingsManager.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void save() {
    Settings settings = load();
    try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) {
        DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
        persister.store(settings.getProperties(), outputStream, "Phoenicis User Settings");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #6
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 #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 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 #9
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 #10
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 #11
Source File: PropertiesLoaderUtils.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Fill the given properties from the given EncodedResource,
 * potentially defining a specific encoding for the properties file.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @throws IOException in case of I/O errors
 */
public static void fillProperties(Properties props, EncodedResource resource)
		throws IOException {

	fillProperties(props, resource, new DefaultPropertiesPersister());
}
 
Example #12
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 #13
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 #14
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 #15
Source File: PropertiesLoaderUtils.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Fill the given properties from the given EncodedResource,
 * potentially defining a specific encoding for the properties file.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @throws IOException in case of I/O errors
 */
public static void fillProperties(Properties props, EncodedResource resource)
		throws IOException {

	fillProperties(props, resource, new DefaultPropertiesPersister());
}
 
Example #16
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 #17
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 #18
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 #19
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());
}
 
Example #20
Source File: PropertiesLoaderUtils.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Fill the given properties from the given EncodedResource,
 * potentially defining a specific encoding for the properties file.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @throws IOException in case of I/O errors
 */
public static void fillProperties(Properties props, EncodedResource resource)
		throws IOException {

	fillProperties(props, resource, new DefaultPropertiesPersister());
}
 
Example #21
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 #22
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 #23
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 #24
Source File: PropertiesLoaderUtils.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Fill the given properties from the given EncodedResource,
 * potentially defining a specific encoding for the properties file.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @throws IOException in case of I/O errors
 */
public static void fillProperties(Properties props, EncodedResource resource)
		throws IOException {

	fillProperties(props, resource, new DefaultPropertiesPersister());
}