Author: tabish
Date: Tue Feb  9 16:03:58 2010
New Revision: 908092

URL: http://svn.apache.org/viewvc?rev=908092&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2352 JMX user / pass swapped fix

Modified:
    
activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java

Modified: 
activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java?rev=908092&r1=908091&r2=908092&view=diff
==============================================================================
--- 
activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java
 (original)
+++ 
activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java
 Tue Feb  9 16:03:58 2010
@@ -26,79 +26,79 @@
 
 /**
  * Configuration based on JNDI values.
- * 
+ *
  * @version $Revision: $
  */
 public class JNDIConfiguration extends AbstractConfiguration {
 
-       private static final String JNDI_JMS_CONNECTION_FACTORY = 
"java:comp/env/jms/connectionFactory";
-       private static final String JNDI_JMS_URL = "java:comp/env/jms/url";
-       private static final String JNDI_JMS_USER = "java:comp/env/jms/user";
-       private static final String JNDI_JMS_PASSWORD = 
"java:comp/env/jms/password";
-
-       private static final String JNDI_JMX_URL = "java:comp/env/jmx/url";
-       private static final String JNDI_JMX_USER = "java:comp/env/jmx/user";
-       private static final String JNDI_JMX_PASSWORD = 
"java:comp/env/jmx/password";
-
-       private InitialContext context;
-
-       public JNDIConfiguration() throws NamingException {
-               this.context = new InitialContext();
-       }
-
-       public JNDIConfiguration(InitialContext context) {
-               this.context = context;
-       }
-
-       public ConnectionFactory getConnectionFactory() {
-               try {
-                       ConnectionFactory connectionFactory = 
(ConnectionFactory) this.context
-                                       .lookup(JNDI_JMS_CONNECTION_FACTORY);
-                       return connectionFactory;
-               } catch (NameNotFoundException e) {
-                       // try to find an url
-               } catch (NamingException e) {
-                       throw new RuntimeException(e);
-               }
-
-               try {
-                       String jmsUrl = (String) 
this.context.lookup(JNDI_JMS_URL);
-                       if (jmsUrl == null) {
-                               throw new IllegalArgumentException(
-                                               "A JMS-url must be specified 
(system property "
-                                                               + JNDI_JMS_URL);
-                       }
-
-                       String jmsUser = getJndiString(JNDI_JMS_USER);
-                       String jmsPassword = getJndiString(JNDI_JMS_PASSWORD);
-                       return makeConnectionFactory(jmsUrl, jmsUser, 
jmsPassword);
-               } catch (NameNotFoundException e) {
-                       throw new IllegalArgumentException(
-                                       "Neither a ConnectionFactory nor a 
JMS-url were specified");
-               } catch (NamingException e) {
-                       throw new RuntimeException(e);
-               }
-       }
-
-       protected String getJndiString(String name) {
-               try {
-                       return (String) this.context.lookup(name);
-               } catch (NamingException e) {
-                       return null;
-               }
-       }
-
-       public Collection<JMXServiceURL> getJmxUrls() {
-               String jmxUrls = getJndiString(JNDI_JMX_URL);
-               return makeJmxUrls(jmxUrls);
-       }
-
-       public String getJmxPassword() {
-               return getJndiString(JNDI_JMX_USER);
-       }
-
-       public String getJmxUser() {
-               return getJndiString(JNDI_JMX_PASSWORD);
-       }
+    private static final String JNDI_JMS_CONNECTION_FACTORY = 
"java:comp/env/jms/connectionFactory";
+    private static final String JNDI_JMS_URL = "java:comp/env/jms/url";
+    private static final String JNDI_JMS_USER = "java:comp/env/jms/user";
+    private static final String JNDI_JMS_PASSWORD = 
"java:comp/env/jms/password";
+
+    private static final String JNDI_JMX_URL = "java:comp/env/jmx/url";
+    private static final String JNDI_JMX_USER = "java:comp/env/jmx/user";
+    private static final String JNDI_JMX_PASSWORD = 
"java:comp/env/jmx/password";
+
+    private InitialContext context;
+
+    public JNDIConfiguration() throws NamingException {
+        this.context = new InitialContext();
+    }
+
+    public JNDIConfiguration(InitialContext context) {
+        this.context = context;
+    }
+
+    public ConnectionFactory getConnectionFactory() {
+        try {
+            ConnectionFactory connectionFactory = (ConnectionFactory) 
this.context
+                    .lookup(JNDI_JMS_CONNECTION_FACTORY);
+            return connectionFactory;
+        } catch (NameNotFoundException e) {
+            // try to find an url
+        } catch (NamingException e) {
+            throw new RuntimeException(e);
+        }
+
+        try {
+            String jmsUrl = (String) this.context.lookup(JNDI_JMS_URL);
+            if (jmsUrl == null) {
+                throw new IllegalArgumentException(
+                        "A JMS-url must be specified (system property "
+                                + JNDI_JMS_URL);
+            }
+
+            String jmsUser = getJndiString(JNDI_JMS_USER);
+            String jmsPassword = getJndiString(JNDI_JMS_PASSWORD);
+            return makeConnectionFactory(jmsUrl, jmsUser, jmsPassword);
+        } catch (NameNotFoundException e) {
+            throw new IllegalArgumentException(
+                    "Neither a ConnectionFactory nor a JMS-url were 
specified");
+        } catch (NamingException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected String getJndiString(String name) {
+        try {
+            return (String) this.context.lookup(name);
+        } catch (NamingException e) {
+            return null;
+        }
+    }
+
+    public Collection<JMXServiceURL> getJmxUrls() {
+        String jmxUrls = getJndiString(JNDI_JMX_URL);
+        return makeJmxUrls(jmxUrls);
+    }
+
+    public String getJmxPassword() {
+        return getJndiString(JNDI_JMX_PASSWORD);
+    }
+
+    public String getJmxUser() {
+        return getJndiString(JNDI_JMX_USER);
+    }
 
-}
\ No newline at end of file
+}


Reply via email to