public SubsystemWithClassLoaderState(final ApplicationContext parentContext, final Properties globalProperties, final PropertiesPersister propertiesPersister, final String category, final String type, final String id, final String instancePath) { ParameterCheck.mandatory("parentContext", parentContext); ParameterCheck.mandatory("globalProperties", globalProperties); ParameterCheck.mandatory("propertiesPersister", propertiesPersister); ParameterCheck.mandatoryString("category", category); ParameterCheck.mandatoryString("type", type); ParameterCheck.mandatoryString("id", id); ParameterCheck.mandatoryString("instancePath", instancePath); this.parentContext = parentContext; this.globalProperties = globalProperties; this.propertiesPersister = propertiesPersister; this.category = category; this.type = type; this.id = id; this.instancePath = instancePath; this.loadFixedConfigProperties(); }
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); }
/** * 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(); } } }
/** * @return the persister */ public PropertiesPersister getPersister() { return persister; }
/** * @param persister the persister to set */ public void setPersister(PropertiesPersister persister) { this.persister = persister; }
/** * Return the PropertiesPersister to use for parsing properties files. */ public PropertiesPersister getPropertiesPersister() { return this.propertiesPersister; }
/** * @param persister * the persister to set */ public void setPersister(final PropertiesPersister persister) { ParameterCheck.mandatory("persister", persister); this.persister = persister; }
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()); }
/** * 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()); }
/** * Initiates an object of type RecursivePropertiesPersister. * * @param propertiesPersister */ public RecursivePropertiesPersister(PropertiesPersister propertiesPersister) { super(); this.propertiesPersister = propertiesPersister; }