merge from master
[nikiroo-utils.git] / library / WebLibraryServerHtml.java
index ac0631dd60ba32abc8f34b7297510bbc78039c95..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: "
@@ -272,6 +281,10 @@ abstract class WebLibraryServerHtml implements Runnable {
                }
        }
 
+       protected void doStop() {
+               server.stop();
+       }
+
        /**
         * The traces handler for this {@link WebLibraryServerHtml}.
         *