use of org.apache.sling.installer.factories.configuration.impl.Coordinator.Operation in project sling by apache.
the class ConfigInstallTask method execute.
@Override
public void execute(final InstallationContext ctx) {
synchronized (Coordinator.SHARED) {
// Get or create configuration, but do not
// update if the new one has the same values.
boolean created = false;
try {
String location = (String) this.getResource().getDictionary().get(ConfigurationConstants.PROPERTY_BUNDLE_LOCATION);
if (location == null) {
// default
location = Activator.DEFAULT_LOCATION;
} else if (location.length() == 0) {
location = null;
}
Configuration config = getConfiguration();
if (config == null) {
created = true;
config = createConfiguration(location);
} else {
if (ConfigUtil.isSameData(config.getProperties(), getResource().getDictionary())) {
this.getLogger().debug("Configuration {} already installed with same data, update request ignored: {}", config.getPid(), getResource());
config = null;
} else {
config.setBundleLocation(location);
}
}
if (config != null) {
config.update(getDictionary());
ctx.log("Installed configuration {} from resource {}", config.getPid(), getResource());
if (this.factoryPid != null) {
this.aliasPid = config.getPid();
}
this.getLogger().debug("Configuration " + config.getPid() + " " + (created ? "created" : "updated") + " from " + getResource());
this.setFinishedState(ResourceState.INSTALLED, this.getCompositeAliasPid());
final Operation op = new Coordinator.Operation(config.getPid(), config.getFactoryPid(), false);
Coordinator.SHARED.add(op);
} else {
this.setFinishedState(ResourceState.IGNORED, this.getCompositeAliasPid());
}
} catch (Exception e) {
this.getLogger().debug("Exception during installation of config " + this.getResource() + " : " + e.getMessage() + ". Retrying later.", e);
}
}
}
Aggregations