FELIX-1574: Some Karaf instances never reach the 'started' state
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@812879 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/assembly/src/main/filtered-resources/bin/admin b/karaf/assembly/src/main/filtered-resources/bin/admin
index 7b46968..4d7e4b0 100644
--- a/karaf/assembly/src/main/filtered-resources/bin/admin
+++ b/karaf/assembly/src/main/filtered-resources/bin/admin
@@ -200,7 +200,7 @@
}
setupDefaults() {
- DEFAULT_JAVA_OPTS="-Dstorage.file=${KARAF_HOME}/etc/instances.properties -Xms$JAVA_MIN_MEM -Xmx$JAVA_MAX_MEM "
+ DEFAULT_JAVA_OPTS="-Dstorage.location=${KARAF_HOME}/instances -Xms$JAVA_MIN_MEM -Xmx$JAVA_MAX_MEM "
#Set the JVM_VENDOR specific JVM flags
if [ "$JVM_VENDOR" = "SUN" ]; then
diff --git a/karaf/assembly/src/main/filtered-resources/bin/admin.bat b/karaf/assembly/src/main/filtered-resources/bin/admin.bat
index d6458f0..c11d1ca 100644
--- a/karaf/assembly/src/main/filtered-resources/bin/admin.bat
+++ b/karaf/assembly/src/main/filtered-resources/bin/admin.bat
@@ -54,7 +54,7 @@
set KARAF_BASE=%KARAF_HOME%
)
-set DEFAULT_JAVA_OPTS=-Dstorage.file="%KARAF_HOME%\etc\instances.properties"
+set DEFAULT_JAVA_OPTS=-Dstorage.location="%KARAF_HOME%\instances"
set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
rem Support for loading native libraries
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java
index c9caca8..58b1908 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java
@@ -37,6 +37,8 @@
public class AdminServiceImpl implements AdminService {
+ public static final String STORAGE_FILE = "instance.properties";
+
private static final Logger LOGGER = LoggerFactory.getLogger(AdminServiceImpl.class);
private Map<String, Instance> instances = new HashMap<String, Instance>();
@@ -81,13 +83,14 @@
public synchronized void init() throws Exception {
try {
- if (!storageLocation.isFile()) {
- if (storageLocation.exists()) {
- LOGGER.error("Instances storage location should be a file: " + storageLocation);
+ File storageFile = new File(storageLocation, STORAGE_FILE);
+ if (!storageFile.isFile()) {
+ if (storageFile.exists()) {
+ LOGGER.error("Instances storage location should be a file: " + storageFile);
}
return;
}
- Properties storage = loadStorage(storageLocation);
+ Properties storage = loadStorage(storageFile);
int count = Integer.parseInt(storage.getProperty("count", "0"));
defaultPortStart = Integer.parseInt(storage.getProperty("port", Integer.toString(defaultPortStart)));
Map<String, Instance> newInstances = new HashMap<String, Instance>();
@@ -117,7 +120,11 @@
if (instances.get(name) != null) {
throw new IllegalArgumentException("Instance '" + name + "' already exists");
}
- File serviceMixBase = new File(location != null ? location : ("instances/" + name)).getCanonicalFile();
+ String loc = location != null ? location : name;
+ File serviceMixBase = new File(loc);
+ if (!serviceMixBase.isAbsolute()) {
+ serviceMixBase = new File(storageLocation, loc);
+ }
int sshPort = port;
if (sshPort <= 0) {
sshPort = ++defaultPortStart;
@@ -184,7 +191,7 @@
storage.setProperty("item." + i + ".loc", data[i].getLocation());
storage.setProperty("item." + i + ".pid", Integer.toString(data[i].getPid()));
}
- saveStorage(storage, storageLocation);
+ saveStorage(storage, new File(storageLocation, STORAGE_FILE));
}
private void copyResourceToDir(File target, String resource, boolean text) throws Exception {
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/main/Execute.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/main/Execute.java
index f970ce2..90e26e9 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/main/Execute.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/main/Execute.java
@@ -73,7 +73,7 @@
exit(-1);
}
- String storage = System.getProperty("storage.file");
+ String storage = System.getProperty("storage.location");
if (storage == null) {
System.err.println("System property 'storage.file' is not set. \n" +
"This property needs to be set to the full path of the instance.properties file.");
diff --git a/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml b/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
index 361fa9f..55e852b 100644
--- a/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
+++ b/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
@@ -80,7 +80,7 @@
</command-bundle>
<bean id="adminService" class="org.apache.felix.karaf.gshell.admin.internal.AdminServiceImpl" init-method="init">
- <property name="storageLocation" value="${karaf.home}/etc/instances.properties" />
+ <property name="storageLocation" value="${karaf.home}/instances" />
</bean>
<bean id="instanceCompleter" class="org.apache.felix.karaf.gshell.admin.internal.completers.InstanceCompleter">