activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1441461 - in /activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web: WebConsoleStarter.java config/OsgiConfiguration.java
Date Fri, 01 Feb 2013 14:34:50 GMT
Author: dejanb
Date: Fri Feb  1 14:34:50 2013
New Revision: 1441461

URL: http://svn.apache.org/viewvc?rev=1441461&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-4034 - osgi web console, remove runtime osgi dependency

Modified:
    activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java
    activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java?rev=1441461&r1=1441460&r2=1441461&view=diff
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java
(original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java
Fri Feb  1 14:34:50 2013
@@ -16,25 +16,17 @@
  */
 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.ServiceRegistration;
-import org.osgi.service.cm.ManagedService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
+import javax.jms.ConnectionFactory;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
 
 /**
  * Starts the WebConsole.
@@ -61,13 +53,18 @@ public class WebConsoleStarter implement
         String webconsoleType = System.getProperty("webconsole.type", "embedded");
 
         // detect osgi
-        if (FrameworkUtil.getBundle(getClass()) != null) {
-            webconsoleType = "osgi";
+        try {
+            if (OsgiUtil.isOsgi()) {
+                webconsoleType = "osgi";
+            }
+        } catch (NoClassDefFoundError ignore) {
         }
 
 
         String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
 
+        LOG.info("Web console type: " + webconsoleType);
+
         XmlWebApplicationContext context = new XmlWebApplicationContext();
         context.setServletContext(servletContext);
         context.setConfigLocations(new String[] {
@@ -95,4 +92,10 @@ public class WebConsoleStarter implement
         // do nothing, since the context is destroyed anyway
     }
 
+    static class OsgiUtil {
+        static boolean isOsgi() {
+            return (FrameworkUtil.getBundle(WebConsoleStarter.class) != null);
+        }
+    }
+
 }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java?rev=1441461&r1=1441460&r2=1441461&view=diff
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java
(original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java
Fri Feb  1 14:34:50 2013
@@ -22,6 +22,7 @@ import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
+import sun.util.LocaleServiceProviderPool;
 
 import javax.jms.ConnectionFactory;
 import javax.management.remote.JMXServiceURL;
@@ -73,14 +74,16 @@ public class OsgiConfiguration extends A
 
     @Override
     public void updated(Dictionary dictionary) throws ConfigurationException {
-        jmxUrl = dictionary != null ? (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_URL)
: null;
-        if (jmxUrl == null) {
-            throw new IllegalArgumentException("A JMS-url must be specified (system property
" + SystemPropertiesConfiguration.PROPERTY_JMX_URL);
+        if (dictionary != null) {
+            jmxUrl = (String) dictionary.get(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);
     }
 }



Mime
View raw message