use of org.apache.felix.fileinstall.plugins.installer.InstallableUnitEvent in project felix by apache.
the class DeploymentInstaller method unsponsorUnit.
/**
* Unsponsor the installable unit. Returns a promise which is resolved when the uninstall is completed.
*/
private Promise<List<Bundle>> unsponsorUnit(File file) {
List<InstallableUnitEvent> events = new LinkedList<>();
Promise<List<Bundle>> bundles = withLock(this.unitsLock.writeLock(), () -> {
Promise<List<Bundle>> promise = Promises.resolved(Collections.emptyList());
InstallableUnitImpl existing = this.units.remove(file);
if (existing != null) {
State origState = existing.getState();
if (origState.equals(State.INSTALLED)) {
promise = putUninstallJob(existing);
}
if (existing.setState(State.REMOVED)) {
events.add(new InstallableUnitEvent(origState, State.REMOVED, existing));
}
}
return promise;
});
notifyListeners(events);
return bundles;
}
use of org.apache.felix.fileinstall.plugins.installer.InstallableUnitEvent in project felix by apache.
the class DeploymentInstaller method replaceUnit.
private void replaceUnit(File file, State origState, InstallableUnitImpl newUnit) {
Collection<InstallableUnitEvent> events = new ArrayList<>(2);
events.add(new InstallableUnitEvent(origState, newUnit.getState(), newUnit));
events.addAll(withLock(this.unitsLock.writeLock(), () -> {
InstallableUnitImpl existing = this.units.put(file, newUnit);
if (existing != null) {
State oldState = existing.getState();
if (existing.setState(State.REMOVED)) {
return Collections.singleton(new InstallableUnitEvent(oldState, State.REMOVED, existing));
}
}
return Collections.emptyList();
}));
notifyListeners(events);
}
Aggregations