X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=library%2FWebLibraryServerHtml.java;h=8895fb83a07b0eb6ff7116b3998a7a89a2acfb15;hp=e96edef95584b5f18a63f62ab630c75abe92f6b0;hb=002972e9de731678035d56304d75a6d9e8233635;hpb=159e970c23d9634d39bb8cf2a194f7088f4d59ab diff --git a/library/WebLibraryServerHtml.java b/library/WebLibraryServerHtml.java index e96edef..8895fb8 100644 --- a/library/WebLibraryServerHtml.java +++ b/library/WebLibraryServerHtml.java @@ -70,6 +70,13 @@ abstract class WebLibraryServerHtml implements Runnable { protected abstract Response delete(String uri, WLoginResult login) throws IOException; + /** + * Wait until all operations are done and stop the server. + *

+ * All the new R/W operations will be refused after a call to stop. + */ + protected abstract Response stop(WLoginResult login); + public WebLibraryServerHtml(boolean secure) throws IOException { Integer port = Instance.getInstance().getConfig() .getInteger(Config.SERVER_PORT); @@ -166,13 +173,14 @@ abstract class WebLibraryServerHtml implements Runnable { } Response rep = null; - if (!login.isSuccess() && WebLibraryUrls.isSupportedUrl(uri)) { + if (!login.isSuccess() + && WebLibraryUrls.isSupportedUrl(uri, true)) { rep = loginPage(login, uri); } if (rep == null) { try { - if (WebLibraryUrls.isSupportedUrl(uri)) { + if (WebLibraryUrls.isSupportedUrl(uri, false)) { if (WebLibraryUrls.INDEX_URL.equals(uri)) { rep = root(session, cookies, login); } else if (WebLibraryUrls.VERSION_URL.equals(uri)) { @@ -210,6 +218,8 @@ abstract class WebLibraryServerHtml implements Runnable { } } else if (WebLibraryUrls.isDeleteUrl(uri)) { rep = delete(uri, login); + } else if (WebLibraryUrls.EXIT_URL.equals(uri)) { + rep = WebLibraryServerHtml.this.stop(login); } else { getTraceHandler().error( "Supported URL was not processed: " @@ -256,9 +266,7 @@ abstract class WebLibraryServerHtml implements Runnable { } }; - if (ssf != null) - - { + if (ssf != null) { getTraceHandler().trace("Install SSL on the web server..."); server.makeSecure(ssf, null); getTraceHandler().trace("Done."); @@ -274,6 +282,10 @@ abstract class WebLibraryServerHtml implements Runnable { } } + protected void doStop() { + server.stop(); + } + /** * The traces handler for this {@link WebLibraryServerHtml}. *