You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by vi...@apache.org on 2012/08/14 04:16:38 UTC
svn commit: r1372705 -
/geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
Author: violalu
Date: Tue Aug 14 02:16:37 2012
New Revision: 1372705
URL: http://svn.apache.org/viewvc?rev=1372705&view=rev
Log:
GERONIMO-6374 create a flag file to detect servr shutdown clean or not
Modified:
geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
Modified: geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java?rev=1372705&r1=1372704&r2=1372705&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java (original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java Tue Aug 14 02:16:37 2012
@@ -59,6 +59,11 @@ public class FrameworkLauncher {
* The default name used for the startup properties file.
*/
public static final String STARTUP_PROPERTIES_FILE_NAME = "startup.properties";
+
+ /**
+ * The flag file to detect whether server is shutdown normally or by terminating jvm.
+ */
+ public static final String SERVER_FLAG_FILE_NAME = "server.flag";
/**
* The system property for specifying the Karaf home directory. The home directory
@@ -145,11 +150,18 @@ public class FrameworkLauncher {
configJansiPath();
setFrameworkStorage(configProps);
+
+
if (cleanStorage) {
configProps.setProperty(Constants.FRAMEWORK_STORAGE_CLEAN,
Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
}
+
+ if(detectServerFlag()){
+ configProps.setProperty(Constants.FRAMEWORK_STORAGE_CLEAN,
+ Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+ }
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
@@ -347,7 +359,7 @@ public class FrameworkLauncher {
}
private void updateClassLoader(Properties configProps) throws Exception {
- String framework = configProps.getProperty(KARAF_FRAMEWORK);
+ String framework = configProps.getProperty(KARAF_FRAMEWORK);
if (framework == null) {
throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + " must be set in the etc/" + configFile + " configuration file");
}
@@ -501,4 +513,19 @@ public class FrameworkLauncher {
int startLevel;
Bundle bundle;
}
+
+ boolean detectServerFlag(){
+ File serverFlagFile = null;
+ try {
+ serverFlagFile = new File(geronimoBase, "var/" + SERVER_FLAG_FILE_NAME);
+ serverFlagFile.deleteOnExit();
+ boolean newFile = serverFlagFile.createNewFile();
+ if (!newFile){
+ return true;
+ }
+ } catch (IOException e) {
+ System.err.println("Can not create server flag file at " + serverFlagFile.getAbsolutePath() + " ( " + e.getMessage() + " ) ");
+ }
+ return false;
+ }
}