<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
import org.osgi.util.tracker.ServiceTracker;
public class ConfigPusherFeatureActivator implements BundleActivator {
-
- BundleContext bc = null;
- ConfigPusherCustomizer cpc = null;
- ServiceTracker<ConfigPusher,ConfigPusher> cpst = null;
+ private BundleContext bc = null;
+ private ConfigPusherCustomizer cpc = null;
+ private ServiceTracker<ConfigPusher, ConfigPusher> cpst = null;
public void start(final BundleContext context) throws Exception {
bc = context;
}
public void stop(final BundleContext context) throws Exception {
- if(cpst != null) {
+ if (cpst != null) {
cpst.close();
cpst = null;
}
- if(cpc != null) {
+ if (cpc != null) {
cpc.close();
cpc = null;
}
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.io.Files;
+
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+
import javax.xml.bind.JAXBException;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
+
import org.apache.karaf.features.BundleInfo;
import org.apache.karaf.features.Capability;
import org.apache.karaf.features.Conditional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
/*
* Wrap a Feature for the purposes of extracting the FeatureConfigSnapshotHolders from
/*
* @param f Feature to wrap
*/
- public AbstractFeatureWrapper(final Feature f) {
- Preconditions.checkNotNull(f,"FeatureWrapper requires non-null Feature in constructor");
- this.feature = f;
+ public AbstractFeatureWrapper(final Feature feature) {
+ Preconditions.checkNotNull(feature, "FeatureWrapper requires non-null Feature in constructor");
+ this.feature = feature;
}
/*
*/
public Set<FeatureConfigSnapshotHolder> getFeatureConfigSnapshotHolders() throws Exception {
final Set<FeatureConfigSnapshotHolder> snapShotHolders = new LinkedHashSet<>();
- for(final ConfigFileInfo c: getConfigurationFiles()) {
+ for (final ConfigFileInfo c : getConfigurationFiles()) {
// Skip non config snapshot XML files
- if(isConfigSnapshot(c.getFinalname())) {
- final Optional<FeatureConfigSnapshotHolder> featureConfigSnapshotHolder = getFeatureConfigSnapshotHolder(c);
- if(featureConfigSnapshotHolder.isPresent()) {
+ if (isConfigSnapshot(c.getFinalname())) {
+ final Optional<FeatureConfigSnapshotHolder> featureConfigSnapshotHolder =
+ getFeatureConfigSnapshotHolder(c);
+ if (featureConfigSnapshotHolder.isPresent()) {
snapShotHolders.add(featureConfigSnapshotHolder.get());
}
}
return snapShotHolders;
}
- protected Optional<FeatureConfigSnapshotHolder> getFeatureConfigSnapshotHolder(final ConfigFileInfo c) {
+ protected Optional<FeatureConfigSnapshotHolder>
+ getFeatureConfigSnapshotHolder(final ConfigFileInfo configFileInfo) {
try {
- return Optional.of(new FeatureConfigSnapshotHolder(c, this));
+ return Optional.of(new FeatureConfigSnapshotHolder(configFileInfo, this));
} catch (final JAXBException e) {
- LOG.warn("Unable to parse configuration snapshot. Config from '{}' will be IGNORED. " +
- "Note that subsequent config files may fail due to this problem. " +
- "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
- c.getFinalname(), e);
+ LOG.warn("Unable to parse configuration snapshot. Config from '{}' will be IGNORED. "
+ + "Note that subsequent config files may fail due to this problem. "
+ + "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
+ configFileInfo.getFinalname(), e);
} catch (final XMLStreamException e) {
// Files that cannot be loaded are ignored as non config subsystem files e.g. jetty.xml
LOG.debug("Unable to read configuration file '{}'. Not a configuration snapshot",
- c.getFinalname(), e);
+ configFileInfo.getFinalname(), e);
}
return Optional.absent();
}
private static boolean isConfigSnapshot(final String fileName) {
- if(!Files.getFileExtension(fileName).equals(CONFIG_FILE_SUFFIX)) {
+ if (!Files.getFileExtension(fileName).equals(CONFIG_FILE_SUFFIX)) {
return false;
}
- if(fileName.endsWith("jetty.xml")) {
+ if (fileName.endsWith("jetty.xml")) {
// Special case - ignore the jetty.xml file as it contains a DTD and causes a "Connection refused"
// error when it tries to go out to the network to retrieve it. We don't want it trying to go out
// to the network nor do we want an error logged trying to parse it.
}
File file = new File(System.getProperty("karaf.home"), fileName);
- try(FileInputStream fis = new FileInputStream(file)) {
+ try (FileInputStream fis = new FileInputStream(file)) {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
builderFactory.setCoalescing(true);
Element root = builderFactory.newDocumentBuilder().parse(fis).getDocumentElement();
return ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME.equals(root.getLocalName());
- } catch (final Exception e) {
+ } catch (final ParserConfigurationException | IOException | SAXException e) {
LOG.error("Could not parse XML file {}", file, e);
return false;
}
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+
import org.apache.felix.utils.version.VersionRange;
import org.apache.felix.utils.version.VersionTable;
import org.apache.karaf.features.Dependency;
*/
public class ChildAwareFeatureWrapper extends AbstractFeatureWrapper implements Feature {
private static final Logger LOG = LoggerFactory.getLogger(ChildAwareFeatureWrapper.class);
- private FeaturesService featuresService= null;
+ private FeaturesService featuresService = null;
- protected ChildAwareFeatureWrapper(final Feature f) {
+ protected ChildAwareFeatureWrapper(final Feature feature) {
// Don't use without a feature service
}
- /*
- * @param f Feature to wrap
- * @param s FeaturesService to look up dependencies
+ /* Constructor.
+
+ * @param feature Feature to wrap
+ * @param featuresService FeaturesService to look up dependencies
*/
- ChildAwareFeatureWrapper(final Feature f, final FeaturesService s) throws Exception {
- super(s.getFeature(f.getName(), f.getVersion()));
- Preconditions.checkNotNull(s, "FeatureWrapper requires non-null FeatureService in constructor");
- this.featuresService = s;
+ ChildAwareFeatureWrapper(final Feature feature, final FeaturesService featuresService) throws Exception {
+ super(featuresService.getFeature(feature.getName(), feature.getVersion()));
+ Preconditions.checkNotNull(featuresService, "FeatureWrapper requires non-null FeatureService in constructor");
+ this.featuresService = featuresService;
}
protected FeaturesService getFeaturesService() {
public Set<? extends ChildAwareFeatureWrapper> getChildFeatures() throws Exception {
List<Dependency> dependencies = feature.getDependencies();
Set<ChildAwareFeatureWrapper> childFeatures = new LinkedHashSet<>();
- if(dependencies != null) {
- for(Dependency dependency: dependencies) {
+ if (dependencies != null) {
+ for (Dependency dependency : dependencies) {
Feature fi = extractFeatureFromDependency(dependency);
if (fi != null) {
if (featuresService.getFeature(fi.getName(), fi.getVersion()) == null) {
- LOG.warn("Feature: {}, {} is missing from features service. Skipping", fi.getName(), fi.getVersion());
+ LOG.warn("Feature: {}, {} is missing from features service. Skipping", fi.getName(), fi
+ .getVersion());
} else {
ChildAwareFeatureWrapper wrappedFeature = new ChildAwareFeatureWrapper(fi, featuresService);
childFeatures.add(wrappedFeature);
@Override
public Set<FeatureConfigSnapshotHolder> getFeatureConfigSnapshotHolders() throws Exception {
Set<FeatureConfigSnapshotHolder> snapShotHolders = new LinkedHashSet<>();
- for(ChildAwareFeatureWrapper c: getChildFeatures()) {
- for(FeatureConfigSnapshotHolder h: c.getFeatureConfigSnapshotHolders()) {
- final Optional<FeatureConfigSnapshotHolder> featureConfigSnapshotHolder = getFeatureConfigSnapshotHolder(h.getFileInfo());
- if(featureConfigSnapshotHolder.isPresent()) {
+ for (ChildAwareFeatureWrapper c : getChildFeatures()) {
+ for (FeatureConfigSnapshotHolder h : c.getFeatureConfigSnapshotHolders()) {
+ final Optional<FeatureConfigSnapshotHolder> featureConfigSnapshotHolder =
+ getFeatureConfigSnapshotHolder(h.getFileInfo());
+ if (featureConfigSnapshotHolder.isPresent()) {
snapShotHolders.add(featureConfigSnapshotHolder.get());
}
}
protected Feature extractFeatureFromDependency(final Dependency dependency) throws Exception {
Feature[] features = featuresService.listFeatures();
- VersionRange range = org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION.equals(dependency.getVersion())
- ? VersionRange.ANY_VERSION : new VersionRange(dependency.getVersion(), true, true);
+ VersionRange range = org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION.equals(dependency
+ .getVersion()) ? VersionRange.ANY_VERSION : new VersionRange(dependency.getVersion(), true, true);
Feature fi = null;
- for(Feature f: features) {
+ for (Feature f : features) {
if (f.getName().equals(dependency.getName())) {
- Version v = VersionTable.getVersion(f.getVersion());
- if (range.contains(v) &&
- (fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(v) < 0)) {
+ Version version = VersionTable.getVersion(f.getVersion());
+ if (range.contains(version) && (fi == null || VersionTable.getVersion(fi.getVersion())
+ .compareTo(version) < 0)) {
fi = f;
break;
}
}
return fi;
}
-
}
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+
import org.apache.karaf.features.FeatureEvent;
import org.apache.karaf.features.FeaturesListener;
import org.apache.karaf.features.FeaturesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ConfigFeaturesListener implements FeaturesListener, AutoCloseable {
+public class ConfigFeaturesListener implements FeaturesListener, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ConfigFeaturesListener.class);
private static final int QUEUE_SIZE = 1000;
private BlockingQueue<FeatureEvent> queue = new LinkedBlockingQueue<>(QUEUE_SIZE);
Thread pushingThread = null;
- public ConfigFeaturesListener(final ConfigPusher p, final FeaturesService f) {
- pushingThread = new Thread(new ConfigPushingRunnable(p, f, queue), "ConfigFeatureListener - ConfigPusher");
+ public ConfigFeaturesListener(final ConfigPusher configPusher, final FeaturesService featuresService) {
+ pushingThread = new Thread(new ConfigPushingRunnable(configPusher, featuresService, queue),
+ "ConfigFeatureListener - ConfigPusher");
pushingThread.start();
}
@Override
public void close() {
- if(pushingThread != null) {
+ if (pushingThread != null) {
pushingThread.interrupt();
pushingThread = null;
}
private static final Logger LOG = LoggerFactory.getLogger(ConfigPusherCustomizer.class);
private ConfigFeaturesListener configFeaturesListener = null;
private FeatureServiceCustomizer featureServiceCustomizer = null;
- private ServiceTracker<FeaturesService,FeaturesService> fsst = null;
+ private ServiceTracker<FeaturesService, FeaturesService> fsst = null;
@Override
public ConfigPusher addingService(final ServiceReference<ConfigPusher> configPusherServiceReference) {
}
@Override
- public void modifiedService(final ServiceReference<ConfigPusher> configPusherServiceReference, final ConfigPusher configPusher) {
+ public void modifiedService(final ServiceReference<ConfigPusher> configPusherServiceReference,
+ final ConfigPusher configPusher) {
// we don't care if the properties change
}
@Override
- public void removedService(final ServiceReference<ConfigPusher> configPusherServiceReference, final ConfigPusher configPusher) {
+ public void removedService(final ServiceReference<ConfigPusher> configPusherServiceReference,
+ final ConfigPusher configPusher) {
this.close();
}
@Override
public void close() {
- if(fsst != null) {
+ if (fsst != null) {
fsst.close();
fsst = null;
}
- if(configFeaturesListener != null) {
+ if (configFeaturesListener != null) {
configFeaturesListener.close();
configFeaturesListener = null;
}
- if(featureServiceCustomizer != null) {
+ if (featureServiceCustomizer != null) {
featureServiceCustomizer.close();
featureServiceCustomizer = null;
}
package org.opendaylight.controller.configpusherfeature.internal;
import com.google.common.collect.LinkedHashMultimap;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
+
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeatureEvent;
import org.apache.karaf.features.FeatureEvent.EventType;
private static final int POLL_TIME = 1;
private BlockingQueue<FeatureEvent> queue;
private FeatureConfigPusher configPusher;
- public ConfigPushingRunnable(final ConfigPusher p, final FeaturesService f, final BlockingQueue<FeatureEvent> q) {
- queue = q;
- configPusher = new FeatureConfigPusher(p, f);
+
+ public ConfigPushingRunnable(final ConfigPusher configPusher, final FeaturesService featuresService,
+ final BlockingQueue<FeatureEvent> featureEvents) {
+ queue = featureEvents;
+ this.configPusher = new FeatureConfigPusher(configPusher, featuresService);
}
@Override
+ @SuppressWarnings("IllegalCatch")
public void run() {
List<Feature> toInstall = new ArrayList<>();
FeatureEvent event = null;
- boolean interuppted = false;
- while(true) {
+ boolean interrupted = false;
+ while (true) {
try {
- if(!interuppted) {
- if(toInstall.isEmpty()) {
+ if (!interrupted) {
+ if (toInstall.isEmpty()) {
event = queue.take();
} else {
event = queue.poll(POLL_TIME, TimeUnit.MILLISECONDS);
}
- if(event != null && event.getFeature() !=null) {
- processFeatureEvent(event,toInstall);
+ if (event != null && event.getFeature() != null) {
+ processFeatureEvent(event, toInstall);
}
- } else if(toInstall.isEmpty()) {
+ } else if (toInstall.isEmpty()) {
LOG.error("ConfigPushingRunnable - exiting");
return;
}
} catch (final InterruptedException e) {
- LOG.error("ConfigPushingRunnable - interupted");
- interuppted = true;
+ LOG.error("ConfigPushingRunnable - interrupted");
+ interrupted = true;
} catch (final Exception e) {
LOG.error("Exception while processing features {} event {}", toInstall, event, e);
}
}
protected void processFeatureEvent(final FeatureEvent event, final List<Feature> toInstall) throws Exception {
- if(event.getType() == EventType.FeatureInstalled) {
+ if (event.getType() == EventType.FeatureInstalled) {
toInstall.add(event.getFeature());
- LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> result = configPusher.pushConfigs(toInstall);
+ LinkedHashMultimap<Feature, FeatureConfigSnapshotHolder> result = configPusher.pushConfigs(toInstall);
toInstall.removeAll(result.keySet());
- } else if(event.getType() == EventType.FeatureUninstalled) {
+ } else if (event.getType() == EventType.FeatureUninstalled) {
toInstall.remove(event.getFeature());
}
}
- protected void logPushResult(final LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> results) {
- for(Feature f:results.keySet()) {
- LOG.info("Pushed configs for feature {} {}",f,results.get(f));
+ protected void logPushResult(final LinkedHashMultimap<Feature, FeatureConfigSnapshotHolder> results) {
+ for (Feature f : results.keySet()) {
+ LOG.info("Pushed configs for feature {} {}", f, results.get(f));
}
}
}
import com.google.common.base.Optional;
import com.google.common.collect.LinkedHashMultimap;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.opendaylight.controller.config.persist.api.ConfigPusher;
* LinkedHashMultimap to track which configs we pushed for each Feature installation
* For future use
*/
- private final LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> feature2configs = LinkedHashMultimap.create();
+ private final LinkedHashMultimap<Feature, FeatureConfigSnapshotHolder> feature2configs = LinkedHashMultimap
+ .create();
- /*
- * @param p - ConfigPusher to push ConfigSnapshotHolders
- */
- public FeatureConfigPusher(final ConfigPusher p, final FeaturesService f) {
- pusher = p;
- featuresService = f;
+ public FeatureConfigPusher(final ConfigPusher configPusher, final FeaturesService featuresService) {
+ pusher = configPusher;
+ this.featuresService = featuresService;
}
+
/*
* Push config files from Features to config subsystem
* @param features - list of Features to extract config files from recursively and push
* If a Feature is not in the returned LinkedHashMultimap then we couldn't push its configs
* (Ususally because it was not yet installed)
*/
- public LinkedHashMultimap<Feature, FeatureConfigSnapshotHolder> pushConfigs(final List<Feature> features)
- throws Exception {
+ public LinkedHashMultimap<Feature, FeatureConfigSnapshotHolder> pushConfigs(
+ final List<Feature> features) throws Exception {
LinkedHashMultimap<Feature, FeatureConfigSnapshotHolder> pushedFeatures = LinkedHashMultimap.create();
for (Feature feature : features) {
Set<FeatureConfigSnapshotHolder> configSnapShots = pushConfig(feature);
// FIXME Workaround for BUG-2836, features service returns null for feature:
// standard-condition-webconsole_0_0_0, 3.0.1
if (featuresService.getFeature(feature.getName(), feature.getVersion()) == null) {
- LOG.debug("Feature: {}, {} is missing from features service. Skipping", feature.getName(),
- feature.getVersion());
+ LOG.debug("Feature: {}, {} is missing from features service. Skipping", feature.getName(), feature
+ .getVersion());
return Collections.emptySet();
}
return configs;
}
- private boolean isInstalled(final Feature feature) throws InterruptedException {
- for (int retries = 0; retries < MAX_RETRIES; retries++) {
- try {
- List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
- if (installedFeatures.contains(feature)) {
- return true;
- }
-
- LOG.info("Karaf Feature Service has not yet finished installing feature {}/{} (retry {})",
- feature.getName(), feature.getVersion(), retries);
- } catch (final Exception e) {
- LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e);
- }
-
- TimeUnit.MILLISECONDS.sleep(RETRY_PAUSE_MILLIS);
- }
- LOG.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",
- MAX_RETRIES, feature.getName(), feature.getVersion());
- return false;
- }
-
private Set<FeatureConfigSnapshotHolder> pushConfig(final Set<FeatureConfigSnapshotHolder> configs,
- final Feature feature) throws InterruptedException {
+ final Feature feature) throws InterruptedException {
Set<FeatureConfigSnapshotHolder> configsToPush = new LinkedHashSet<>(configs);
configsToPush.removeAll(pushedConfigs);
if (!configsToPush.isEmpty()) {
// Ignore features that are present in persisted current config
final Optional<XmlFileStorageAdapter> currentCfgPusher = XmlFileStorageAdapter.getInstance();
- if (currentCfgPusher.isPresent() &&
- currentCfgPusher.get().getPersistedFeatures().contains(feature.getId())) {
+ if (currentCfgPusher.isPresent() && currentCfgPusher.get().getPersistedFeatures()
+ .contains(feature.getId())) {
LOG.warn("Ignoring default configuration {} for feature {}, the configuration is present in {}",
configsToPush, feature.getId(), currentCfgPusher.get());
} else {
pusher.pushConfigs(new ArrayList<>(configsToPush));
}
-
pushedConfigs.addAll(configsToPush);
}
Set<FeatureConfigSnapshotHolder> configsPushed = new LinkedHashSet<>(pushedConfigs);
configsPushed.retainAll(configs);
return configsPushed;
}
+
+ @SuppressWarnings("IllegalCatch")
+ private boolean isInstalled(final Feature feature) throws InterruptedException {
+ for (int retries = 0; retries < MAX_RETRIES; retries++) {
+ try {
+ List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
+ if (installedFeatures.contains(feature)) {
+ return true;
+ }
+
+ LOG.info("Karaf Feature Service has not yet finished installing feature {}/{} (retry {})", feature
+ .getName(), feature.getVersion(), retries);
+ } catch (final Exception e) {
+ LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e);
+ }
+
+ TimeUnit.MILLISECONDS.sleep(RETRY_PAUSE_MILLIS);
+ }
+ LOG.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet "
+ + "finished installing feature {} {}", MAX_RETRIES, feature.getName(), feature.getVersion());
+ return false;
+ }
}
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
+
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
+
import org.apache.karaf.features.ConfigFileInfo;
import org.apache.karaf.features.Feature;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
* @param holder - FeatureConfigSnapshotHolder that we
* @param feature - new
*/
- public FeatureConfigSnapshotHolder(final FeatureConfigSnapshotHolder holder, final Feature feature) throws JAXBException, XMLStreamException {
- this(holder.fileInfo,holder.getFeature());
+ public FeatureConfigSnapshotHolder(final FeatureConfigSnapshotHolder holder,
+ final Feature feature) throws JAXBException, XMLStreamException {
+ this(holder.fileInfo, holder.getFeature());
this.featureChain.add(feature);
}
* @param fileInfo - ConfigFileInfo to read into the ConfigSnapshot
* @param feature - Feature the ConfigFileInfo was attached to
*/
- public FeatureConfigSnapshotHolder(final ConfigFileInfo fileInfo, final Feature feature) throws JAXBException, XMLStreamException {
+ public FeatureConfigSnapshotHolder(final ConfigFileInfo fileInfo,
+ final Feature feature) throws JAXBException, XMLStreamException {
Preconditions.checkNotNull(fileInfo);
Preconditions.checkNotNull(fileInfo.getFinalname());
Preconditions.checkNotNull(feature);
XMLStreamReader xsr = xif.createXMLStreamReader(new StreamSource(new File(fileInfo.getFinalname())));
unmarshalled = (ConfigSnapshot) um.unmarshal(xsr);
}
+
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((unmarshalled != null && unmarshalled.getConfigSnapshot() == null) ? 0 : unmarshalled.getConfigSnapshot().hashCode());
+ result = prime * result + ((unmarshalled != null && unmarshalled.getConfigSnapshot() == null) ? 0 :
+ unmarshalled.getConfigSnapshot().hashCode());
return result;
}
+
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
if (getClass() != obj.getClass()) {
return false;
}
- FeatureConfigSnapshotHolder fcsh = (FeatureConfigSnapshotHolder)obj;
- if(this.unmarshalled.getConfigSnapshot().equals(fcsh.unmarshalled.getConfigSnapshot())) {
+ FeatureConfigSnapshotHolder fcsh = (FeatureConfigSnapshotHolder) obj;
+ if (this.unmarshalled.getConfigSnapshot().equals(fcsh.unmarshalled.getConfigSnapshot())) {
return true;
}
return false;
@Override
public String toString() {
- StringBuilder b = new StringBuilder();
- Path p = Paths.get(fileInfo.getFinalname());
- b.append(p.getFileName())
- .append("(")
- .append(getCauseFeature())
- .append(",")
- .append(getFeature())
- .append(")");
- return b.toString();
+ StringBuilder stringBuilder = new StringBuilder();
+ Path path = Paths.get(fileInfo.getFinalname());
+ stringBuilder.append(path.getFileName()).append("(").append(getCauseFeature()).append(",").append(getFeature())
+ .append(")");
+ return stringBuilder.toString();
}
@Override
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FeatureServiceCustomizer implements ServiceTrackerCustomizer<FeaturesService, FeaturesService>, AutoCloseable {
+public class FeatureServiceCustomizer implements ServiceTrackerCustomizer<FeaturesService, FeaturesService>,
+ AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(FeatureServiceCustomizer.class);
private ConfigPusher configPusher = null;
private ServiceRegistration<?> registration;
- FeatureServiceCustomizer(final ConfigPusher c) {
- configPusher = c;
+ FeatureServiceCustomizer(final ConfigPusher configPusher) {
+ this.configPusher = configPusher;
}
@Override
+ @SuppressWarnings("IllegalCatch")
public FeaturesService addingService(final ServiceReference<FeaturesService> reference) {
BundleContext bc = reference.getBundle().getBundleContext();
final FeaturesService featureService = bc.getService(reference);
}
@Override
- public void modifiedService(final ServiceReference<FeaturesService> reference,
- final FeaturesService service) {
+ public void modifiedService(final ServiceReference<FeaturesService> reference, final FeaturesService service) {
// we don't care if the properties change
}
@Override
- public void removedService(final ServiceReference<FeaturesService> reference,
- final FeaturesService service) {
+ public void removedService(final ServiceReference<FeaturesService> reference, final FeaturesService service) {
close();
}