Examples of DeploymentPackage


Examples of org.osgi.service.deploymentadmin.DeploymentPackage

        BundleInfoImpl[] bundleInfos = source.getBundleInfoImpls();
        for (int i = 0; i < bundleInfos.length; i++) {
            String symbolicName = bundleInfos[i].getSymbolicName();
            Version version = bundleInfos[i].getVersion();

            DeploymentPackage targetPackage = getDeploymentPackageContainingBundleWithSymbolicName(symbolicName);
            // If found, it should match the given target DP; not found is also ok...
            if ((targetPackage != null) && !targetPackage.equals(target)) {
                m_log.log(LogService.LOG_ERROR, "Bundle '" + symbolicName + "/" + version + " already present in other deployment packages!");
                throw new DeploymentException(CODE_BUNDLE_SHARING_VIOLATION, "Bundle '" + symbolicName + "/" + version + " already present in other deployment packages!");
            }

            if (targetPackage == null) {
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

                final DeploymentAdmin admin = (DeploymentAdmin) adminTracker.getService();
                if (admin != null)
                {
                    try
                    {
                        final DeploymentPackage pck = admin.getDeploymentPackage(pckId);
                        if (pck != null)
                        {
                            pck.uninstall();
                        }
                    }
                    catch ( /*Deployment*/Exception e)
                    {
                        throw new ServletException("Unable to undeploy package.", e);
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

            this.getResourceGroup().setFinishState(ResourceState.IGNORED);
            return;
        }

        // get package if available
        final DeploymentPackage dp = this.deploymentAdmin.getDeploymentPackage(symbolicName);

        if ( tr.getState() == ResourceState.INSTALL) {
            InputStream is = null;
            try {
                is = tr.getInputStream();
                if ( is == null ) {
                    // something went wrong
                    logger.error("Resource {} does not provide an input stream!", tr);
                    this.getResourceGroup().setFinishState(ResourceState.IGNORED);
                } else {
                    final Version newVersion = new Version((String)tr.getAttribute(DeploymentPackageInstaller.DEPLOYMENTPACKAGE_VERSION));
                    // check version
                    if ( dp != null ) {
                        final int compare = dp.getVersion().compareTo(newVersion);
                        if (compare < 0) {
                            // installed version is lower -> update
                            this.deploymentAdmin.installDeploymentPackage(is);
                            ctx.log("Installed deployment package {} : {}", symbolicName, newVersion);
                            this.getResourceGroup().setFinishState(ResourceState.INSTALLED);
                        } else if (compare >= 0) {
                            logger.debug("Deployment package " + symbolicName + " " + newVersion
                                        + " is not installed, package with higher or same version is already installed.");
                        }
                    } else {
                        this.deploymentAdmin.installDeploymentPackage(is);
                        ctx.log("Installed deployment package {} : {}", symbolicName, newVersion);
                        this.getResourceGroup().setFinishState(ResourceState.INSTALLED);
                    }
                }
            } catch (final DeploymentException e) {
                logger.error("Unable to install deployment package {} from resource {}",
                        symbolicName,
                        tr);
                this.getResourceGroup().setFinishState(ResourceState.IGNORED);
            } catch (final IOException ioe) {
                logger.error("Unable to install deployment package {} from resource {}",
                        symbolicName,
                        tr);
                this.getResourceGroup().setFinishState(ResourceState.IGNORED);
            } finally {
                if ( is != null ) {
                    try {
                        is.close();
                    } catch (IOException ignore) {}
                }
            }
        } else { // uninstall
            if ( dp != null ) {
                try {
                    dp.uninstall();
                } catch (final DeploymentException e) {
                    logger.error("Unable to uninstall deployment package {} from resource {}", symbolicName, tr);
                }
            } else {
                logger.info("Unable to find deployment package with symbolic name {} for uninstalling.",
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

public class GetStorageAreaCommand extends Command {

    private final Map m_storageAreas = new HashMap();

    protected void doExecute(DeploymentSessionImpl session) throws Exception {
        DeploymentPackage target = session.getTargetDeploymentPackage();
        BundleInfo[] infos = target.getBundleInfos();
        for (int i = 0; i < infos.length; i++) {
            if (isCancelled()) {
                throw new DeploymentException(CODE_CANCELLED);
            }
            Bundle bundle = target.getBundle(infos[i].getSymbolicName());
            if (bundle != null) {
                try {
                    File root = session.getDataFile(bundle);
                    m_storageAreas.put(bundle.getSymbolicName(), root);
                }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

            // first, install a deployment package with implementation and api bundles in version 1.0.0
            DeploymentPackageBuilder dpBuilder = createDeploymentPackageBuilder("a", "1.0.0");
            dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
            dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")));
   
            DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
            assertNotNull("No deployment package returned?!", dp1);
   
            assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
   
            // then, install a fix package with implementation and api bundles in version 2.0.0
            dpBuilder = createDeploymentPackageBuilder("a", "2.0.0").setFixPackage("[1.0.0,2.0.0]");
            dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl2", "bundleimpl2", "2.0.0")));
            dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi2", "bundleapi2", "2.0.0")));

            DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
            assertNotNull("No deployment package returned?!", dp2);

            awaitRefreshPackagesEvent();

            assertBundleExists(getSymbolicName("bundleimpl"), "2.0.0");
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

        dpBuilder
            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
            .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
            .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));

        DeploymentPackage dp = installDeploymentPackage(dpBuilder);
        assertNotNull("No deployment package returned?!", dp);

        awaitRefreshPackagesEvent();

        assertTrue("Two bundles should be started!", getCurrentBundles().size() == 2);

        Bundle rpBundle = dp.getBundle(getSymbolicName("rp1"));
        rpBundle.uninstall();

        assertTrue("One bundle should be started!", getCurrentBundles().size() == 1);

        assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());

        assertTrue(dp.uninstallForced());

        // FELIX-4484: after a forced uninstall, the DP should be marked as stale...
        assertTrue(dp.isStale());
       
        assertTrue("No bundle should be started!", getCurrentBundles().isEmpty());

        assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
    }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

        DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
        dpBuilder
            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("fragment1")));

        DeploymentPackage dp = installDeploymentPackage(dpBuilder);
        assertNotNull("No deployment package returned?!", dp);

        awaitRefreshPackagesEvent();

        assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
        assertBundleExists(getSymbolicName("fragment1"), "1.0.0");

        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
        assertFalse(isBundleActive(dp.getBundle(getSymbolicName("fragment1"))));

        // Should succeed...
        dp.uninstall();

        assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());

        // Both bundles should be uninstalled...
        assertBundleNotExists(getSymbolicName("bundle1"), "1.0.0");
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

            .add(
                dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1)
                    .setUrl(getTestResource("test-config1.xml")))
            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));

        DeploymentPackage dp = installDeploymentPackage(dpBuilder);
        assertNotNull("No deployment package returned?!", dp);

        awaitRefreshPackagesEvent();

        // Though the commit failed; the package should be installed...
        assertBundleExists(getSymbolicName("rp1"), "1.0.0");
        assertBundleExists(getSymbolicName("bundle3"), "1.0.0");

        assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());

        // Should succeed...
        dp.uninstall();

        assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());

        assertBundleNotExists(getSymbolicName("rp1"), "1.0.0");
        assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

        dpBuilder
            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
            .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
            .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));

        DeploymentPackage dp = installDeploymentPackage(dpBuilder);
        assertNotNull("No deployment package returned?!", dp);

        awaitRefreshPackagesEvent();
       
        assertTrue("Two bundles should be started!", getCurrentBundles().size() == 2);

        assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
       
        System.setProperty("rp1", "commit");

        dp.uninstall();

        assertTrue("No bundles should be started! " + getCurrentBundles(), getCurrentBundles().isEmpty());

        assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
    }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentPackage

        dpBuilder
            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
            .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
            .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));

        DeploymentPackage dp = installDeploymentPackage(dpBuilder);
        assertNotNull("No deployment package returned?!", dp);

        awaitRefreshPackagesEvent();
       
        assertTrue("Two bundles should be started!", getCurrentBundles().size() == 2);

        assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
       
        System.setProperty("rp1", "dropAllResources");

        try {
            dp.uninstall();
            fail("Expected uninstall to fail and rollback!");
        }
        catch (DeploymentException exception) {
            // Ok; expected
            assertDeploymentException(CODE_OTHER_ERROR, exception);
        }

        // FELIX-4484: only after a successful uninstall, the DP should be marked as stale...
        assertFalse(dp.isStale());
       
        assertTrue("Two bundles should be started!", getCurrentBundles().size() == 2);

        assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.