ConfigPusherCustomizer cpc = null;
ServiceTracker<ConfigPusher,ConfigPusher> cpst = null;
- public void start(BundleContext context) throws Exception {
+ public void start(final BundleContext context) throws Exception {
bc = context;
cpc = new ConfigPusherCustomizer();
cpst = new ServiceTracker<>(bc, ConfigPusher.class.getName(), cpc);
cpst.open();
}
- public void stop(BundleContext context) throws Exception {
+ public void stop(final BundleContext context) throws Exception {
if(cpst != null) {
cpst.close();
cpst = null;
return Optional.absent();
}
- private static boolean isConfigSnapshot(String fileName) {
+ private static boolean isConfigSnapshot(final String fileName) {
if(!Files.getFileExtension(fileName).equals(CONFIG_FILE_SUFFIX)) {
return false;
}
Element root = builderFactory.newDocumentBuilder().parse(fis).getDocumentElement();
return ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME.equals(root.getLocalName());
- } catch (Exception e) {
+ } catch (final Exception e) {
LOG.error("Could not parse XML file {}", file, e);
return false;
}
private static final Logger LOG = LoggerFactory.getLogger(ChildAwareFeatureWrapper.class);
private FeaturesService featuresService= null;
- protected ChildAwareFeatureWrapper(Feature f) {
+ protected ChildAwareFeatureWrapper(final Feature f) {
// Don't use without a feature service
}
* @param f Feature to wrap
* @param s FeaturesService to look up dependencies
*/
- ChildAwareFeatureWrapper(Feature f, FeaturesService s) throws Exception {
+ 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;
return snapShotHolders;
}
- protected Feature extractFeatureFromDependency(Dependency dependency) throws Exception {
+ 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);
private BlockingQueue<FeatureEvent> queue = new LinkedBlockingQueue<>(QUEUE_SIZE);
Thread pushingThread = null;
- public ConfigFeaturesListener(ConfigPusher p, FeaturesService f) {
+ public ConfigFeaturesListener(final ConfigPusher p, final FeaturesService f) {
pushingThread = new Thread(new ConfigPushingRunnable(p, f, queue), "ConfigFeatureListener - ConfigPusher");
pushingThread.start();
}
@Override
- public void featureEvent(FeatureEvent event) {
+ public void featureEvent(final FeatureEvent event) {
queue.offer(event);
}
@Override
- public void repositoryEvent(RepositoryEvent event) {
+ public void repositoryEvent(final RepositoryEvent event) {
LOG.debug("Repository: {} {}", event.getType(), event.getRepository());
}
private ServiceTracker<FeaturesService,FeaturesService> fsst = null;
@Override
- public ConfigPusher addingService(ServiceReference<ConfigPusher> configPusherServiceReference) {
+ public ConfigPusher addingService(final ServiceReference<ConfigPusher> configPusherServiceReference) {
LOG.trace("Got ConfigPusherCustomizer.addingService {}", configPusherServiceReference);
BundleContext bc = configPusherServiceReference.getBundle().getBundleContext();
ConfigPusher cpService = bc.getService(configPusherServiceReference);
}
@Override
- public void modifiedService(ServiceReference<ConfigPusher> configPusherServiceReference, ConfigPusher configPusher) {
+ public void modifiedService(final ServiceReference<ConfigPusher> configPusherServiceReference, final ConfigPusher configPusher) {
// we don't care if the properties change
}
@Override
- public void removedService(ServiceReference<ConfigPusher> configPusherServiceReference, ConfigPusher configPusher) {
+ public void removedService(final ServiceReference<ConfigPusher> configPusherServiceReference, final ConfigPusher configPusher) {
this.close();
}
private static final int POLL_TIME = 1;
private BlockingQueue<FeatureEvent> queue;
private FeatureConfigPusher configPusher;
- public ConfigPushingRunnable(ConfigPusher p, FeaturesService f,BlockingQueue<FeatureEvent> q) {
+ public ConfigPushingRunnable(final ConfigPusher p, final FeaturesService f, final BlockingQueue<FeatureEvent> q) {
queue = q;
configPusher = new FeatureConfigPusher(p, f);
}
LOG.error("ConfigPushingRunnable - exiting");
return;
}
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
LOG.error("ConfigPushingRunnable - interupted");
interuppted = true;
- } catch (Exception e) {
+ } catch (final Exception e) {
LOG.error("Exception while processing features {} event {}", toInstall, event, e);
}
}
}
- protected void processFeatureEvent(FeatureEvent event, List<Feature> toInstall) throws Exception {
+ protected void processFeatureEvent(final FeatureEvent event, final List<Feature> toInstall) throws Exception {
if(event.getType() == EventType.FeatureInstalled) {
toInstall.add(event.getFeature());
LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> result = configPusher.pushConfigs(toInstall);
}
}
- protected void logPushResult(LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> results) {
+ protected void logPushResult(final LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> results) {
for(Feature f:results.keySet()) {
LOG.info("Pushed configs for feature {} {}",f,results.get(f));
}
LOG.info("Karaf Feature Service has not yet finished installing feature {}/{} (retry {})",
feature.getName(), feature.getVersion(), retries);
- } catch (Exception e) {
+ } catch (final Exception e) {
LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e);
}
* We really care most about the underlying ConfigShapshot, so compute equality on that
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
private ConfigPusher configPusher = null;
private ServiceRegistration<?> registration;
- FeatureServiceCustomizer(ConfigPusher c) {
+ FeatureServiceCustomizer(final ConfigPusher c) {
configPusher = c;
}
@Override
- public FeaturesService addingService(ServiceReference<FeaturesService> reference) {
+ public FeaturesService addingService(final ServiceReference<FeaturesService> reference) {
BundleContext bc = reference.getBundle().getBundleContext();
final FeaturesService featureService = bc.getService(reference);
final Optional<XmlFileStorageAdapter> currentPersister = XmlFileStorageAdapter.getInstance();
for (final Feature installedFeature : featureService.listInstalledFeatures()) {
installedFeatureIds.add(installedFeature.getId());
}
- } catch (Exception e) {
+ } catch (final Exception e) {
LOG.error("Error listing installed features", e);
}
}
@Override
- public void modifiedService(ServiceReference<FeaturesService> reference,
- FeaturesService service) {
+ public void modifiedService(final ServiceReference<FeaturesService> reference,
+ final FeaturesService service) {
// we don't care if the properties change
}
@Override
- public void removedService(ServiceReference<FeaturesService> reference,
- FeaturesService service) {
+ public void removedService(final ServiceReference<FeaturesService> reference,
+ final FeaturesService service) {
close();
}