Skip to content

Commit e7428c3

Browse files
committed
OWS-634: Allow deployment config to load a custom properties file
1 parent 02d17ed commit e7428c3

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

core/src/main/java/net/sourceforge/jnlp/config/DeploymentConfiguration.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ static boolean checkUrl(final URL file) {
165165
*
166166
* @throws ConfigurationException if it encounters a fatal error.
167167
*/
168-
public void load(File... propFile) throws ConfigurationException {
168+
public void load() throws ConfigurationException {
169169
LOG.debug("Start DeploymentConfiguration.load()");
170170
try {
171-
load(true, propFile);
171+
load(true);
172172
} catch (final MalformedURLException ex) {
173173
throw new ConfigurationException(ex.toString());
174174
} finally {
@@ -184,11 +184,12 @@ public void load(File... propFile) throws ConfigurationException {
184184
* resorting to the default values
185185
* @throws ConfigurationException if it encounters a fatal error.
186186
*/
187-
public void load(final boolean fixIssues, File... propFile ) throws ConfigurationException, MalformedURLException {
187+
public void load(final boolean fixIssues) throws ConfigurationException, MalformedURLException {
188+
final String owsUserPropertiesFilePath = System.getProperty("owsUserPropertiesFilePath");
188189
final SecurityManager sm = System.getSecurityManager();
189190
if (sm != null) {
190-
if (propFile.length > 0) {
191-
sm.checkRead(clean(propFile[0].getAbsolutePath()));
191+
if (owsUserPropertiesFilePath != null) {
192+
sm.checkRead(owsUserPropertiesFilePath);
192193
} else {
193194
sm.checkRead(userDeploymentFileDescriptor.getFullPath());
194195
}
@@ -208,7 +209,7 @@ public void load(final boolean fixIssues, File... propFile ) throws Configuratio
208209
/*
209210
* Third, read the user's subdirResult deployment.properties file or the custom config properties
210211
*/
211-
userPropertiesFile = propFile.length > 0 ? propFile[0] : userDeploymentFileDescriptor.getFile();
212+
userPropertiesFile = owsUserPropertiesFilePath != null ? new File(owsUserPropertiesFilePath) : userDeploymentFileDescriptor.getFile();
212213
final URL userPropertiesUrl = userPropertiesFile.toURI().toURL();
213214
final Map<String, Setting> userProperties = loadProperties(ConfigType.USER, userPropertiesUrl, false);
214215
userComments = loadComments(userPropertiesUrl);

core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,7 @@ private static class DeploymentConfigurationHolder {
459459
static {
460460
DeploymentConfiguration config = new DeploymentConfiguration();
461461
try {
462-
final String owsUserPropertiesFilename = System.getProperty("owsUserPropertiesFilename");
463-
if (owsUserPropertiesFilename != null) {
464-
LOG.debug("Loading config from file {} ", owsUserPropertiesFilename);
465-
config.load(new File(owsUserPropertiesFilename));
466-
} else {
467-
config.load();
468-
}
462+
config.load();
469463
config.copyTo(System.getProperties());
470464
} catch (ConfigurationException ex) {
471465
LOG.info("Fatal error while reading the configuration, continuing with empty. Please fix");

0 commit comments

Comments
 (0)