All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.activemq.artemis.jms.client.DefaultConnectionProperties Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.activemq.artemis.jms.client;

import java.security.AccessController;
import java.security.PrivilegedAction;

/**
 * 

This class will provide default properties for constructors

* * * * * * * * *
Name Default Value
AMQ_HOST or org.apache.activemq.AMQ_HOST localhost
AMQ_PORT or org.apache.activemq.AMQ_PORT 61616
BROKER_BIND_URL or org.apache.activemq.BROKER_BIND_URL tcp://${AMQ_HOST}:${AMQ_PORT}
AMQ_USER or org.apache.activemq.AMQ_USER null
AMQ_PASSWORD or org.apache.activemq.AMQ_PASSWORD null
*/ public class DefaultConnectionProperties { public static final String DEFAULT_BROKER_HOST; public static final int DEFAULT_BROKER_PORT; public static final String DEFAULT_BROKER_BIND_URL; public static final String DEFAULT_BROKER_URL; public static final String DEFAULT_USER; public static final String DEFAULT_PASSWORD; static String getProperty(final String defaultValue, final String... propertyNames) { return AccessController.doPrivileged(new PrivilegedAction() { @Override public String run() { for (String name : propertyNames) { String property = System.getProperty(name); if (property != null && !property.isEmpty()) { return property; } } return defaultValue; } }); } static { String host = getProperty("localhost", "AMQ_HOST", "org.apache.activemq.AMQ_HOST"); String port = getProperty("61616", "AMQ_PORT", "org.apache.activemq.AMQ_PORT"); DEFAULT_BROKER_HOST = host; DEFAULT_BROKER_PORT = Integer.parseInt(port); String url = getProperty("tcp://" + host + ":" + port, "org.apache.activemq.BROKER_BIND_URL", "BROKER_BIND_URL"); DEFAULT_USER = getProperty(null, "AMQ_USER", "org.apache.activemq.AMQ_USER"); DEFAULT_PASSWORD = getProperty(null, "AMQ_PASSWORD", "org.apache.activemq.AMQ_PASSWORD"); if (DEFAULT_USER != null && DEFAULT_PASSWORD != null) { url += "?user=" + DEFAULT_USER + "&password=" + DEFAULT_PASSWORD; } DEFAULT_BROKER_BIND_URL = url; // TODO: improve this once we implement failover:// as ActiveMQ5 does DEFAULT_BROKER_URL = DEFAULT_BROKER_BIND_URL; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy