Examples of FrameworkWiring


Examples of org.osgi.framework.wiring.FrameworkWiring

    /**
     * @see org.osgi.jmx.framework.FrameworkMBean#getDependencyClosureBundles(long[])
     */
    public long[] getDependencyClosure(long[] bundles) throws IOException {
        FrameworkWiring fw = context.getBundle(0).adapt(FrameworkWiring.class);

        List<Bundle> bl = new ArrayList<Bundle>();
        for (int i=0; i < bundles.length; i++) {
            bl.add(context.getBundle(bundles[i]));
        }

        Collection<Bundle> rc = fw.getDependencyClosure(bl);

        Iterator<Bundle> it = rc.iterator();
        long[] result = new long[rc.size()];
        for (int i = 0; i < result.length; i++) {
            result[i] = it.next().getBundleId();
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

    /**
     * @see org.osgi.jmx.framework.FrameworkMBean#getRemovalPendingBundles()
     */
    public long[] getRemovalPendingBundles() throws IOException {
        FrameworkWiring fw = context.getBundle(0).adapt(FrameworkWiring.class);

        Collection<Bundle> rc = fw.getRemovalPendingBundles();
        Iterator<Bundle> it = rc.iterator();
        long[] result = new long[rc.size()];
        for (int i = 0; i < result.length; i++) {
            result[i] = it.next().getBundleId();
        }
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

                        logger.error("Error updating bundle.", ex);
                    }
                }
                try {
                    final CountDownLatch latch = new CountDownLatch(1);
                    FrameworkWiring wiring = getBundleContext().getBundle(0).adapt(FrameworkWiring.class);
                    wiring.refreshBundles(updated, new FrameworkListener() {
                        public void frameworkEvent(FrameworkEvent event) {
                            latch.countDown();
                        }
                    });
                    latch.await();
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

                targetBundle.update(fi);
            } finally {
                close(fi);
            }

            FrameworkWiring wiring = context.getBundle(0).adapt(FrameworkWiring.class);
           
            Collection<Bundle> bundles = Arrays.asList(targetBundle);
           
            // resolve the bundle
            if (!wiring.resolveBundles(bundles)) {
                StringBuilder builder = new StringBuilder();
                builder.append("Updated ").append(bundleName).append(" bundle cannot be resolved.");
               
                // check for resolver errors
                ResolverErrorAnalyzer errorAnalyzer = new ResolverErrorAnalyzer(context);
                String resolverErrors = errorAnalyzer.getErrorsAsString(bundles);
                if (resolverErrors != null) {
                    builder.append(" ").append(resolverErrors);
                }
               
                throw new BundleException(builder.toString());
            }
           
            // log dependents
            Collection<Bundle> dependents = wiring.getDependencyClosure(bundles);
            dependents.removeAll(bundles);
            if (!dependents.isEmpty()) {
                String bundleListString = bundleCollectionToString(dependents);
                LOG.info("Update of {} bundle will cause the following bundles to be refreshed: {}", bundleName, bundleListString);
            }
           
            // update application archive
            try {
                updateEBA(targetBundle, bundleFile);
            } catch (Exception e) {
                LOG.warn("Error updating application archive with the new contents. " +
                         "Changes made might be gone next time the application or server is restarted.", e.getMessage());
            }
           
            // refresh the bundle and its dependents
            RefreshListener refreshListener = new RefreshListener();
            wiring.refreshBundles(bundles, refreshListener);
            refreshListener.waitForRefresh(bundleRefreshTimeout);

            // start the bundle
            if (BundleUtils.canStart(targetBundle)) {
                targetBundle.start(Bundle.START_TRANSIENT);
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

        }       
    }   
   
    private void startApplicationBundles() throws Exception {
        BundleContext context = bundle.getBundleContext();
        FrameworkWiring wiring = context.getBundle(0).adapt(FrameworkWiring.class);
        if (!wiring.resolveBundles(applicationBundles)) {
            throw new BundleException("One or more bundles in " + getApplicationName() + " application could not be resolved.");
        }
       
        LinkedList<Bundle> bundlesWeStarted = new LinkedList<Bundle>();
        try {
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

        return result;
    }
   
    protected void refreshPackages(Collection<Bundle> bundles) {
        final Object refreshLock = new Object();
        FrameworkWiring wiring = bundleContext.getBundle().adapt(FrameworkWiring.class);
        if (wiring != null) {
            synchronized (refreshLock) {
                wiring.refreshBundles(bundles, new FrameworkListener() {
                    public void frameworkEvent(FrameworkEvent event) {
                        if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
                            synchronized (refreshLock) {
                                refreshLock.notifyAll();
                            }
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

                    latch.countDown();
                }
            }
        };

        FrameworkWiring fwWiring = syscontext.getBundle().adapt(FrameworkWiring.class);
        fwWiring.refreshBundles(Collections.singleton(bundle), listener);

        // Wait for the refresh to complete
        try {
            if (!latch.await(10, TimeUnit.SECONDS)) {
                throw new TimeoutException();
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

                    latch.countDown();
                }
            }
        };

        FrameworkWiring fwWiring = syscontext.getBundle().adapt(FrameworkWiring.class);
        fwWiring.refreshBundles(Collections.singleton(bundle), listener);

        // Wait for the refresh to complete
        try {
            if (!latch.await(10, TimeUnit.SECONDS)) {
                throw new TimeoutException();
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

            exporter.exportTo(baos);

            ByteArrayInputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
            Bundle bundle = syscontext.installBundle(archive.getName(), inputStream);

            FrameworkWiring frameworkWiring = syscontext.getBundle().adapt(FrameworkWiring.class);
            if (frameworkWiring.resolveBundles(Arrays.asList(bundle)) == false)
                throw new IllegalStateException("Cannot resolve test bundle - see framework log");

        } catch (RuntimeException rte) {
            throw rte;
        } catch (Exception ex) {
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

     * Convenience to refresh the packages
     */
    static void refresh(BundleContext context, Collection<Bundle> bundles) throws InterruptedException
    {
        final CountDownLatch latch = new CountDownLatch(1);
        FrameworkWiring wiring = context.getBundle(0).adapt(FrameworkWiring.class);
        wiring.refreshBundles(bundles, new FrameworkListener() {
            public void frameworkEvent(FrameworkEvent event) {
                latch.countDown();
            }
        });
        latch.await();
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.