fix STOP server
[nikiroo-utils.git] / src / be / nikiroo / fanfix / library / WebLibrary.java
index 42f7ea5ccadd4eb40d6b86cfd1f6842abab0db50..0f2510dd544218279d8ddcaa1beae3ad097d631c 100644 (file)
@@ -126,6 +126,26 @@ public class WebLibrary extends BasicLibrary {
                return new Version();
        }
 
+       /**
+        * Stop the server.
+        * 
+        * @throws IOException
+        *             in case of I/O errors
+        */
+       public void stop() throws IOException {
+               try {
+                       post(WebLibraryUrls.EXIT_URL, null).close();
+               } catch (Exception e) {
+                       try {
+                               Thread.sleep(200);
+                       } catch (InterruptedException e1) {
+                       }
+                       if (getStatus() != Status.UNAVAILABLE) {
+                               throw new IOException("Cannot exit the library", e);
+                       }
+               }
+       }
+
        @Override
        public Status getStatus() {
                try {