merge from master
[nikiroo-utils.git] / library / WebLibraryServerHtml.java
index e96edef95584b5f18a63f62ab630c75abe92f6b0..7351d0dd3665bceffb58b02574345dfcb498d940 100644 (file)
@@ -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.
+        * <p>
+        * 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);
@@ -210,6 +217,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 +265,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 +281,10 @@ abstract class WebLibraryServerHtml implements Runnable {
                }
        }
 
+       protected void doStop() {
+               server.stop();
+       }
+
        /**
         * The traces handler for this {@link WebLibraryServerHtml}.
         *