mirror of https://github.com/apache/activemq.git
AMQ-7486: Log at INFO level on starting standalone broker the http url of the web console
This commit is contained in:
parent
e889e36335
commit
84c4b9db56
|
@ -30,8 +30,6 @@ import javax.servlet.ServletContextListener;
|
|||
|
||||
/**
|
||||
* Starts the WebConsole.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class WebConsoleStarter implements ServletContextListener {
|
||||
|
||||
|
@ -40,30 +38,28 @@ public class WebConsoleStarter implements ServletContextListener {
|
|||
public void contextInitialized(ServletContextEvent event) {
|
||||
LOG.debug("Initializing ActiveMQ WebConsole...");
|
||||
|
||||
String webconsoleType = getWebconsoleType();
|
||||
|
||||
ServletContext servletContext = event.getServletContext();
|
||||
WebApplicationContext context = createWebapplicationContext(servletContext);
|
||||
WebApplicationContext context = createWebapplicationContext(servletContext, webconsoleType);
|
||||
|
||||
initializeWebClient(servletContext, context);
|
||||
|
||||
LOG.info("ActiveMQ WebConsole initialized.");
|
||||
}
|
||||
|
||||
private WebApplicationContext createWebapplicationContext(ServletContext servletContext) {
|
||||
|
||||
String webconsoleType = System.getProperty("webconsole.type", "embedded");
|
||||
|
||||
// detect osgi
|
||||
try {
|
||||
if (OsgiUtil.isOsgi()) {
|
||||
webconsoleType = "osgi";
|
||||
// for embedded console log what port it uses
|
||||
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);
|
||||
}
|
||||
} catch (NoClassDefFoundError ignore) {
|
||||
}
|
||||
|
||||
LOG.debug("ActiveMQ WebConsole initialized.");
|
||||
}
|
||||
|
||||
private WebApplicationContext createWebapplicationContext(ServletContext servletContext, String webconsoleType) {
|
||||
String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
|
||||
|
||||
LOG.info("Web console type: " + webconsoleType);
|
||||
LOG.debug("Web console type: " + webconsoleType);
|
||||
|
||||
XmlWebApplicationContext context = new XmlWebApplicationContext();
|
||||
context.setServletContext(servletContext);
|
||||
|
@ -93,6 +89,20 @@ public class WebConsoleStarter implements ServletContextListener {
|
|||
// do nothing, since the context is destroyed anyway
|
||||
}
|
||||
|
||||
private static String getWebconsoleType() {
|
||||
String webconsoleType = System.getProperty("webconsole.type", "embedded");
|
||||
|
||||
// detect osgi
|
||||
try {
|
||||
if (OsgiUtil.isOsgi()) {
|
||||
webconsoleType = "osgi";
|
||||
}
|
||||
} catch (NoClassDefFoundError ignore) {
|
||||
}
|
||||
|
||||
return webconsoleType;
|
||||
}
|
||||
|
||||
static class OsgiUtil {
|
||||
static boolean isOsgi() {
|
||||
return (FrameworkUtil.getBundle(WebConsoleStarter.class) != null);
|
||||
|
|
|
@ -47,6 +47,7 @@ public final class Main {
|
|||
port = Integer.parseInt(text);
|
||||
}
|
||||
System.out.println("Starting Web Server on port: " + port);
|
||||
System.setProperty("jetty.port", "" + port);
|
||||
Server server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
connector.setPort(port);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.web;
|
||||
|
||||
/**
|
||||
* Bean to initialize the port number we use for embedded Jetty server for the web consoles.
|
||||
*/
|
||||
public class WebConsolePort {
|
||||
|
||||
public static final int DEFAULT_PORT = 8161;
|
||||
|
||||
private int port = DEFAULT_PORT;
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -111,13 +111,19 @@
|
|||
<bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
</bean>
|
||||
|
||||
<bean id="Server" class="org.eclipse.jetty.server.Server" init-method="start"
|
||||
<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
|
||||
<!-- the default port number for the web console -->
|
||||
<property name="port" value="8161"/>
|
||||
</bean>
|
||||
|
||||
<bean id="Server" depends-on="jettyPort" class="org.eclipse.jetty.server.Server" init-method="start"
|
||||
destroy-method="stop">
|
||||
|
||||
<property name="connectors">
|
||||
<list>
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||
<property name="port" value="8161" />
|
||||
<!-- see the jettyPort bean -->
|
||||
<property name="port" value="#{systemProperties['jetty.port']}" />
|
||||
</bean>
|
||||
<!--
|
||||
Enable this connector if you wish to use https with web console
|
||||
|
|
Loading…
Reference in New Issue