1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.activemq.web.config; 18 19 import java.util.Collection; 20 21 import javax.jms.ConnectionFactory; 22 import javax.management.remote.JMXServiceURL; 23 24 25 /** 26 * Configuration based on system-properties. 27 * 28 * @version $Revision: $ 29 */ 30 public class SystemPropertiesConfiguration extends AbstractConfiguration { 31 32 private static final String PROPERTY_JMS_URL = "webconsole.jms.url"; 33 private static final String PROPERTY_JMS_USER = "webconsole.jms.user"; 34 private static final String PROPERTY_JMS_PASSWORD = "webconsole.jms.password"; 35 36 private static final String PROPERTY_JMX_URL = "webconsole.jmx.url"; 37 private static final String PROPERTY_JMX_USER = "webconsole.jmx.user"; 38 private static final String PROPERTY_JMX_PASSWORD = "webconsole.jmx.password"; 39 40 public ConnectionFactory getConnectionFactory() { 41 String jmsUrl = System.getProperty(PROPERTY_JMS_URL); 42 if (jmsUrl == null) 43 throw new IllegalArgumentException( 44 "A JMS-url must be specified (system property " 45 + PROPERTY_JMS_URL); 46 47 String jmsUser = System.getProperty(PROPERTY_JMS_USER); 48 String jmsPassword = System.getProperty(PROPERTY_JMS_PASSWORD); 49 return makeConnectionFactory(jmsUrl, jmsUser, jmsPassword); 50 } 51 52 public Collection<JMXServiceURL> getJmxUrls() { 53 String jmxUrls = System.getProperty(PROPERTY_JMX_URL); 54 return makeJmxUrls(jmxUrls); 55 } 56 57 public String getJmxPassword() { 58 return System.getProperty(PROPERTY_JMX_PASSWORD); 59 } 60 61 public String getJmxUser() { 62 return System.getProperty(PROPERTY_JMX_USER); 63 } 64 65 }