Package org.osgi.framework

Examples of org.osgi.framework.Bundle.adapt()


    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentRevisionDeclaredCapabilities(long, java.lang.String)
     */
    public CompositeData[] getCurrentRevisionDeclaredCapabilities(long bundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
        BundleRevision revision = bundle.adapt(BundleRevision.class);

        return BundleWiringData.getCapabilitiesCompositeData(revision.getDeclaredCapabilities(namespace));
    }

    /* (non-Javadoc)
 
View Full Code Here


    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentWiring(long, java.lang.String)
     */
    public CompositeData getCurrentWiring(long bundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
        BundleRevision currentRevision = bundle.adapt(BundleRevision.class);
        Map<BundleRevision, Integer> revisionIDMap = getCurrentRevisionTransitiveRevisionsClosure(bundleId, namespace);
        return getRevisionWiring(currentRevision, 0, namespace, revisionIDMap);
    }

    /* (non-Javadoc)
 
View Full Code Here

    // The current revision being passed in always gets assigned revision ID 0
    // All the other revision IDs unique, but don't increase monotonous.
    private Map<BundleRevision, Integer> getCurrentRevisionTransitiveRevisionsClosure(long rootBundleId, String namespace) throws IOException {
        Bundle rootBundle = FrameworkUtils.resolveBundle(bundleContext, rootBundleId);
        BundleRevision rootRevision = rootBundle.adapt(BundleRevision.class);
        return getRevisionTransitiveClosure(rootRevision, namespace);
    }

    private Map<BundleRevision, Integer> getRevisionTransitiveClosure(BundleRevision rootRevision, String namespace) {
        Map<BundleRevision, Integer> revisionIDMap = new HashMap<BundleRevision, Integer>();
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredRequirements(long, java.lang.String, boolean)
     */
    public TabularData getRevisionsDeclaredRequirements(long bundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
        BundleRevisions revisions = bundle.adapt(BundleRevisions.class);

        TabularData td = new TabularDataSupport(BundleWiringStateMBean.REVISIONS_REQUIREMENTS_TYPE);
        for (BundleRevision revision : revisions.getRevisions()) {
            td.put(BundleWiringData.getRevisionRequirements(
                    System.identityHashCode(revision),
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredCapabilities(long, java.lang.String, boolean)
     */
    public TabularData getRevisionsDeclaredCapabilities(long bundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
        BundleRevisions revisions = bundle.adapt(BundleRevisions.class);

        TabularData td = new TabularDataSupport(BundleWiringStateMBean.REVISIONS_CAPABILITIES_TYPE);
        for (BundleRevision revision : revisions.getRevisions()) {
            td.put(BundleWiringData.getRevisionCapabilities(
                    System.identityHashCode(revision),
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsWiring(long, java.lang.String)
     */
    public TabularData getRevisionsWiring(long bundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
        BundleRevisions revisions = bundle.adapt(BundleRevisions.class);

        TabularData td = new TabularDataSupport(BundleWiringStateMBean.BUNDLES_WIRING_TYPE);
        for (BundleRevision revision : revisions.getRevisions()) {
            Map<BundleRevision, Integer> revisionIDMap = getRevisionTransitiveClosure(revision, namespace);
            td.put(getRevisionWiring(revision, System.identityHashCode(revision), namespace, revisionIDMap));
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getWiringClosure(long, java.lang.String)
     */
    public TabularData getRevisionsWiringClosure(long rootBundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, rootBundleId);
        BundleRevisions revisions = bundle.adapt(BundleRevisions.class);

        Map<BundleRevision, Integer> revisionIDMap = new HashMap<BundleRevision, Integer>();
        for (BundleRevision revision : revisions.getRevisions()) {
            populateTransitiveRevisions(namespace, revision, revisionIDMap);
        }
View Full Code Here

            populateTransitiveRevisions(namespace, revision, revisionIDMap);
        }

        // Set the root current revision ID to 0,
        // TODO check if there is already a revision with ID 0 and if so swap them. Quite a small chance that this will be needed
        BundleRevision revision = bundle.adapt(BundleRevision.class);
        revisionIDMap.put(revision, 0);

        TabularData td = new TabularDataSupport(BundleWiringStateMBean.BUNDLES_WIRING_TYPE);
        for (Map.Entry<BundleRevision, Integer> entry : revisionIDMap.entrySet()) {
            td.put(getRevisionWiring(entry.getKey(), entry.getValue(), namespace, revisionIDMap));
View Full Code Here

        properties.save();
    }

    public void setStartLevel(int startLevel) {
        Bundle b = getBundleContext().getBundle(0);
        FrameworkStartLevel fsl = (FrameworkStartLevel) b.adapt(FrameworkStartLevel.class);
        fsl.setStartLevel(startLevel, null);
    }

    public int getStartLevel() {
        Bundle b = getBundleContext().getBundle(0);
View Full Code Here

        fsl.setStartLevel(startLevel, null);
    }

    public int getStartLevel() {
        Bundle b = getBundleContext().getBundle(0);
        FrameworkStartLevel fsl = (FrameworkStartLevel) b.adapt(FrameworkStartLevel.class);
        return fsl.getStartLevel();
    }

    /* for backward compatibility */

 
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.