Add Jetty host property to resolve URL message

This commit is contained in:
Jason Sherman 2014-05-09 16:38:49 -04:00
parent 210e39df8b
commit d37786ea13
3 changed files with 17 additions and 2 deletions

View File

@ -49,8 +49,9 @@ public class WebConsoleStarter implements ServletContextListener {
if ("embedded".equals(webconsoleType)) {
// show the url for the web consoles / main page so people can spot it
String port = System.getProperty("jetty.port");
if (port != null) {
LOG.info("ActiveMQ WebConsole available at http://localhost:{}/", port);
String host = System.getProperty("jetty.host");
if (host != null && port != null) {
LOG.info("ActiveMQ WebConsole available at http://{}:{}/", host, port);
}
}

View File

@ -21,9 +21,11 @@ package org.apache.activemq.web;
*/
public class WebConsolePort {
public static final String DEFAULT_HOST = "0.0.0.0";
public static final int DEFAULT_PORT = 8161;
private int port = DEFAULT_PORT;
private String host = DEFAULT_HOST;
public int getPort() {
return port;
@ -33,9 +35,19 @@ public class WebConsolePort {
this.port = port;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public void start() {
// you may set a JVM system property for the jetty.port
String port = System.getProperty("jetty.port", "" + this.port);
System.setProperty("jetty.port", port);
String host = System.getProperty("jetty.host", "" + this.host);
System.setProperty("jetty.host", host);
}
}

View File

@ -99,6 +99,7 @@
<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
<!-- the default port number for the web console -->
<property name="host" value="0.0.0.0"/>
<property name="port" value="8161"/>
</bean>
@ -109,6 +110,7 @@
<list>
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<!-- see the jettyPort bean -->
<property name="host" value="#{systemProperties['jetty.host']}" />
<property name="port" value="#{systemProperties['jetty.port']}" />
</bean>
<!--