- Improved shutdown hooks

- Redesigned UI, now a single-window application (todo: minimize to tray)
This commit is contained in:
Sebastian Stenzel
2014-12-09 10:50:09 +01:00
parent 884b894e04
commit d0f0c09585
19 changed files with 785 additions and 626 deletions
@@ -32,6 +32,7 @@ public final class WebDAVServer {
private static final int MIN_THREADS = 4;
private static final int THREAD_IDLE_SECONDS = 20;
private final Server server;
private int port;
public WebDAVServer() {
final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(MAX_PENDING_REQUESTS);
@@ -42,9 +43,9 @@ public final class WebDAVServer {
/**
* @param workDir Path of encrypted folder.
* @param cryptor A fully initialized cryptor instance ready to en- or decrypt streams.
* @return port, on which the server did start
* @return <code>true</code> upon success
*/
public int start(final String workDir, final Cryptor cryptor) {
public synchronized boolean start(final String workDir, final Cryptor cryptor) {
final ServerConnector connector = new ServerConnector(server);
connector.setHost(LOCALHOST);
@@ -58,20 +59,22 @@ public final class WebDAVServer {
try {
server.setConnectors(new Connector[] {connector});
server.start();
port = connector.getLocalPort();
return true;
} catch (Exception ex) {
LOG.error("Server couldn't be started", ex);
return false;
}
return connector.getLocalPort();
}
public boolean isRunning() {
return server.isRunning();
}
public boolean stop() {
public synchronized boolean stop() {
try {
server.stop();
port = 0;
} catch (Exception ex) {
LOG.error("Server couldn't be stopped", ex);
}
@@ -85,4 +88,8 @@ public final class WebDAVServer {
return result;
}
public int getPort() {
return port;
}
}