Search in sources :

Example 1 with BundleUpdateTask

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);
}
Also used : BundleInstallTask(org.apache.sling.installer.core.impl.tasks.BundleInstallTask) BundleUpdateTask(org.apache.sling.installer.core.impl.tasks.BundleUpdateTask) BundleStartTask(org.apache.sling.installer.core.impl.tasks.BundleStartTask) BundleRemoveTask(org.apache.sling.installer.core.impl.tasks.BundleRemoveTask) InstallTask(org.apache.sling.installer.api.tasks.InstallTask) BundleInstallTask(org.apache.sling.installer.core.impl.tasks.BundleInstallTask) RefreshBundlesTask(org.apache.sling.installer.core.impl.tasks.RefreshBundlesTask)

Example 2 with BundleUpdateTask

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;
}
Also used : Bundle(org.osgi.framework.Bundle) BundleUpdateTask(org.apache.sling.installer.core.impl.tasks.BundleUpdateTask) InstallTask(org.apache.sling.installer.api.tasks.InstallTask)

Aggregations

InstallTask (org.apache.sling.installer.api.tasks.InstallTask)2 BundleUpdateTask (org.apache.sling.installer.core.impl.tasks.BundleUpdateTask)2 BundleInstallTask (org.apache.sling.installer.core.impl.tasks.BundleInstallTask)1 BundleRemoveTask (org.apache.sling.installer.core.impl.tasks.BundleRemoveTask)1 BundleStartTask (org.apache.sling.installer.core.impl.tasks.BundleStartTask)1 RefreshBundlesTask (org.apache.sling.installer.core.impl.tasks.RefreshBundlesTask)1 Bundle (org.osgi.framework.Bundle)1