Refactor CMS UUID factory
[lgpl/argeo-commons.git] / org.argeo.cms.lib.jetty / src / org / argeo / cms / jetty / JettyHttpServer.java
index 98975c3c843ad7c152a4c1815f738a812c6ca130..4e91ea41c734a51f739a1d82d2d030000788fb38 100644 (file)
@@ -16,6 +16,7 @@ import org.argeo.api.cms.CmsLog;
 import org.argeo.api.cms.CmsState;
 import org.argeo.cms.CmsDeployProperty;
 import org.argeo.cms.http.server.HttpServerUtils;
+import org.eclipse.jetty.ee8.servlet.ServletContextHandler;
 import org.eclipse.jetty.http.UriCompliance;
 import org.eclipse.jetty.server.HttpConfiguration;
 import org.eclipse.jetty.server.HttpConnectionFactory;
@@ -24,7 +25,6 @@ import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
-import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.ExecutorThreadPool;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
@@ -230,6 +230,7 @@ public class JettyHttpServer extends HttpsServer {
                        server.stop();
                        // TODO delete temp dir
                        started = false;
+                       log.debug(() -> "Stopped Jetty server");
                } catch (Exception e) {
                        log.error("Cannot stop Jetty HTTP server", e);
                }
@@ -278,7 +279,8 @@ public class JettyHttpServer extends HttpsServer {
                JettyHttpContext httpContext = contexts.remove(path);
                if (httpContext instanceof ContextHandlerHttpContext contextHandlerHttpContext) {
                        // TODO stop handler first?
-                       contextHandlerCollection.removeHandler(contextHandlerHttpContext.getServletContextHandler());
+                       // FIXME understand compatibility with Jetty 12
+                       // contextHandlerCollection.removeHandler(contextHandlerHttpContext.getServletContextHandler());
                } else {
                        // FIXME apparently servlets cannot be removed in Jetty, we should replace the
                        // handler
@@ -314,9 +316,16 @@ public class JettyHttpServer extends HttpsServer {
        }
 
        private String httpPortsMsg() {
+               String hostStr = getHost();
+               hostStr = hostStr == null ? "*:" : hostStr + ":";
+               return (httpConnector != null ? "# HTTP " + hostStr + getHttpPort() + " " : "")
+                               + (httpsConnector != null ? "# HTTPS " + hostStr + getHttpsPort() : "");
+       }
 
-               return (httpConnector != null ? "HTTP " + getHttpPort() + " " : "")
-                               + (httpsConnector != null ? "HTTPS " + getHttpsPort() : "");
+       public String getHost() {
+               if (httpConnector == null)
+                       return null;
+               return httpConnector.getHost();
        }
 
        public Integer getHttpPort() {