activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1156748 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Date Thu, 11 Aug 2011 19:14:50 GMT
Author: tabish
Date: Thu Aug 11 19:14:50 2011
New Revision: 1156748

URL: http://svn.apache.org/viewvc?rev=1156748&view=rev
Log:
apply patch for: https://issues.apache.org/jira/browse/AMQ-2845

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java?rev=1156748&r1=1156747&r2=1156748&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Thu Aug 11 19:14:50 2011
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -321,14 +322,25 @@ public class BrokerView implements Broke
         // Avoid a direct dependency on log4j.. use reflection.
         try {
             ClassLoader cl = getClass().getClassLoader();
-            Class logManagerClass = cl.loadClass("org.apache.log4j.LogManager");
+            Class<?> logManagerClass = cl.loadClass("org.apache.log4j.LogManager");
 
             Method resetConfiguration = logManagerClass.getMethod("resetConfiguration", new
Class[]{});
             resetConfiguration.invoke(null, new Object[]{});
 
-            URL log4jprops = cl.getResource("log4j.properties");
+            String configurationOptionStr = System.getProperty("log4j.configuration");
+            URL log4jprops = null;
+            if (configurationOptionStr != null) {
+                try {
+                    log4jprops = new URL(configurationOptionStr);
+                } catch (MalformedURLException ex) {
+                    log4jprops = cl.getResource("log4j.properties");
+                }
+            } else {
+               log4jprops = cl.getResource("log4j.properties");
+            }
+
             if (log4jprops != null) {
-                Class propertyConfiguratorClass = cl.loadClass("org.apache.log4j.PropertyConfigurator");
+                Class<?> propertyConfiguratorClass = cl.loadClass("org.apache.log4j.PropertyConfigurator");
                 Method configure = propertyConfiguratorClass.getMethod("configure", new Class[]{URL.class});
                 configure.invoke(null, new Object[]{log4jprops});
             }



Mime
View raw message