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); }
/** * 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; }
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(); } }
/** * 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(); } }
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; }
public void setPropertiesPersister(PropertiesPersister propertiesPersister) { this.propertiesPersister = (propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }