use of org.apache.sling.installer.core.impl.tasks.BundleUpdateTask in project sling by apache.
the class TaskOrderingTest method testBasicOrdering.
@org.junit.Test
public void testBasicOrdering() throws Exception {
int testIndex = 1;
final InstallTask[] tasksInOrder = { new BundleRemoveTask(getRegisteredResource("test:url"), null), new BundleInstallTask(getRegisteredResource("test:url"), null), new BundleUpdateTask(getRegisteredResource("test:url"), null), new RefreshBundlesTask(null), new BundleStartTask(null, 0, null) };
taskSet.clear();
taskSet.add(tasksInOrder[4]);
taskSet.add(tasksInOrder[3]);
taskSet.add(tasksInOrder[2]);
taskSet.add(tasksInOrder[1]);
taskSet.add(tasksInOrder[0]);
assertOrder(testIndex++, taskSet, tasksInOrder);
taskSet.clear();
taskSet.add(tasksInOrder[0]);
taskSet.add(tasksInOrder[1]);
taskSet.add(tasksInOrder[2]);
taskSet.add(tasksInOrder[3]);
taskSet.add(tasksInOrder[4]);
assertOrder(testIndex++, taskSet, tasksInOrder);
taskSet.clear();
taskSet.add(tasksInOrder[3]);
taskSet.add(tasksInOrder[2]);
taskSet.add(tasksInOrder[0]);
taskSet.add(tasksInOrder[4]);
taskSet.add(tasksInOrder[1]);
assertOrder(testIndex++, taskSet, tasksInOrder);
taskSet.clear();
taskSet.add(tasksInOrder[4]);
taskSet.add(tasksInOrder[0]);
taskSet.add(tasksInOrder[2]);
taskSet.add(tasksInOrder[3]);
taskSet.add(tasksInOrder[1]);
assertOrder(testIndex++, taskSet, tasksInOrder);
}
use of org.apache.sling.installer.core.impl.tasks.BundleUpdateTask in project sling by apache.
the class OsgiInstallerImpl method getLowestStartLevel.
/**
* Get the lowest start level for the update operation
*/
private int getLowestStartLevel(final SortedSet<InstallTask> tasks, final StartLevel startLevel) {
final int currentStartLevel = startLevel.getStartLevel();
int startLevelToTarget = currentStartLevel;
for (final InstallTask task : tasks) {
if (task instanceof BundleUpdateTask) {
final Bundle b = ((BundleUpdateTask) task).getBundle();
if (b != null) {
try {
final int bundleStartLevel = startLevel.getBundleStartLevel(b) - 1;
if (bundleStartLevel < startLevelToTarget) {
startLevelToTarget = bundleStartLevel;
}
} catch (final IllegalArgumentException iae) {
// ignore - bundle is uninstalled
}
}
}
}
// check installer start level
final int ownStartLevel = startLevel.getBundleStartLevel(ctx.getBundle());
if (ownStartLevel > startLevelToTarget) {
// we don't want to disable ourselves
startLevelToTarget = ownStartLevel;
}
return startLevelToTarget;
}
Aggregations