Repository: activemq-artemis Updated Branches: refs/heads/master 3cb5883aa -> 67d493ee0
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java ---------------------------------------------------------------------- diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java index c0a7702..d10ede8 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java @@ -23,11 +23,6 @@ import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; public class ConnectionFactoryProperties implements ConnectionFactoryOptions { - /** - * Trace enabled - */ - private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled(); - private boolean hasBeenUpdated = false; /** @@ -181,14 +176,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public String getConnectionLoadBalancingPolicyClassName() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getConnectionLoadBalancingPolicyClassName()"); } return connectionLoadBalancingPolicyClassName; } public void setConnectionLoadBalancingPolicyClassName(final String connectionLoadBalancingPolicyClassName) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setSessionDefaultType(" + connectionLoadBalancingPolicyClassName + ")"); } hasBeenUpdated = true; @@ -196,14 +191,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public String getDiscoveryAddress() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getDiscoveryAddress()"); } return discoveryAddress; } public void setDiscoveryAddress(final String discoveryAddress) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setDiscoveryAddress(" + discoveryAddress + ")"); } hasBeenUpdated = true; @@ -211,14 +206,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getDiscoveryPort() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getDiscoveryPort()"); } return discoveryPort; } public void setDiscoveryLocalBindAddress(final String discoveryLocalBindAddress) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setDiscoveryLocalBindAddress(" + discoveryLocalBindAddress + ")"); } hasBeenUpdated = true; @@ -226,14 +221,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public String getDiscoveryLocalBindAddress() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getDiscoveryLocalBindAddress()"); } return discoveryLocalBindAddress; } public void setDiscoveryPort(final Integer discoveryPort) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setDiscoveryPort(" + discoveryPort + ")"); } hasBeenUpdated = true; @@ -241,14 +236,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getDiscoveryRefreshTimeout() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getDiscoveryRefreshTimeout()"); } return discoveryRefreshTimeout; } public void setDiscoveryRefreshTimeout(final Long discoveryRefreshTimeout) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setDiscoveryRefreshTimeout(" + discoveryRefreshTimeout + ")"); } hasBeenUpdated = true; @@ -256,14 +251,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getDiscoveryInitialWaitTimeout() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getDiscoveryInitialWaitTimeout()"); } return discoveryInitialWaitTimeout; } public void setDiscoveryInitialWaitTimeout(final Long discoveryInitialWaitTimeout) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setDiscoveryInitialWaitTimeout(" + discoveryInitialWaitTimeout + ")"); } hasBeenUpdated = true; @@ -271,14 +266,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public String getClientID() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getClientID()"); } return clientID; } public void setClientID(final String clientID) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setClientID(" + clientID + ")"); } hasBeenUpdated = true; @@ -286,14 +281,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getDupsOKBatchSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getDupsOKBatchSize()"); } return dupsOKBatchSize; } public void setDupsOKBatchSize(final Integer dupsOKBatchSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setDupsOKBatchSize(" + dupsOKBatchSize + ")"); } hasBeenUpdated = true; @@ -301,14 +296,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getTransactionBatchSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getTransactionBatchSize()"); } return transactionBatchSize; } public void setTransactionBatchSize(final Integer transactionBatchSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setTransactionBatchSize(" + transactionBatchSize + ")"); } hasBeenUpdated = true; @@ -316,14 +311,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getClientFailureCheckPeriod() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getClientFailureCheckPeriod()"); } return clientFailureCheckPeriod; } public void setClientFailureCheckPeriod(final Long clientFailureCheckPeriod) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setClientFailureCheckPeriod(" + clientFailureCheckPeriod + ")"); } hasBeenUpdated = true; @@ -331,14 +326,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getConnectionTTL() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getConnectionTTL()"); } return connectionTTL; } public void setConnectionTTL(final Long connectionTTL) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setConnectionTTL(" + connectionTTL + ")"); } hasBeenUpdated = true; @@ -346,14 +341,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getCallTimeout() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getCallTimeout()"); } return callTimeout; } public void setCallTimeout(final Long callTimeout) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setCallTimeout(" + callTimeout + ")"); } hasBeenUpdated = true; @@ -361,14 +356,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getCallFailoverTimeout() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getCallFailoverTimeout()"); } return callFailoverTimeout; } public void setCallFailoverTimeout(final Long callFailoverTimeout) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setCallFailoverTimeout(" + callFailoverTimeout + ")"); } hasBeenUpdated = true; @@ -376,14 +371,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getConsumerWindowSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getConsumerWindowSize()"); } return consumerWindowSize; } public void setConsumerWindowSize(final Integer consumerWindowSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setConsumerWindowSize(" + consumerWindowSize + ")"); } hasBeenUpdated = true; @@ -391,14 +386,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getConsumerMaxRate() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getConsumerMaxRate()"); } return consumerMaxRate; } public void setConsumerMaxRate(final Integer consumerMaxRate) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setConsumerMaxRate(" + consumerMaxRate + ")"); } hasBeenUpdated = true; @@ -406,14 +401,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getConfirmationWindowSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getConfirmationWindowSize()"); } return confirmationWindowSize; } public void setConfirmationWindowSize(final Integer confirmationWindowSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setConfirmationWindowSize(" + confirmationWindowSize + ")"); } hasBeenUpdated = true; @@ -430,14 +425,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getProducerMaxRate() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getProducerMaxRate()"); } return producerMaxRate; } public void setProducerMaxRate(final Integer producerMaxRate) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setProducerMaxRate(" + producerMaxRate + ")"); } hasBeenUpdated = true; @@ -445,14 +440,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getProducerWindowSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getProducerWindowSize()"); } return producerWindowSize; } public void setProducerWindowSize(final Integer producerWindowSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setProducerWindowSize(" + producerWindowSize + ")"); } hasBeenUpdated = true; @@ -460,14 +455,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getMinLargeMessageSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getMinLargeMessageSize()"); } return minLargeMessageSize; } public void setMinLargeMessageSize(final Integer minLargeMessageSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setMinLargeMessageSize(" + minLargeMessageSize + ")"); } hasBeenUpdated = true; @@ -475,14 +470,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isBlockOnAcknowledge() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isBlockOnAcknowledge()"); } return blockOnAcknowledge; } public void setBlockOnAcknowledge(final Boolean blockOnAcknowledge) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setBlockOnAcknowledge(" + blockOnAcknowledge + ")"); } hasBeenUpdated = true; @@ -490,14 +485,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isBlockOnNonDurableSend() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isBlockOnNonDurableSend()"); } return blockOnNonDurableSend; } public void setBlockOnNonDurableSend(final Boolean blockOnNonDurableSend) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setBlockOnNonDurableSend(" + blockOnNonDurableSend + ")"); } hasBeenUpdated = true; @@ -505,14 +500,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isBlockOnDurableSend() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isBlockOnDurableSend()"); } return blockOnDurableSend; } public void setBlockOnDurableSend(final Boolean blockOnDurableSend) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setBlockOnDurableSend(" + blockOnDurableSend + ")"); } hasBeenUpdated = true; @@ -520,14 +515,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isAutoGroup() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isAutoGroup()"); } return autoGroup; } public void setAutoGroup(final Boolean autoGroup) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setAutoGroup(" + autoGroup + ")"); } hasBeenUpdated = true; @@ -535,14 +530,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isPreAcknowledge() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isPreAcknowledge()"); } return preAcknowledge; } public void setPreAcknowledge(final Boolean preAcknowledge) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setPreAcknowledge(" + preAcknowledge + ")"); } hasBeenUpdated = true; @@ -550,14 +545,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Long getRetryInterval() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getRetryInterval()"); } return retryInterval; } public void setRetryInterval(final Long retryInterval) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setRetryInterval(" + retryInterval + ")"); } hasBeenUpdated = true; @@ -565,14 +560,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Double getRetryIntervalMultiplier() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getRetryIntervalMultiplier()"); } return retryIntervalMultiplier; } public void setRetryIntervalMultiplier(final Double retryIntervalMultiplier) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setRetryIntervalMultiplier(" + retryIntervalMultiplier + ")"); } hasBeenUpdated = true; @@ -589,14 +584,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getReconnectAttempts() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getReconnectAttempts()"); } return reconnectAttempts; } public void setReconnectAttempts(final Integer reconnectAttempts) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setReconnectAttempts(" + reconnectAttempts + ")"); } hasBeenUpdated = true; @@ -604,14 +599,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isUseGlobalPools() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isUseGlobalPools()"); } return useGlobalPools; } public void setUseGlobalPools(final Boolean useGlobalPools) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setUseGlobalPools(" + useGlobalPools + ")"); } hasBeenUpdated = true; @@ -619,14 +614,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isCacheDestinations() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isCacheDestinations()"); } return cacheDestinations; } public void setCacheDestinations(final Boolean cacheDestinations) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setCacheDestinations(" + cacheDestinations + ")"); } hasBeenUpdated = true; @@ -634,14 +629,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Boolean isEnable1xPrefixes() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("isEnable1xPrefixes()"); } return enable1xPrefixes; } public void setEnable1xPrefixes(final Boolean enable1xPrefixes) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setEnable1xPrefixes(" + enable1xPrefixes + ")"); } hasBeenUpdated = true; @@ -649,14 +644,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getScheduledThreadPoolMaxSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getScheduledThreadPoolMaxSize()"); } return scheduledThreadPoolMaxSize; } public void setScheduledThreadPoolMaxSize(final Integer scheduledThreadPoolMaxSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setScheduledThreadPoolMaxSize(" + scheduledThreadPoolMaxSize + ")"); } hasBeenUpdated = true; @@ -664,14 +659,14 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getThreadPoolMaxSize() { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getThreadPoolMaxSize()"); } return threadPoolMaxSize; } public void setThreadPoolMaxSize(final Integer threadPoolMaxSize) { - if (ConnectionFactoryProperties.trace) { + if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setThreadPoolMaxSize(" + threadPoolMaxSize + ")"); } hasBeenUpdated = true; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/pom.xml ---------------------------------------------------------------------- diff --git a/artemis-server/pom.xml b/artemis-server/pom.xml index 7e7c162..f24731b 100644 --- a/artemis-server/pom.xml +++ b/artemis-server/pom.xml @@ -51,7 +51,6 @@ <dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>jboss-logmanager</artifactId> - <scope>test</scope> </dependency> <dependency> <groupId>org.apache.activemq</groupId> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index 20a6cfc..ee01e7e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -329,7 +329,7 @@ public interface ActiveMQServerLogger extends BasicLogger { void removingBackupData(String path); @LogMessage(level = Logger.Level.INFO) - @Message(id = 221056, value = "Reloading configuration ...{0}", + @Message(id = 221056, value = "Reloading configuration: {0}", format = Message.Format.MESSAGE_FORMAT) void reloadingConfiguration(String module); @@ -1603,6 +1603,16 @@ public interface ActiveMQServerLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void problemDeployingQueue(String queueName, String message); + @LogMessage(level = Logger.Level.WARN) + @Message(id = 222276, value = "Failed to process changes to the logging configuration file: {0}", + format = Message.Format.MESSAGE_FORMAT) + void loggingReloadFailed(String configFile, @Cause Exception e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 222277, value = "Problem initializing automatic logging configuration reload for {0}", + format = Message.Format.MESSAGE_FORMAT) + void problemAddingConfigReloadCallback(String propertyName, @Cause Exception e); + @LogMessage(level = Logger.Level.ERROR) @Message(id = 224000, value = "Failure in initialisation", format = Message.Format.MESSAGE_FORMAT) void initializationError(@Cause Throwable e); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationFileReloader.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationFileReloader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationFileReloader.java new file mode 100644 index 0000000..26fdf29 --- /dev/null +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationFileReloader.java @@ -0,0 +1,86 @@ +/** + * 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.core.server; + +import java.io.InputStream; +import java.net.URL; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import org.apache.activemq.artemis.core.server.reload.ReloadCallback; +import org.jboss.logmanager.Configurator; +import org.jboss.logmanager.LogContext; +import org.jboss.logmanager.PropertyConfigurator; +import org.jboss.logmanager.config.LogContextConfiguration; + +public class LoggingConfigurationFileReloader implements ReloadCallback { + + private final Lock lock = new ReentrantLock(); + private final org.jboss.logmanager.Logger.AttachmentKey<LoggingConfigurationUpdater> KEY = new org.jboss.logmanager.Logger.AttachmentKey<>(); + + @Override + public void reload(URL uri) throws Exception { + ActiveMQServerLogger.LOGGER.reloadingConfiguration("logging"); + final LoggingConfigurationUpdater updater = getOrCreateUpdater(); + if (updater == null) { + ActiveMQServerLogger.LOGGER.loggingReloadFailed(uri.toString(), null); + return; + } + try (InputStream in = uri.openStream()) { + lock.lock(); + updater.configure(in); + } catch (Exception e) { + ActiveMQServerLogger.LOGGER.loggingReloadFailed(uri.toString(), e); + } finally { + lock.unlock(); + } + } + + private LoggingConfigurationUpdater getOrCreateUpdater() { + final LogContext logContext = LogContext.getLogContext(); + final org.jboss.logmanager.Logger rootLogger = logContext.getLogger(""); + LoggingConfigurationUpdater updater = rootLogger.getAttachment(KEY); + if (updater == null) { + final LogContextConfiguration logContextConfiguration = getOrCreateConfiguration(rootLogger); + if (logContextConfiguration == null) { + return null; + } + updater = new LoggingConfigurationUpdater(logContextConfiguration); + final LoggingConfigurationUpdater appearing = rootLogger.attachIfAbsent(KEY, updater); + if (appearing != null) { + updater = appearing; + } + } + return updater; + } + + private LogContextConfiguration getOrCreateConfiguration(final org.jboss.logmanager.Logger rootLogger) { + Configurator configurator = rootLogger.getAttachment(Configurator.ATTACHMENT_KEY); + if (configurator == null) { + configurator = new PropertyConfigurator(rootLogger.getLogContext()); + final Configurator appearing = rootLogger.attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator); + if (appearing != null) { + configurator = appearing; + } + } + if (configurator instanceof PropertyConfigurator) { + return ((PropertyConfigurator) configurator).getLogContextConfiguration(); + } + return null; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationUpdater.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationUpdater.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationUpdater.java new file mode 100644 index 0000000..f8be8e9 --- /dev/null +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LoggingConfigurationUpdater.java @@ -0,0 +1,447 @@ +/* + * 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.core.server; + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.Properties; +import java.util.regex.Pattern; + +import org.jboss.logmanager.config.ErrorManagerConfiguration; +import org.jboss.logmanager.config.FilterConfiguration; +import org.jboss.logmanager.config.FormatterConfiguration; +import org.jboss.logmanager.config.HandlerConfiguration; +import org.jboss.logmanager.config.HandlerContainingConfigurable; +import org.jboss.logmanager.config.LogContextConfiguration; +import org.jboss.logmanager.config.LoggerConfiguration; +import org.jboss.logmanager.config.PojoConfiguration; +import org.jboss.logmanager.config.PropertyConfigurable; +import org.jboss.logmanager.config.ValueExpression; + +public class LoggingConfigurationUpdater { + + private static final String[] EMPTY_STRINGS = new String[0]; + private static final Pattern EXPRESSION_PATTERN = Pattern.compile(".*\\$\\{.*\\}.*"); + private static final String LOGGERS = "loggers"; + private static final String HANDLERS = "handlers"; + private static final String FILTERS = "filters"; + private static final String FORMATTERS = "formatters"; + private static final String ERROR_MANAGERS = "errorManagers"; + private static final String POJOS = "pojos"; + private static final String LOGGER = "logger"; + private static final String LEVEL = "level"; + private static final String HANDLER = "handler"; + private static final String FORMATTER = "formatter"; + private static final String ENCODING = "encoding"; + private static final String ERROR_MANAGER = "errorManager"; + private static final String POST_CONFIGURATION = "postConfiguration"; + private static final String POJO = "pojo"; + private static final String MODULE = "module"; + private static final String PROPERTIES = "properties"; + private static final String FILTER = "filter"; + private static final String CONSTRUCTOR_PROPERTIES = "constructorProperties"; + private static final String USE_PARENT_HANDLERS = "useParentHandlers"; + + private final LogContextConfiguration config; + + public LoggingConfigurationUpdater(final LogContextConfiguration config) { + this.config = config; + } + + /** + * {@inheritDoc} + */ + public void configure(final InputStream inputStream) throws IOException { + final Properties properties = new Properties(); + try { + properties.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + inputStream.close(); + } finally { + safeClose(inputStream); + } + configure(properties); + } + + /** + * Configure the log manager from the given properties. + * <p/> + * The following values read in from a configuration will be trimmed of prefixed and trailing whitespace: + * <pre> + * <ul> + * <li>logger.NAME.filter</li> + * <li>logger.NAME.level</li> + * <li>logger.NAME.useParentHandlers</li> + * <li>handler.NAME.filter</li> + * <li>handler.NAME.formatter</li> + * <li>handler.NAME.level</li> + * <li>handler.NAME.encoding</li> + * <li>handler.NAME.errorManager</li> + * </ul> + * </pre> + * + * @param properties the properties + */ + private void configure(final Properties properties) { + try { + final Collection<String> handlersToRemove = config.getHandlerNames(); + // Start with the list of loggers to configure. The root logger is always on the list. + handlersToRemove.removeAll(configureLogger(properties, "")); + + // And, for each logger name, configure any filters, handlers, etc. + final String[] loggerNames = getStringCsvArray(properties, LOGGERS); + for (String loggerName : loggerNames) { + handlersToRemove.removeAll(configureLogger(properties, loggerName)); + } + // Remove any loggers that are not longer required + final Collection<String> loggersToRemove = config.getLoggerNames(); + loggersToRemove.remove(""); + loggersToRemove.removeAll(Arrays.asList(loggerNames)); + for (String loggerName : loggersToRemove) { + config.removeLoggerConfiguration(loggerName); + } + + // Configure any declared handlers. + final String[] handlerNames = getStringCsvArray(properties, HANDLERS); + for (String handlerName : handlerNames) { + configureHandler(properties, handlerName); + } + // Remove any handlers that are not longer required + handlersToRemove.removeAll(Arrays.asList(handlerNames)); + for (String handlerName : handlersToRemove) { + config.removeHandlerConfiguration(handlerName); + } + + // Configure any declared filters. + for (String filterName : getStringCsvArray(properties, FILTERS)) { + configureFilter(properties, filterName); + } + + // Configure any declared formatters. + for (String formatterName : getStringCsvArray(properties, FORMATTERS)) { + configureFormatter(properties, formatterName); + } + + // Configure any declared error managers. + for (String errorManagerName : getStringCsvArray(properties, ERROR_MANAGERS)) { + configureErrorManager(properties, errorManagerName); + } + + // Configure POJOs + for (String pojoName : getStringCsvArray(properties, POJOS)) { + configurePojos(properties, pojoName); + } + config.commit(); + } finally { + config.forget(); + } + } + + private List<String> configureLogger(final Properties properties, final String loggerName) { + final LoggerConfiguration loggerConfiguration; + if (config.getLoggerNames().contains(loggerName)) { + loggerConfiguration = config.getLoggerConfiguration(loggerName); + } else { + loggerConfiguration = config.addLoggerConfiguration(loggerName); + } + + // Get logger level + final String levelName = getStringProperty(properties, getKey(LOGGER, loggerName, LEVEL)); + if (notEqual(levelName, loggerConfiguration.getLevelValueExpression())) { + loggerConfiguration.setLevel(levelName == null ? "ALL" : levelName); + } + + // Get logger filter + final String filterName = getStringProperty(properties, getKey(LOGGER, loggerName, FILTER)); + final ValueExpression<String> newValue = ValueExpression.STRING_RESOLVER.resolve(filterName); + if (notEqual(newValue, loggerConfiguration.getFilterValueExpression())) { + loggerConfiguration.setFilter(filterName); + final String resolvedFilter = loggerConfiguration.getFilterValueExpression().getResolvedValue(); + if (resolvedFilter != null) { + // Check for a filter class + final String filterClassName = getStringProperty(properties, getKey(FILTER, resolvedFilter)); + // If the filter class is null, assume it's a filter expression + if (filterClassName != null) { + configureFilter(properties, resolvedFilter); + } + } + } + + // Get logger handlers + configureHandlerNames(properties, loggerConfiguration, LOGGER, loggerName); + + // Get logger properties + final String useParentHandlersString = getStringProperty(properties, getKey(LOGGER, loggerName, USE_PARENT_HANDLERS)); + if (booleanNotEqual(useParentHandlersString, loggerConfiguration.getUseParentHandlersValueExpression())) { + // Check for expression + if (EXPRESSION_PATTERN.matcher(useParentHandlersString).matches()) { + loggerConfiguration.setUseParentHandlers(useParentHandlersString); + } else { + loggerConfiguration.setUseParentHandlers(Boolean.parseBoolean(useParentHandlersString)); + } + } + return loggerConfiguration.getHandlerNames(); + } + + private void configureFilter(final Properties properties, final String filterName) { + final String className = getStringProperty(properties, getKey(FILTER, filterName)); + if (className == null) { + // Assume we're using a filter expression + return; + } + final FilterConfiguration configuration; + if (config.getFilterNames().contains(filterName)) { + configuration = config.getFilterConfiguration(filterName); + } else { + configuration = config.addFilterConfiguration(getStringProperty(properties, getKey(FILTER, filterName, MODULE)), className, filterName, getStringCsvArray(properties, getKey(FILTER, filterName, CONSTRUCTOR_PROPERTIES))); + } + final String[] postConfigurationMethods = getStringCsvArray(properties, getKey(FILTER, filterName, POST_CONFIGURATION)); + configuration.setPostConfigurationMethods(postConfigurationMethods); + configureProperties(properties, configuration, getKey(FILTER, filterName)); + } + + private boolean configureFormatter(final Properties properties, final String formatterName) { + final String className = getStringProperty(properties, getKey(FORMATTER, formatterName)); + if (className == null) { + printError("Formatter %s is not defined%n", formatterName); + return false; + } + final FormatterConfiguration configuration; + if (config.getFormatterNames().contains(formatterName)) { + configuration = config.getFormatterConfiguration(formatterName); + } else { + configuration = config.addFormatterConfiguration(getStringProperty(properties, getKey(FORMATTER, formatterName, MODULE)), className, formatterName, getStringCsvArray(properties, getKey(FORMATTER, formatterName, CONSTRUCTOR_PROPERTIES))); + } + final String[] postConfigurationMethods = getStringCsvArray(properties, getKey(FORMATTER, formatterName, POST_CONFIGURATION)); + configuration.setPostConfigurationMethods(postConfigurationMethods); + configureProperties(properties, configuration, getKey(FORMATTER, formatterName)); + return true; + } + + private boolean configureErrorManager(final Properties properties, final String errorManagerName) { + final String className = getStringProperty(properties, getKey(ERROR_MANAGER, errorManagerName)); + if (className == null) { + printError("Error manager %s is not defined%n", errorManagerName); + return false; + } + final ErrorManagerConfiguration configuration; + if (config.getErrorManagerNames().contains(errorManagerName)) { + configuration = config.getErrorManagerConfiguration(errorManagerName); + } else { + configuration = config.addErrorManagerConfiguration(getStringProperty(properties, getKey(ERROR_MANAGER, errorManagerName, MODULE)), className, errorManagerName, getStringCsvArray(properties, getKey(ERROR_MANAGER, errorManagerName, CONSTRUCTOR_PROPERTIES))); + } + final String[] postConfigurationMethods = getStringCsvArray(properties, getKey(ERROR_MANAGER, errorManagerName, POST_CONFIGURATION)); + configuration.setPostConfigurationMethods(postConfigurationMethods); + configureProperties(properties, configuration, getKey(ERROR_MANAGER, errorManagerName)); + return true; + } + + private boolean configureHandler(final Properties properties, final String handlerName) { + final String className = getStringProperty(properties, getKey(HANDLER, handlerName)); + if (className == null) { + printError("Handler %s is not defined%n", handlerName); + return false; + } + final HandlerConfiguration configuration; + if (config.getHandlerNames().contains(handlerName)) { + configuration = config.getHandlerConfiguration(handlerName); + } else { + configuration = config.addHandlerConfiguration(getStringProperty(properties, getKey(HANDLER, handlerName, MODULE)), className, handlerName, getStringCsvArray(properties, getKey(HANDLER, handlerName, CONSTRUCTOR_PROPERTIES))); + } + final String filter = getStringProperty(properties, getKey(HANDLER, handlerName, FILTER)); + if (notEqual(filter, configuration.getFilterValueExpression())) { + configuration.setFilter(filter); + final String resolvedFilter = configuration.getFilterValueExpression().getResolvedValue(); + if (resolvedFilter != null) { + // Check for a filter class + final String filterClassName = getStringProperty(properties, getKey(FILTER, resolvedFilter)); + // If the filter class is null, assume it's a filter expression + if (filterClassName != null) { + configureFilter(properties, resolvedFilter); + } + } + } + final String levelName = getStringProperty(properties, getKey(HANDLER, handlerName, LEVEL)); + if (notEqual(levelName, configuration.getLevelValueExpression())) { + configuration.setLevel(levelName == null ? "ALL" : levelName); + } + final String formatterName = getStringProperty(properties, getKey(HANDLER, handlerName, FORMATTER)); + if (formatterName != null) { + if (getStringProperty(properties, getKey(FORMATTER, ValueExpression.STRING_RESOLVER.resolve(formatterName).getResolvedValue())) == null) { + printError("Formatter %s is not defined%n", formatterName); + } else { + final ValueExpression<String> newValue = ValueExpression.STRING_RESOLVER.resolve(formatterName); + if (notEqual(newValue, configuration.getFormatterNameValueExpression())) { + if (configureFormatter(properties, newValue.getResolvedValue())) { + configuration.setFormatterName(formatterName); + } + } + } + } + final String encoding = getStringProperty(properties, getKey(HANDLER, handlerName, ENCODING)); + if (notEqual(encoding, configuration.getEncodingValueExpression())) { + configuration.setEncoding(encoding); + } + final String errorManagerName = getStringProperty(properties, getKey(HANDLER, handlerName, ERROR_MANAGER)); + if (errorManagerName != null) { + if (getStringProperty(properties, getKey(ERROR_MANAGER, ValueExpression.STRING_RESOLVER.resolve(errorManagerName).getResolvedValue())) == null) { + printError("Error manager %s is not defined%n", errorManagerName); + } else { + final ValueExpression<String> newValue = ValueExpression.STRING_RESOLVER.resolve(errorManagerName); + if (notEqual(newValue, configuration.getErrorManagerNameValueExpression())) { + if (configureErrorManager(properties, newValue.getResolvedValue())) { + configuration.setErrorManagerName(errorManagerName); + } + } + } + } + configureHandlerNames(properties, configuration, HANDLER, handlerName); + final String[] postConfigurationMethods = getStringCsvArray(properties, getKey(HANDLER, handlerName, POST_CONFIGURATION)); + configuration.setPostConfigurationMethods(postConfigurationMethods); + configureProperties(properties, configuration, getKey(HANDLER, handlerName)); + return true; + } + + private void configurePojos(final Properties properties, final String pojoName) { + final String className = getStringProperty(properties, getKey(POJO, pojoName)); + if (className == null) { + printError("POJO %s is not defined%n", pojoName); + return; + } + final PojoConfiguration configuration; + if (config.getPojoNames().contains(pojoName)) { + configuration = config.getPojoConfiguration(pojoName); + } else { + configuration = config.addPojoConfiguration(getStringProperty(properties, getKey(POJO, pojoName, MODULE)), getStringProperty(properties, getKey(POJO, pojoName)), pojoName, getStringCsvArray(properties, getKey(POJO, pojoName, CONSTRUCTOR_PROPERTIES))); + } + final String[] postConfigurationMethods = getStringCsvArray(properties, getKey(POJO, pojoName, POST_CONFIGURATION)); + configuration.setPostConfigurationMethods(postConfigurationMethods); + configureProperties(properties, configuration, getKey(POJO, pojoName)); + } + + private void configureProperties(final Properties properties, + final PropertyConfigurable configurable, + final String prefix) { + final List<String> propertyNames = getStringCsvList(properties, getKey(prefix, PROPERTIES)); + for (String propertyName : propertyNames) { + final String valueString = getStringProperty(properties, getKey(prefix, propertyName), false); + if (notEqual(valueString, configurable.getPropertyValueExpression(propertyName))) { + configurable.setPropertyValueString(propertyName, valueString); + } + } + } + + private void configureHandlerNames(final Properties properties, + final HandlerContainingConfigurable configuration, + final String prefix, + final String name) { + final String[] handlerNames = getStringCsvArray(properties, getKey(prefix, name, HANDLERS)); + final Collection<String> availableHandlers = new ArrayList<>(); + for (String handlerName : handlerNames) { + if (configureHandler(properties, handlerName)) { + availableHandlers.add(handlerName); + } + } + configuration.setHandlerNames(availableHandlers); + } + + private static String getKey(final String prefix, final String objectName) { + return objectName.length() > 0 ? prefix + "." + objectName : prefix; + } + + private static String getKey(final String prefix, final String objectName, final String key) { + return objectName.length() > 0 ? prefix + "." + objectName + "." + key : prefix + "." + key; + } + + private static String getStringProperty(final Properties properties, final String key) { + return getStringProperty(properties, key, true); + } + + private static String getStringProperty(final Properties properties, final String key, final boolean trim) { + final String value = properties.getProperty(key); + return (trim ? (value == null ? null : value.trim()) : value); + } + + private static String[] getStringCsvArray(final Properties properties, final String key) { + final String property = properties.getProperty(key, ""); + if (property == null) { + return EMPTY_STRINGS; + } + final String value = property.trim(); + if (value.length() == 0) { + return EMPTY_STRINGS; + } + return value.split("\\s*,\\s*"); + } + + private static List<String> getStringCsvList(final Properties properties, final String key) { + return new ArrayList<>(Arrays.asList(getStringCsvArray(properties, key))); + } + + private static void printError(final String format, final Object... args) { + System.err.printf(format, args); + } + + private static void safeClose(final Closeable stream) { + if (stream != null) + try { + stream.close(); + } catch (Exception e) { + // can't do anything about it + } + } + + private static boolean notEqual(final ValueExpression<String> newValue, final ValueExpression<String> currentValue) { + if (newValue == null) { + return currentValue.getResolvedValue() != null; + } + return !Objects.equals(newValue.getValue(), currentValue.getValue()); + } + + private static boolean notEqual(final String newValue, final ValueExpression<String> currentValue) { + if (newValue == null) { + return currentValue.getResolvedValue() != null; + } + if (currentValue.isExpression()) { + final String resolvedCurrentValue = currentValue.getResolvedValue(); + final String resolvedNewValue = ValueExpression.STRING_RESOLVER.resolve(newValue).getResolvedValue(); + return resolvedCurrentValue == null ? resolvedNewValue != null : !resolvedCurrentValue.equals(resolvedNewValue); + } + return !newValue.equals(currentValue.getValue()); + } + + private static boolean booleanNotEqual(final String newValue, final ValueExpression<Boolean> currentValue) { + if (newValue == null) { + return currentValue.getResolvedValue() != null; + } + if (currentValue.isExpression()) { + final Boolean resolvedCurrentValue = currentValue.getResolvedValue(); + final Boolean resolvedNewValue = ValueExpression.BOOLEAN_RESOLVER.resolve(newValue).getResolvedValue(); + return resolvedCurrentValue == null ? resolvedNewValue != null : !resolvedCurrentValue.equals(resolvedNewValue); + } + return !newValue.equals(currentValue.getValue()); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index a4c0d71..7f5ca86 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.management.ManagementFactory; +import java.net.URI; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; @@ -124,6 +125,7 @@ import org.apache.activemq.artemis.core.server.BindingQueryResult; import org.apache.activemq.artemis.core.server.Divert; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.core.server.LargeServerMessage; +import org.apache.activemq.artemis.core.server.LoggingConfigurationFileReloader; import org.apache.activemq.artemis.core.server.MemoryManager; import org.apache.activemq.artemis.core.server.NetworkHealthCheck; import org.apache.activemq.artemis.core.server.NodeManager; @@ -2574,6 +2576,15 @@ public class ActiveMQServerImpl implements ActiveMQServer { reloadManager.addCallback(configuration.getConfigurationUrl(), new ConfigurationFileReloader()); } + if (System.getProperty("logging.configuration") != null) { + try { + reloadManager.addCallback(new URI(System.getProperty("logging.configuration")).toURL(), new LoggingConfigurationFileReloader()); + } catch (Exception e) { + // a syntax error with the logging system property shouldn't prevent the server from starting + ActiveMQServerLogger.LOGGER.problemAddingConfigReloadCallback(System.getProperty("logging.configuration"), e); + } + } + if (hasBrokerPlugins()) { callBrokerPlugins(plugin -> plugin.registered(this)); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/test/java/org/apache/activemq/artemis/core/reload/LoggingConfigurationFileReloaderTest.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/reload/LoggingConfigurationFileReloaderTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/reload/LoggingConfigurationFileReloaderTest.java new file mode 100644 index 0000000..9f111c6 --- /dev/null +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/reload/LoggingConfigurationFileReloaderTest.java @@ -0,0 +1,117 @@ +/** + * 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.core.reload; + +import java.util.Collections; +import java.util.List; +import java.util.logging.LogManager; + +import org.apache.activemq.artemis.core.server.LoggingConfigurationFileReloader; +import org.apache.activemq.artemis.utils.ClassloadingUtil; +import org.jboss.logging.Logger; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class LoggingConfigurationFileReloaderTest { + + @Test + public void test() throws Exception { + LogManager logManager = LogManager.getLogManager(); + + List loggerNames = Collections.list(logManager.getLoggerNames()); + assertFalse(loggerNames.contains("test1")); + assertFalse(loggerNames.contains("test2")); + assertFalse(loggerNames.contains("test3")); + + // everything defaults to INFO + final Logger root = Logger.getLogger(""); + assertTrue(root.isEnabled(Logger.Level.ERROR)); + assertTrue(root.isEnabled(Logger.Level.WARN)); + assertTrue(root.isEnabled(Logger.Level.INFO)); + assertFalse(root.isEnabled(Logger.Level.DEBUG)); + assertFalse(root.isEnabled(Logger.Level.TRACE)); + + final Logger test1 = Logger.getLogger("test1"); + assertTrue(test1.isEnabled(Logger.Level.ERROR)); + assertTrue(test1.isEnabled(Logger.Level.WARN)); + assertTrue(test1.isEnabled(Logger.Level.INFO)); + assertFalse(test1.isEnabled(Logger.Level.DEBUG)); + assertFalse(test1.isEnabled(Logger.Level.TRACE)); + + final Logger test2 = Logger.getLogger("test2"); + assertTrue(test2.isEnabled(Logger.Level.ERROR)); + assertTrue(test2.isEnabled(Logger.Level.WARN)); + assertTrue(test2.isEnabled(Logger.Level.INFO)); + assertFalse(test2.isEnabled(Logger.Level.DEBUG)); + assertFalse(test2.isEnabled(Logger.Level.TRACE)); + + LoggingConfigurationFileReloader loggingConfigurationFileReloader = new LoggingConfigurationFileReloader(); + loggingConfigurationFileReloader.reload(ClassloadingUtil.findResource("reload-logging-1.properties")); + + loggerNames = Collections.list(logManager.getLoggerNames()); + assertTrue(loggerNames.contains("test1")); + assertTrue(loggerNames.contains("test2")); + assertFalse(loggerNames.contains("test3")); + + assertTrue(root.isEnabled(Logger.Level.ERROR)); + assertTrue(root.isEnabled(Logger.Level.WARN)); + assertFalse(root.isEnabled(Logger.Level.INFO)); + assertFalse(root.isEnabled(Logger.Level.DEBUG)); + assertFalse(root.isEnabled(Logger.Level.TRACE)); + + assertTrue(test1.isEnabled(Logger.Level.ERROR)); + assertTrue(test1.isEnabled(Logger.Level.WARN)); + assertTrue(test1.isEnabled(Logger.Level.INFO)); + assertTrue(test1.isEnabled(Logger.Level.DEBUG)); + assertTrue(test1.isEnabled(Logger.Level.TRACE)); + + assertTrue(test2.isEnabled(Logger.Level.ERROR)); + assertFalse(test2.isEnabled(Logger.Level.WARN)); + assertFalse(test2.isEnabled(Logger.Level.INFO)); + assertFalse(test2.isEnabled(Logger.Level.DEBUG)); + assertFalse(test2.isEnabled(Logger.Level.TRACE)); + + loggingConfigurationFileReloader.reload(ClassloadingUtil.findResource("reload-logging-2.properties")); + + loggerNames = Collections.list(logManager.getLoggerNames()); + assertTrue(loggerNames.contains("test1")); + assertTrue(loggerNames.contains("test2")); + assertTrue(loggerNames.contains("test3")); + + assertTrue(root.isEnabled(Logger.Level.ERROR)); + assertFalse(root.isEnabled(Logger.Level.WARN)); + assertFalse(root.isEnabled(Logger.Level.INFO)); + assertFalse(root.isEnabled(Logger.Level.DEBUG)); + assertFalse(root.isEnabled(Logger.Level.TRACE)); + + assertTrue(test1.isEnabled(Logger.Level.ERROR)); + assertTrue(test1.isEnabled(Logger.Level.WARN)); + assertFalse(test1.isEnabled(Logger.Level.INFO)); + assertFalse(test1.isEnabled(Logger.Level.DEBUG)); + assertFalse(test1.isEnabled(Logger.Level.TRACE)); + + final Logger test3 = Logger.getLogger("test3"); + assertTrue(test3.isEnabled(Logger.Level.ERROR)); + assertTrue(test3.isEnabled(Logger.Level.WARN)); + assertTrue(test3.isEnabled(Logger.Level.INFO)); + assertTrue(test3.isEnabled(Logger.Level.DEBUG)); + assertFalse(test3.isEnabled(Logger.Level.TRACE)); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/test/resources/reload-logging-1.properties ---------------------------------------------------------------------- diff --git a/artemis-server/src/test/resources/reload-logging-1.properties b/artemis-server/src/test/resources/reload-logging-1.properties new file mode 100644 index 0000000..7aba821 --- /dev/null +++ b/artemis-server/src/test/resources/reload-logging-1.properties @@ -0,0 +1,21 @@ +# +# 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. +# + +loggers=test1,test2 +logger.test1.level=TRACE +logger.test2.level=ERROR +logger.level=WARN \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-server/src/test/resources/reload-logging-2.properties ---------------------------------------------------------------------- diff --git a/artemis-server/src/test/resources/reload-logging-2.properties b/artemis-server/src/test/resources/reload-logging-2.properties new file mode 100644 index 0000000..8ff0a5f --- /dev/null +++ b/artemis-server/src/test/resources/reload-logging-2.properties @@ -0,0 +1,21 @@ +# +# 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. +# + +loggers=test1,test3 +logger.test1.level=WARN +logger.test3.level=DEBUG +logger.level=ERROR \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbace51d/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java ---------------------------------------------------------------------- diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java index b80795c..80b7167 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java @@ -48,14 +48,12 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration; */ public class ActiveMQXAResourceRecovery { - private final boolean trace = ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled(); - private boolean hasMore; private ActiveMQXAResourceWrapper res; public ActiveMQXAResourceRecovery() { - if (trace) { + if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { ActiveMQXARecoveryLogger.LOGGER.trace("Constructing ActiveMQXAResourceRecovery"); } }
