Package org.apache.sling.installer.api.tasks

Examples of org.apache.sling.installer.api.tasks.InstallTask


        final TaskResource toActivate = group.getActiveResource();
        if ( !toActivate.getType().equals(InstallableResource.TYPE_CONFIG) ) {
            return null;
        }

        final InstallTask result;
    if (toActivate.getState() == ResourceState.UNINSTALL) {
            // if this is an uninstall, check if we have to install an older version
            // in this case we should do an update instead of uninstall/install (!)
            final TaskResource second = group.getNextActiveResource();
            if ( second != null &&
View Full Code Here


    /**
     * @see org.apache.sling.installer.api.tasks.InstallTaskFactory#createTask(org.apache.sling.installer.api.tasks.TaskResourceGroup)
     */
    public InstallTask createTask(final TaskResourceGroup toActivate) {
        final InstallTask result;

        final TaskResource rsrc = toActivate.getActiveResource();
        if ( rsrc.getType().equals(TYPE_SUBSYSTEM) ) {

            // check if the required info is available
View Full Code Here

            final MockBundleTaskCreator c = new MockBundleTaskCreator();
            c.addBundleInfo(SN, "1.1", Bundle.ACTIVE);
            final SortedSet<InstallTask> s = getTasks(r, c);
            assertEquals("Expected one tasks, bundle was not installed by us", 2, s.size());
            final Iterator<InstallTask> i = s.iterator();
            final InstallTask first = i.next();
            final InstallTask second = i.next();
            assertTrue("Expected a ChangeStateTask", first instanceof ChangeStateTask);
            assertTrue("Expected a BundleRemoveTask", second instanceof BundleRemoveTask);
        }
    }
View Full Code Here

            c.addBundleInfo(SN, "1.1.0", Bundle.ACTIVE);

            final SortedSet<InstallTask> s = getTasks(r, c);
            assertEquals("Expected two tasks", 2, s.size());
            final Iterator<InstallTask> i = s.iterator();
            final InstallTask first = i.next();
            assertTrue("Expected a ChangeStateTask:" + first , first instanceof ChangeStateTask);
            final InstallTask second = i.next();
            assertTrue("Expected a BundleRemoveTask", second instanceof BundleRemoveTask);
            final BundleRemoveTask t = (BundleRemoveTask)second;
            assertEquals("Remove should be to V1.1", r[1].getEntityId(), t.getResource().getEntityId());
        }
    }
View Full Code Here

            for(final String entityId : this.persistentList.getEntityIds()) {
                final EntityResourceList group = this.persistentList.getEntityResourceList(entityId);
                // Check the first resource in each group
                final RegisteredResource toActivate = group.getActiveResource();
                if ( toActivate != null ) {
                    final InstallTask task = getTask(services, group);
                    if ( task != null ) {
                        tasks.add(task);
                    }

                }
View Full Code Here

    /**
     * Get the task for the resource.
     */
    private InstallTask getTask(List<InstallTaskFactory> services,
            final TaskResourceGroup rrg) {
        InstallTask result = null;

        for(final InstallTaskFactory factory : services) {
            if ( factory != null ) {
                result = factory.createTask(rrg);
                if ( result != null ) {
View Full Code Here

                        }
                    }
                }
            };
            while (this.active && !tasks.isEmpty()) {
                InstallTask task = null;
                synchronized (tasks) {
                    task = tasks.first();
                    tasks.remove(task);
                }
                // async tasks are executed "immediately"
                if ( task.isAsynchronousTask() ) {
                    logger.debug("Executing async task: {}", task);
                    // set attribute
                    final Integer oldValue;
                    if ( task.getResource() != null ) {
                        oldValue = (Integer)task.getResource().getAttribute(InstallTask.ASYNC_ATTR_NAME);
                        final Integer newValue;
                        if ( oldValue == null ) {
                            newValue = 1;
                        } else {
                            newValue = oldValue + 1;
                        }
                        task.getResource().setAttribute(InstallTask.ASYNC_ATTR_NAME, newValue);
                    } else {
                        oldValue = null;
                    }
                    // save new state
                    this.cleanupInstallableResources();
                    final InstallTask aSyncTask = task;
                    final String threadName = "BackgroundTaskThread" + backgroundTaskCounter.incrementAndGet();
                    final Thread t = new Thread(threadName) {

                        @Override
                        public void run() {
                            logger.debug("Starting background thread {} to execute {}",
                                    Thread.currentThread().getName(),
                                    aSyncTask);
                            try {
                                Thread.sleep(2000L);
                            } catch (final InterruptedException ie) {
                                // ignore
                            }
                            // reset attribute
                            if ( aSyncTask.getResource() != null ) {
                                aSyncTask.getResource().setAttribute(InstallTask.ASYNC_ATTR_NAME, oldValue);
                            }
                            aSyncTask.execute(ctx);
                            logger.debug("Background thread {} ends",  Thread.currentThread().getName());
                        }
                    };
                    t.start();
                    return ACTION.SHUTDOWN;
View Full Code Here

        }
        final String symbolicName = (String)toActivate.getAttribute(Constants.BUNDLE_SYMBOLICNAME);
        final boolean isInstallerCoreBundle = this.bundleContext.getBundle().getSymbolicName().equals(symbolicName);

        // Uninstall
        final InstallTask result;
    if (toActivate.getState() == ResourceState.UNINSTALL) {
            // find the info with the exact version
            final BundleInfo info = this.getBundleInfo(
                    symbolicName,
                    (String)toActivate.getAttribute(Constants.BUNDLE_VERSION));
View Full Code Here

TOP

Related Classes of org.apache.sling.installer.api.tasks.InstallTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.