Added a constructor for HikariConfig that accepts a Properties object. Modified props-file reading constructor to use try-with-resources to ensure prompt file close.

pull/10/head
Steve Waldman 11 years ago
parent 78ffed04f0
commit 6c84ea8a05

@ -81,6 +81,18 @@ public final class HikariConfig implements HikariConfigMBean
poolName = "HikariPool-" + poolNumber++; poolName = "HikariPool-" + poolNumber++;
} }
/**
* Construct a HikariConfig from the specified properties object.
*
* @param properties the name of the property file
*/
public HikariConfig(Properties properties)
{
this();
PropertyBeanSetter.setTargetFromProperties(this, properties);
}
/** /**
* Construct a HikariConfig from the specified property file name. * Construct a HikariConfig from the specified property file name.
* *
@ -96,9 +108,8 @@ public final class HikariConfig implements HikariConfigMBean
throw new IllegalArgumentException("Property file " + propertyFileName + " was not found."); throw new IllegalArgumentException("Property file " + propertyFileName + " was not found.");
} }
try try ( FileInputStream fis = new FileInputStream(propFile) )
{ {
FileInputStream fis = new FileInputStream(propFile);
Properties props = new Properties(); Properties props = new Properties();
props.load(fis); props.load(fis);
PropertyBeanSetter.setTargetFromProperties(this, props); PropertyBeanSetter.setTargetFromProperties(this, props);

Loading…
Cancel
Save