X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.lib.jetty%2Fsrc%2Forg%2Fargeo%2Fcms%2Fjetty%2FJettyHttpServer.java;h=e414f5f984f3053dfc54ac3278069d0314cf83a0;hb=8c6e16aa43d9523e1ec57a41a06b3ceba7d23fdb;hp=0eaaadb5f321924cbdee914cf6902119c0a7b50c;hpb=79c14508549e1af042485b4f888a3c54f5a68833;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java b/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java index 0eaaadb5f..e414f5f98 100644 --- a/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java +++ b/org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java @@ -10,6 +10,7 @@ import java.util.concurrent.ThreadPoolExecutor; import javax.servlet.ServletException; import org.argeo.api.cms.CmsLog; +import org.argeo.api.cms.CmsState; import org.argeo.cms.CmsDeployProperty; import org.argeo.util.http.HttpServerUtils; import org.eclipse.jetty.http.UriCompliance; @@ -41,7 +42,8 @@ public class JettyHttpServer extends HttpsServer { protected ServerConnector httpConnector; protected ServerConnector httpsConnector; - private InetSocketAddress address; + private InetSocketAddress httpAddress; + private InetSocketAddress httpsAddress; private ThreadPoolExecutor executor; @@ -53,6 +55,8 @@ public class JettyHttpServer extends HttpsServer { private boolean started; + private CmsState cmsState; + @Override public void bind(InetSocketAddress addr, int backlog) throws IOException { throw new UnsupportedOperationException(); @@ -182,7 +186,7 @@ public class JettyHttpServer extends HttpsServer { @Override public InetSocketAddress getAddress() { - return address; + return httpAddress; } @Override @@ -195,8 +199,6 @@ public class JettyHttpServer extends HttpsServer { return httpsConfigurator; } - - protected void configureConnectors() { HttpConfiguration httpConfiguration = new HttpConfiguration(); @@ -210,6 +212,10 @@ public class JettyHttpServer extends HttpsServer { // try { if (httpPortStr != null || httpsPortStr != null) { + // TODO deal with hostname resolving taking too much time +// String fallBackHostname = InetAddress.getLocalHost().getHostName(); + String fallBackHostname = cmsState != null ? cmsState.getHostname() : "::1"; + boolean httpEnabled = httpPortStr != null; // props.put(JettyHttpConstants.HTTP_ENABLED, httpEnabled); boolean httpsEnabled = httpsPortStr != null; @@ -226,6 +232,8 @@ public class JettyHttpServer extends HttpsServer { httpConnector.setPort(httpPort); httpConnector.setHost(httpHost); httpConnector.setIdleTimeout(DEFAULT_IDLE_TIMEOUT); + + httpAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, httpPort); } if (httpsEnabled) { @@ -261,6 +269,8 @@ public class JettyHttpServer extends HttpsServer { int httpsPort = Integer.parseInt(httpsPortStr); httpsConnector.setPort(httpsPort); httpsConnector.setHost(httpHost); + + httpsAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, httpsPort); } } @@ -268,7 +278,8 @@ public class JettyHttpServer extends HttpsServer { } protected String getDeployProperty(CmsDeployProperty deployProperty) { - return System.getProperty(deployProperty.getProperty()); + return cmsState != null ? cmsState.getDeployProperty(deployProperty.getProperty()) + : System.getProperty(deployProperty.getProperty()); } private String httpPortsMsg() { @@ -297,7 +308,10 @@ public class JettyHttpServer extends HttpsServer { } - + public void setCmsState(CmsState cmsState) { + this.cmsState = cmsState; + } + public boolean isStarted() { return started; }