Package org.apache.felix.framework.cache

Examples of org.apache.felix.framework.cache.BundleArchive

The "reference:" notation signifies that the resource should be used "in place", meaning that they will not be copied. For referenced JAR files, some resources may still be copied, such as embedded JAR files or native libraries, but for referenced exploded bundle directories, nothing will be copied. Currently, reference URLs can only refer to "file:" targets.

@see org.apache.felix.framework.cache.BundleCache @see org.apache.felix.framework.cache.BundleRevision

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        BundleImpl bi = new BundleImpl(felixMock, originatingBundle, archive);
        assertEquals(3L, bi.getBundleId());

        // Do the revise operation.
View Full Code Here


        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        BundleImpl bi = new BundleImpl(felixMock, null, archive);
        assertEquals("zar", bi.getSymbolicName());

        // Do the revise operation, change the bsn to foo
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        try
        {
            new BundleImpl(felixMock, null, archive);
            fail("Should have thrown a BundleException because the collision hook is not enabled");
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        BundleImpl bi = new BundleImpl(felixMock, null, archive);
        assertEquals(3L, bi.getBundleId());
    }
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        try
        {
            new BundleImpl(felixMock, null, archive);
            fail("Should have thrown a BundleException because the installed bundle is not unique");
View Full Code Here

    Bundle installBundle(
        Bundle origin, String location, InputStream is)
        throws BundleException
    {
        BundleArchive ba = null;
        BundleImpl existing, bundle = null;

        // Acquire an install lock.
        acquireInstallLock(location);

        try
        {
            // Check to see if the framework is still running;
            if ((getState() == Bundle.STOPPING) ||
                (getState() == Bundle.UNINSTALLED))
            {
                throw new BundleException("The framework has been shutdown.");
            }

            // If bundle location is already installed, then
            // return it as required by the OSGi specification.
            existing = (BundleImpl) getBundle(location);
            if (existing == null)
            {
                // First generate an identifier for it.
                long id = getNextId();

                try
                {
                    // Add the bundle to the cache.
                    ba = m_cache.create(id, getInitialBundleStartLevel(), location, is);
                }
                catch (Exception ex)
                {
                    throw new BundleException(
                        "Unable to cache bundle: " + location, ex);
                }
                finally
                {
                    try
                    {
                        if (is != null) is.close();
                    }
                    catch (IOException ex)
                    {
                        m_logger.log(
                            Logger.LOG_ERROR,
                            "Unable to close input stream.", ex);
                    }
                }

                try
                {
                    // Acquire the global lock to create the bundle,
                    // since this impacts the global state.
                    boolean locked = acquireGlobalLock();
                    if (!locked)
                    {
                        throw new BundleException(
                            "Unable to acquire the global lock to install the bundle.");
                    }
                    try
                    {
                        bundle = new BundleImpl(this, origin, ba);
                    }
                    finally
                    {
                        // Always release the global lock.
                        releaseGlobalLock();
                    }

                    if (!bundle.isExtension())
                    {
                        Object sm = System.getSecurityManager();
                        if (sm != null)
                        {
                            ((SecurityManager) sm).checkPermission(
                                new AdminPermission(bundle, AdminPermission.LIFECYCLE));
                        }
                    }
                    else
                    {
                        m_extensionManager.addExtensionBundle(this, bundle);
                        m_resolver.addRevision(m_extensionManager.getRevision());
                    }
                }
                catch (Throwable ex)
                {
                    // Remove bundle from the cache.
                    try
                    {
                        if (bundle != null)
                        {
                            bundle.closeAndDelete();
                        }
                        else if (ba != null)
                        {
                            ba.closeAndDelete();
                        }
                    }
                    catch (Exception ex1)
                    {
                        m_logger.log(bundle,
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        BundleImpl bi = new BundleImpl(felixMock, originatingBundle, archive);
        assertEquals(3L, bi.getBundleId());

        // Do the revise operation.
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        BundleImpl bi = new BundleImpl(felixMock, null, archive);
        assertEquals("zar", bi.getSymbolicName());

        // Do the revise operation, change the bsn to foo
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        try
        {
            new BundleImpl(felixMock, null, archive);
            fail("Should have thrown a BundleException because the collision hook is not enabled");
View Full Code Here

        headerMap.put(Constants.BUNDLE_MANIFESTVERSION, "2");

        BundleArchiveRevision archiveRevision = Mockito.mock(BundleArchiveRevision.class);
        Mockito.when(archiveRevision.getManifestHeader()).thenReturn(headerMap);

        BundleArchive archive = Mockito.mock(BundleArchive.class);
        Mockito.when(archive.getCurrentRevision()).thenReturn(archiveRevision);
        Mockito.when(archive.getId()).thenReturn(3L);

        BundleImpl bi = new BundleImpl(felixMock, null, archive);
        assertEquals(3L, bi.getBundleId());
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.framework.cache.BundleArchive

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.