Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 77968 invoked from network); 9 Feb 2010 16:06:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Feb 2010 16:06:23 -0000 Received: (qmail 48444 invoked by uid 500); 9 Feb 2010 16:06:23 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 48384 invoked by uid 500); 9 Feb 2010 16:06:23 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 48375 invoked by uid 99); 9 Feb 2010 16:06:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Feb 2010 16:06:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Feb 2010 16:06:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EF80D23888E7; Tue, 9 Feb 2010 16:06:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r908093 - /activemq/branches/activemq-5.3/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java Date: Tue, 09 Feb 2010 16:06:01 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100209160601.EF80D23888E7@eris.apache.org> Author: tabish Date: Tue Feb 9 16:06:01 2010 New Revision: 908093 URL: http://svn.apache.org/viewvc?rev=908093&view=rev Log: https://issues.apache.org/activemq/browse/AMQ-2352 JMX user / pass swapped fix Modified: activemq/branches/activemq-5.3/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java Modified: activemq/branches/activemq-5.3/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java?rev=908093&r1=908092&r2=908093&view=diff ============================================================================== --- activemq/branches/activemq-5.3/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java (original) +++ activemq/branches/activemq-5.3/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java Tue Feb 9 16:06:01 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 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 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 +}