Author: gnodet
Date: Tue Sep 21 11:45:59 2010
New Revision: 999346
URL: http://svn.apache.org/viewvc?rev=999346&view=rev
Log:
KARAF-143: Setting 'karaf.instances' system property has no effect
Modified:
karaf/branches/karaf-2.0.x/main/src/main/java/org/apache/karaf/main/Utils.java
Modified:
karaf/branches/karaf-2.0.x/main/src/main/java/org/apache/karaf/main/Utils.java
URL:
http://svn.apache.org/viewvc/karaf/branches/karaf-2.0.x/main/src/main/java/org/apache/karaf/main/Utils.java?rev=999346&r1=999345&r2=999346&view=diff
==============================================================================
---
karaf/branches/karaf-2.0.x/main/src/main/java/org/apache/karaf/main/Utils.java
(original)
+++
karaf/branches/karaf-2.0.x/main/src/main/java/org/apache/karaf/main/Utils.java
Tue Sep 21 11:45:59 2010
@@ -34,13 +34,13 @@ public class Utils {
// Use the system property if specified.
String path = System.getProperty(Main.PROP_KARAF_HOME);
if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " +
Main.PROP_KARAF_HOME + " system property", false);
+ rc = validateDirectoryExists(path, "Invalid " +
Main.PROP_KARAF_HOME + " system property", false, true);
}
if (rc == null) {
path = System.getenv(Main.ENV_KARAF_HOME);
if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " +
Main.ENV_KARAF_HOME + " environment variable", false);
+ rc = validateDirectoryExists(path, "Invalid " +
Main.ENV_KARAF_HOME + " environment variable", false, true);
}
}
@@ -75,24 +75,24 @@ public class Utils {
return rc;
}
- public static File validateDirectoryExists(String path, String errPrefix,
boolean createDirectory) {
+ public static File validateDirectoryExists(String path, String errPrefix,
boolean createDirectory, boolean validate) {
File rc;
try {
rc = new File(path).getCanonicalFile();
} catch (IOException e) {
throw new IllegalArgumentException(errPrefix + " '" + path + "' :
" + e.getMessage());
}
- if (!rc.exists() && !createDirectory) {
+ if (!rc.exists() && !createDirectory && validate) {
throw new IllegalArgumentException(errPrefix + " '" + path + "' :
does not exist");
}
- if (!rc.exists()) {
+ if (!rc.exists() && createDirectory) {
try {
rc.mkdirs();
} catch (SecurityException se) {
throw new IllegalArgumentException(errPrefix + " '" + path +
"' : " + se.getMessage());
}
}
- if (!rc.isDirectory()) {
+ if (rc.exists() && !rc.isDirectory()) {
throw new IllegalArgumentException(errPrefix + " '" + path + "' :
is not a directory");
}
return rc;
@@ -102,14 +102,14 @@ public class Utils {
File rc = null;
String path = System.getProperty(directoryProperty);
- if (path != null && validate) {
- rc = validateDirectoryExists(path, "Invalid " + directoryProperty
+ " system property", create);
+ if (path != null) {
+ rc = validateDirectoryExists(path, "Invalid " + directoryProperty
+ " system property", create, validate);
}
if (rc == null) {
path = System.getenv(directoryEnvironmentVariable);
if (path != null && validate) {
- rc = validateDirectoryExists(path, "Invalid " +
directoryEnvironmentVariable + " environment variable", create);
+ rc = validateDirectoryExists(path, "Invalid " +
directoryEnvironmentVariable + " environment variable", create, validate);
}
}