
org.apache.activemq.plugin.DefaultConfigurationProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activemq-runtime-config Show documentation
Show all versions of activemq-runtime-config Show documentation
ActiveMQ Runtime Configuration
/**
* 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.plugin;
import org.apache.activemq.util.IntrospectionSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBElement;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
import org.apache.activemq.schema.core.DtoBroker;
public class DefaultConfigurationProcessor implements ConfigurationProcessor {
public static final Logger LOG = LoggerFactory.getLogger(DefaultConfigurationProcessor.class);
RuntimeConfigurationBroker plugin;
Class configurationClass;
Pattern matchPassword = Pattern.compile("password=.*,");
public DefaultConfigurationProcessor(RuntimeConfigurationBroker plugin, Class configurationClass) {
this.plugin = plugin;
this.configurationClass = configurationClass;
}
@Override
public void processChanges(DtoBroker currentConfiguration, DtoBroker modifiedConfiguration) {
List current = filter(currentConfiguration, configurationClass);
List modified = filter(modifiedConfiguration, configurationClass);
if (current.equals(modified)) {
plugin.debug("no changes to " + configurationClass.getSimpleName());
return;
} else {
plugin.info("changes to " + configurationClass.getSimpleName());
}
processChanges(current, modified);
}
public void processChanges(List current, List modified) {
int modIndex = 0, currentIndex = 0;
for (; modIndex < modified.size() && currentIndex < current.size(); modIndex++, currentIndex++) {
// walk the list for mods
applyModifications(getContents(current.get(currentIndex)),
getContents(modified.get(modIndex)));
}
for (; modIndex < modified.size(); modIndex++) {
// new element; add all
for (Object nc : getContents(modified.get(modIndex))) {
ConfigurationProcessor processor = findProcessor(nc);
if (processor != null) {
processor.addNew(nc);
} else {
addNew(nc);
}
}
}
for (; currentIndex < current.size(); currentIndex++) {
// removal of element; remove all
for (Object nc : getContents(current.get(currentIndex))) {
ConfigurationProcessor processor = findProcessor(nc);
if (processor != null) {
processor.remove(nc);
} else {
remove(nc);
}
}
}
}
protected void applyModifications(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy