public void execute()

in src/main/java/org/apache/sling/installer/core/impl/tasks/BundleStartTask.java [70:105]


    public void execute(final InstallationContext ctx) {
        // this is just a sanity check which should never be reached
        if (bundleId == 0) {
            String message = "Bundle 0 is the framework bundle, ignoring request to start it";
            this.getLogger().debug(message);
            if ( this.getResource() != null ) {
                this.setFinishedState(ResourceState.INSTALLED, null, message);
            }
            return;
        }

        // and another sanity check
        final Bundle b = this.getBundleContext().getBundle(bundleId);
        if (b == null) {
            String message = MessageFormat.format("Cannot start bundle, id not found: {0}", bundleId);
            this.getLogger().debug(message);
            this.setFinishedState(ResourceState.IGNORED, null, message);
            return;
        }

        if (BundleUtil.isBundleActive(b) ) {
            String message = MessageFormat.format("Bundle already started, no action taken: {0}", bundleId);
            this.getLogger().debug(message);
            this.setFinishedState(ResourceState.INSTALLED, null, message);
        } else {
            // Try to start bundle, and if that doesn't work we'll need to retry
            try {
                b.start();
                this.setFinishedState(ResourceState.INSTALLED);
                ctx.log("Started bundle {}", b);
            } catch (final BundleException e) {
                this.getLogger().info("Could not start bundle {}. Reason: {}. Will retry.",
                        new Object[] {b, e});
            }
        }
    }