Examples of 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
  • org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

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

            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

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

        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

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

        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, 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

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

      private String basToString(final BundleArchives bas) {
        final StringBuffer res = new StringBuffer();

        if (null != bas) {
          for (Iterator it = bas.allBundleArchives.iterator(); it.hasNext();) {
            final BundleArchive ba = (BundleArchive) it.next();

            if (0 < res.length()) {
              res.append("<br>\n");
            }
            res.append(providerToString(ba));
    View Full Code Here

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

      private String providersToString(final Set providers) {
        final StringBuffer res = new StringBuffer();

        for (Iterator it = providers.iterator(); it.hasNext();) {
          final BundleArchive ba = (BundleArchive) it.next();

          if (0 < res.length()) {
            res.append(", ");
          }
          res.append(providerToString(ba));
    View Full Code Here

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

        while (it.hasNext()) {
          final Map.Entry entry = (Map.Entry) it.next();
          final Set bsnSet = (Set) entry.getValue();
          // Sorted set with bundle archives, same bsn, different versions
          for (Iterator itV = bsnSet.iterator(); itV.hasNext();) {
            final BundleArchive ba = (BundleArchive) itV.next();
            final String targetName = ba.bsn + "-" + ba.version;
            targetNames.append(",").append(targetName);

            final Comment comment = doc.createComment(ba.relPath);
            final Element target = doc.createElement("target");
            target.setAttribute("name", targetName);

            final Element mvnDeployBundle = doc.createElement("mvn_deploy_bundle");
            target.appendChild(doc.createTextNode("\n"+prefix2));
            target.appendChild(mvnDeployBundle);

            mvnDeployBundle.setAttribute("projDirName", ba.projectName);
            addMavenCoordinates(mvnDeployBundle, ba);
            mvnDeployBundle.setAttribute("artifactName", ba.name);
            mvnDeployBundle.setAttribute("artifactBundle", ba.file.getAbsolutePath());
            mvnDeployBundle.setAttribute("packing", "jar");

            // Optional attributes
            final String description = ba.getBundleDescription();
            if (null != description) {
              mvnDeployBundle.setAttribute("description", description);
            }

            if (null!=settingsFile) {
    View Full Code Here

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

        while (it.hasNext()) {
          final Map.Entry entry = (Map.Entry) it.next();
          final Set bsnSet = (Set) entry.getValue();
          // Sorted set with bundle archives, same bsn, different versions
          for (Iterator itV = bsnSet.iterator(); itV.hasNext();) {
            final BundleArchive ba = (BundleArchive) itV.next();

            dependencies.appendChild(doc.createTextNode("\n\n" +prefix2));
            dependencies.appendChild(doc.createComment(ba.relPath));
            dependencies.appendChild(doc.createTextNode("\n" +prefix2));

            final Element dependency = doc.createElement("dependency");
            dependencies.appendChild(dependency);

            // Dummy element to read mvn coordinates from
            final Element coordinateEl = doc.createElement("dummy");
            addMavenCoordinates(coordinateEl, ba);
            addMavenCoordinates(coordinateEl, dependency, prefix3);

            dependency.appendChild(doc.createTextNode("\n" +prefix2));

            // Bundle metadata for xsl rendering
            final Element bundle = doc.createElement("bundle");
            bundles.appendChild(doc.createTextNode("\n" +prefix2));
            bundles.appendChild(bundle);

            bundle.appendChild(doc.createTextNode("\n" +prefix3));
            final Element name = doc.createElement("name");
            bundle.appendChild(name);
            name.appendChild(doc.createTextNode(ba.name));
            log("name: " +ba.name, Project.MSG_VERBOSE);

            String description = ba.getBundleDescription();
            log("description: " +description, Project.MSG_VERBOSE);
            if (null==description) {
              description = "";
            }
            bundle.appendChild(doc.createTextNode("\n" +prefix3));
    View Full Code Here

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

          while (itBSN.hasNext()) {
            final Map.Entry entry = (Map.Entry) itBSN.next();
            final Set bsnSet = (Set) entry.getValue();
            // Sorted set with bundle archives, same BSN, different versions
            for (Iterator itV = bsnSet.iterator(); itV.hasNext();) {
              final BundleArchive ba = (BundleArchive) itV.next();
              writeBundlePage(ba);
            }
          }

          final String mainPageTemplate = Util.loadFile(getBundleMainTemplate().getAbsolutePath());
    View Full Code Here

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

        if(ba.pkgProvidedMap.size() == 0) {
          dependingList.append("None found");
        } else {
          for(Iterator it = ba.pkgProvidedMap.entrySet().iterator(); it.hasNext();) {
            final Map.Entry entry = (Map.Entry) it.next();
            final BundleArchive dependentBa = (BundleArchive) entry.getKey();
            final Set pkgs = (Set) entry.getValue();

            String row = replace(bundleRow, "${what}", getPackagesJavadocString(relPathUp, pkgs));
            row = replace(row, "${bundledoc}", relPathUp + getVarMap(dependentBa).get("html.uri"));
            row = stdReplace(dependentBa, row);
    View Full Code Here

    Examples of org.knopflerfish.ant.taskdefs.bundle.BundleArchives.BundleArchive

        if(ba.pkgProvidersMap.size() == 0 && ba.pkgUnprovidedMap.size() == 0) {
          providersList.append("None found");
        } else {
          for(Iterator it = ba.pkgProvidersMap.entrySet().iterator(); it.hasNext();) {
            final Map.Entry entry = (Map.Entry) it.next();
            final BundleArchive providingBa = (BundleArchive) entry.getKey();
            final Set pkgs = (Set) entry.getValue();

            String row = replace(bundleRow, "${what}", getPackagesJavadocString(relPathUp, pkgs));
            row = replace(row, "${bundledoc}", relPathUp + getVarMap(providingBa).get("html.uri"));
            row = stdReplace(providingBa, row);
    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.