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;
protected ServerConnector httpConnector;
protected ServerConnector httpsConnector;
- private InetSocketAddress address;
+ private InetSocketAddress httpAddress;
+ private InetSocketAddress httpsAddress;
private ThreadPoolExecutor executor;
private boolean started;
+ private CmsState cmsState;
+
@Override
public void bind(InetSocketAddress addr, int backlog) throws IOException {
throw new UnsupportedOperationException();
configureRootContextHandler(rootContextHandler);
// server.setHandler(rootContextHandler);
- ContextHandlerCollection contextHandlers = new ContextHandlerCollection();
+// ContextHandlerCollection contextHandlers = new ContextHandlerCollection();
if (rootContextHandler != null && !contexts.containsKey("/"))
- contextHandlers.addHandler(rootContextHandler);
- for (String contextPath : contexts.keySet()) {
- JettyHttpContext ctx = contexts.get(contextPath);
- contextHandlers.addHandler(ctx.getContextHandler());
- }
+ contextHandlerCollection.addHandler(rootContextHandler);
+// for (String contextPath : contexts.keySet()) {
+// JettyHttpContext ctx = contexts.get(contextPath);
+// contextHandlers.addHandler(ctx.getContextHandler());
+// }
server.setHandler(contextHandlerCollection);
@Override
public InetSocketAddress getAddress() {
- return address;
+ return httpAddress;
}
@Override
return httpsConfigurator;
}
-
-
protected void configureConnectors() {
HttpConfiguration httpConfiguration = new HttpConfiguration();
// 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;
httpConnector.setPort(httpPort);
httpConnector.setHost(httpHost);
httpConnector.setIdleTimeout(DEFAULT_IDLE_TIMEOUT);
+
+ httpAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, httpPort);
}
if (httpsEnabled) {
int httpsPort = Integer.parseInt(httpsPortStr);
httpsConnector.setPort(httpsPort);
httpsConnector.setHost(httpHost);
+
+ httpsAddress = new InetSocketAddress(httpHost != null ? httpHost : fallBackHostname, httpsPort);
}
}
}
protected String getDeployProperty(CmsDeployProperty deployProperty) {
- return System.getProperty(deployProperty.getProperty());
+ return cmsState != null ? cmsState.getDeployProperty(deployProperty.getProperty())
+ : System.getProperty(deployProperty.getProperty());
}
private String httpPortsMsg() {
}
-
+ public void setCmsState(CmsState cmsState) {
+ this.cmsState = cmsState;
+ }
+
public boolean isStarted() {
return started;
}