mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-4034 - osgi web console, remove runtime osgi dependency
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1441461 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
964f8ca375
commit
3527a4cfa0
|
@ -16,25 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.web;
|
package org.apache.activemq.web;
|
||||||
|
|
||||||
import javax.imageio.spi.ServiceRegistry;
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletContextEvent;
|
|
||||||
import javax.servlet.ServletContextListener;
|
|
||||||
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
import org.osgi.framework.Constants;
|
|
||||||
import org.osgi.framework.FrameworkUtil;
|
import org.osgi.framework.FrameworkUtil;
|
||||||
import org.osgi.framework.ServiceRegistration;
|
|
||||||
import org.osgi.service.cm.ManagedService;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||||
import org.springframework.web.context.support.XmlWebApplicationContext;
|
import org.springframework.web.context.support.XmlWebApplicationContext;
|
||||||
|
|
||||||
import java.util.Dictionary;
|
import javax.jms.ConnectionFactory;
|
||||||
import java.util.Hashtable;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the WebConsole.
|
* Starts the WebConsole.
|
||||||
|
@ -61,13 +53,18 @@ public class WebConsoleStarter implements ServletContextListener {
|
||||||
String webconsoleType = System.getProperty("webconsole.type", "embedded");
|
String webconsoleType = System.getProperty("webconsole.type", "embedded");
|
||||||
|
|
||||||
// detect osgi
|
// detect osgi
|
||||||
if (FrameworkUtil.getBundle(getClass()) != null) {
|
try {
|
||||||
webconsoleType = "osgi";
|
if (OsgiUtil.isOsgi()) {
|
||||||
|
webconsoleType = "osgi";
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError ignore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
|
String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
|
||||||
|
|
||||||
|
LOG.info("Web console type: " + webconsoleType);
|
||||||
|
|
||||||
XmlWebApplicationContext context = new XmlWebApplicationContext();
|
XmlWebApplicationContext context = new XmlWebApplicationContext();
|
||||||
context.setServletContext(servletContext);
|
context.setServletContext(servletContext);
|
||||||
context.setConfigLocations(new String[] {
|
context.setConfigLocations(new String[] {
|
||||||
|
@ -95,4 +92,10 @@ public class WebConsoleStarter implements ServletContextListener {
|
||||||
// do nothing, since the context is destroyed anyway
|
// do nothing, since the context is destroyed anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class OsgiUtil {
|
||||||
|
static boolean isOsgi() {
|
||||||
|
return (FrameworkUtil.getBundle(WebConsoleStarter.class) != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.osgi.framework.FrameworkUtil;
|
||||||
import org.osgi.framework.ServiceRegistration;
|
import org.osgi.framework.ServiceRegistration;
|
||||||
import org.osgi.service.cm.ConfigurationException;
|
import org.osgi.service.cm.ConfigurationException;
|
||||||
import org.osgi.service.cm.ManagedService;
|
import org.osgi.service.cm.ManagedService;
|
||||||
|
import sun.util.LocaleServiceProviderPool;
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
import javax.jms.ConnectionFactory;
|
||||||
import javax.management.remote.JMXServiceURL;
|
import javax.management.remote.JMXServiceURL;
|
||||||
|
@ -73,14 +74,16 @@ public class OsgiConfiguration extends AbstractConfiguration implements ManagedS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updated(Dictionary dictionary) throws ConfigurationException {
|
public void updated(Dictionary dictionary) throws ConfigurationException {
|
||||||
jmxUrl = dictionary != null ? (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_URL) : null;
|
if (dictionary != null) {
|
||||||
if (jmxUrl == null) {
|
jmxUrl = (String) dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_URL);
|
||||||
throw new IllegalArgumentException("A JMS-url must be specified (system property " + SystemPropertiesConfiguration.PROPERTY_JMX_URL);
|
if (jmxUrl == null) {
|
||||||
|
throw new IllegalArgumentException("A JMS-url must be specified (system property " + SystemPropertiesConfiguration.PROPERTY_JMX_URL);
|
||||||
|
}
|
||||||
|
jmxUser = (String) dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_USER);
|
||||||
|
jmxPassword = (String) dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_PASSWORD);
|
||||||
|
jmsUrl = (String) dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMS_URL);
|
||||||
|
jmsUser = (String) dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMS_USER);
|
||||||
|
jmsPassword = (String) dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMS_PASSWORD);
|
||||||
}
|
}
|
||||||
jmxUser = (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_USER);
|
|
||||||
jmxPassword = (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_PASSWORD);
|
|
||||||
jmxUrl = (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMS_URL);
|
|
||||||
jmsUser = (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMS_USER);
|
|
||||||
jmsPassword = (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMS_PASSWORD);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue