Examples of FrameworkWiring


Examples of org.osgi.framework.wiring.FrameworkWiring

                        logger.error("Error updating bundle.", ex);
                    }
                }
                try {
                    final CountDownLatch latch = new CountDownLatch(1);
                    FrameworkWiring wiring = bundleContext.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

    }

    protected boolean resolveBundles(Bundle... bundles) throws Exception {
        Bundle systemBundle = m_context.getBundle(0L);

        FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
        frameworkWiring.resolveBundles(Arrays.asList(bundles));
       
        for (Bundle bundle : bundles) {
            if ((bundle.getState() & Bundle.RESOLVED) == 0) {
                return false;
            }
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

    public Refresh() {
        this.defaultAllBundles = false;
    }

    protected void doExecute(List<Bundle> bundles) throws Exception {
        FrameworkWiring wiring = getBundleContext().getBundle(0).adapt(FrameworkWiring.class);
        wiring.refreshBundles(bundles == null || bundles.isEmpty() ? null : bundles);
    }
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

    protected Object doExecute() throws Exception {
        if (!confirm(session)) {
            return null;
        }
        final BundleContext bundleContext = getBundleContext().getBundle(0).getBundleContext();
        final FrameworkWiring wiring = bundleContext.getBundle().adapt(FrameworkWiring.class);
        final CountDownLatch latch = new CountDownLatch(threads);
        final Bundle[] bundles = bundleContext.getBundles();
        final AtomicBoolean[] locks = new AtomicBoolean[bundles.length];
        for (int b = 0; b < locks.length; b++) {
            locks[b] = new AtomicBoolean(true);
            // Avoid touching excluded bundles
            if (excludes.contains(Long.toString(bundles[b].getBundleId()))
                    || excludes.contains(bundles[b].getSymbolicName())) {
                continue;
            }
            // Only touch active bundles
            if (bundles[b].getState() != Bundle.ACTIVE) {
                continue;
            }
            // Now set the lock to available
            locks[b].set(false);
        }
        for (int i = 0; i < threads; i++) {
            new Thread() {
                public void run() {
                    try {
                        Random rand = new Random();
                        for (int j = 0; j < iterations; j++) {
                            for (;;) {
                                int b = rand.nextInt(bundles.length);
                                if (locks[b].compareAndSet(false, true)) {
                                    try {
                                        // Only touch active bundles
                                        if (bundles[b].getState() != Bundle.ACTIVE) {
                                            continue;
                                        }
                                        if (rand.nextInt(100) < refresh) {
                                            try {
                                                bundles[b].update();
                                                final CountDownLatch latch = new CountDownLatch(1);
                                                wiring.refreshBundles(Collections.singletonList(bundles[b]), new FrameworkListener() {
                                                    public void frameworkEvent(FrameworkEvent event) {
                                                        latch.countDown();
                                                    }
                                                });
                                                latch.await();
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

    public Resolve() {
        super(true);
    }

    protected void doExecute(List<Bundle> bundles) throws Exception {
        FrameworkWiring wiring = getBundleContext().getBundle(0).adapt(FrameworkWiring.class);
        wiring.resolveBundles(bundles == null || bundles.isEmpty() ? null : bundles);
    }
View Full Code Here

Examples of org.osgi.framework.wiring.FrameworkWiring

                    }
                }
            }
            if (watchedBundles.size() > 0) {
                // Get the wiring before any in case of a refresh of a dependency
                FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
                File localRepository = this.localRepoDetector.getLocalRepository();
                List<Bundle> updated = new ArrayList<Bundle>();
                for (Bundle bundle : watchedBundles) {
                    try {
                        updateBundleIfNecessary(localRepository, updated, bundle);
                    } catch (IOException ex) {
                        logger.error("Error watching bundle.", ex);
                    } catch (BundleException ex) {
                        logger.error("Error updating bundle.", ex);
                    }
                }
                try {
                    final CountDownLatch latch = new CountDownLatch(1);
                    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

        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

    protected Object doExecute() throws Exception {
        if (!confirm(session)) {
            return null;
        }
        final BundleContext bundleContext = getBundleContext().getBundle(0).getBundleContext();
        final FrameworkWiring wiring = bundleContext.getBundle().adapt(FrameworkWiring.class);
        final CountDownLatch latch = new CountDownLatch(threads);
        final Bundle[] bundles = bundleContext.getBundles();
        final AtomicBoolean[] locks = new AtomicBoolean[bundles.length];
        for (int b = 0; b < locks.length; b++) {
            locks[b] = new AtomicBoolean(true);
            // Avoid touching excluded bundles
            if (excludes.contains(Long.toString(bundles[b].getBundleId()))
                    || excludes.contains(bundles[b].getSymbolicName())) {
                continue;
            }
            // Only touch active bundles
            if (bundles[b].getState() != Bundle.ACTIVE) {
                continue;
            }
            // Now set the lock to available
            locks[b].set(false);
        }
        for (int i = 0; i < threads; i++) {
            new Thread() {
                public void run() {
                    try {
                        Random rand = new Random();
                        for (int j = 0; j < iterations; j++) {
                            for (;;) {
                                int b = rand.nextInt(bundles.length);
                                if (locks[b].compareAndSet(false, true)) {
                                    try {
                                        // Only touch active bundles
                                        if (bundles[b].getState() != Bundle.ACTIVE) {
                                            continue;
                                        }
                                        if (rand.nextInt(100) < refresh) {
                                            try {
                                                bundles[b].update();
                                                final CountDownLatch latch = new CountDownLatch(1);
                                                wiring.refreshBundles(Collections.singletonList(bundles[b]), new FrameworkListener() {
                                                    public void frameworkEvent(FrameworkEvent event) {
                                                        latch.countDown();
                                                    }
                                                });
                                                latch.await();
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

        }       
    }   
   
    private void startApplicationBundles() throws Exception {
        BundleContext context = bundle.getBundleContext();
        FrameworkWiring wiring = context.getBundle(0).adapt(FrameworkWiring.class);
        if (!wiring.resolveBundles(applicationBundles)) {
            LOG.debug("First resolution of application bundles failed.");
            if (!wiring.resolveBundles(applicationBundles)) {
                throw new BundleException("One or more bundles in " + getApplicationName() + " application could not be resolved.");
            } else {
                LOG.debug("Second resolution of application bundles was successful.");
            }
        }
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.