mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 03:38:05 -05:00
Fix Winrun4J service wrapper implementation, launch a non daemon thread
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1988 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
43356e24ff
commit
e59e4d526f
@ -191,7 +191,9 @@ public final class Settings {
|
|||||||
String logFilePath = Settings.getProperty("davmail.logFilePath");
|
String logFilePath = Settings.getProperty("davmail.logFilePath");
|
||||||
// set default log file path
|
// set default log file path
|
||||||
if ((logFilePath == null || logFilePath.length() == 0)) {
|
if ((logFilePath == null || logFilePath.length() == 0)) {
|
||||||
if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
|
if (Settings.getBooleanProperty("davmail.server")) {
|
||||||
|
logFilePath = "davmail.log";
|
||||||
|
} else if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
|
||||||
// store davmail.log in OSX Logs directory
|
// store davmail.log in OSX Logs directory
|
||||||
logFilePath = System.getProperty("user.home") + "/Library/Logs/DavMail/davmail.log";
|
logFilePath = System.getProperty("user.home") + "/Library/Logs/DavMail/davmail.log";
|
||||||
} else {
|
} else {
|
||||||
@ -231,7 +233,7 @@ public final class Settings {
|
|||||||
/**
|
/**
|
||||||
* Update Log4J config from settings.
|
* Update Log4J config from settings.
|
||||||
*/
|
*/
|
||||||
private static void updateLoggingConfig() {
|
public static void updateLoggingConfig() {
|
||||||
String logFilePath = getLogFilePath();
|
String logFilePath = getLogFilePath();
|
||||||
|
|
||||||
Logger rootLogger = Logger.getRootLogger();
|
Logger rootLogger = Logger.getRootLogger();
|
||||||
|
@ -30,6 +30,8 @@ import org.boris.winrun4j.ServiceException;
|
|||||||
*/
|
*/
|
||||||
public class DavService extends AbstractService {
|
public class DavService extends AbstractService {
|
||||||
|
|
||||||
|
protected boolean stopped;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a service request.
|
* Perform a service request.
|
||||||
*
|
*
|
||||||
@ -44,6 +46,7 @@ public class DavService extends AbstractService {
|
|||||||
case SERVICE_CONTROL_SHUTDOWN:
|
case SERVICE_CONTROL_SHUTDOWN:
|
||||||
DavGatewayTray.debug(new BundleMessage("LOG_STOPPING_DAVMAIL"));
|
DavGatewayTray.debug(new BundleMessage("LOG_STOPPING_DAVMAIL"));
|
||||||
DavGateway.stop();
|
DavGateway.stop();
|
||||||
|
stopped = true;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -61,11 +64,29 @@ public class DavService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Settings.load();
|
Settings.load();
|
||||||
DavGatewayTray.init();
|
if (!Settings.getBooleanProperty("davmail.server")) {
|
||||||
|
Settings.setProperty("davmail.server", "true");
|
||||||
|
Settings.updateLoggingConfig();
|
||||||
|
}
|
||||||
|
|
||||||
DavGateway.start();
|
DavGateway.start();
|
||||||
DavGatewayTray.debug(new BundleMessage("LOG_DAVMAIL_STARTED"));
|
DavGatewayTray.debug(new BundleMessage("LOG_DAVMAIL_STARTED"));
|
||||||
|
|
||||||
|
// launch a non daemon thread
|
||||||
|
Thread shutdownListenerThread = new Thread("ShutDownListener") {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
while (!stopped) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
DavGatewayTray.debug(new BundleMessage("LOG_GATEWAY_INTERRUPTED"));
|
||||||
|
DavGateway.stop();
|
||||||
|
DavGatewayTray.debug(new BundleMessage("LOG_GATEWAY_STOP"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
shutdownListenerThread.start();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user