Package org.osgi.framework

Examples of org.osgi.framework.FrameworkListener


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


    protected MBeanRegistrator(MBeanServer server, AgentContext ac) {
      this.server = server;
      this.ac=ac;
     
      fl = new FrameworkListener() {
        public void frameworkEvent(FrameworkEvent event) {
          if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
            // We cannot know which are the affected packages, just refresh all
            //However, registering mbeans is expensive, as it involves reflection
            //TODO improve this
View Full Code Here

        File f = new File("../testbundles").getAbsoluteFile();
        assertTrue("Failed to find test bundles directory?!", f.exists() && f.isDirectory());

        m_testBundleBasePath = f.getAbsolutePath();

        m_context.addFrameworkListener(new FrameworkListener() {
            public void frameworkEvent(FrameworkEvent event) {
                if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
                    m_gate.getAndIncrement();
                }
            }
View Full Code Here

    public static void changeStartLevel(final BundleContext context, final int level, final long timeout, final TimeUnit units) throws InterruptedException, TimeoutException {
        final ServiceReference sref = context.getServiceReference(StartLevel.class.getName());
        final StartLevel startLevel = (StartLevel) context.getService(sref);
        if (level != startLevel.getStartLevel()) {
            final CountDownLatch latch = new CountDownLatch(1);
            context.addFrameworkListener(new FrameworkListener() {
                public void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED && level == startLevel.getStartLevel()) {
                        latch.countDown();
                    }
                }
View Full Code Here

    public static void changeStartLevel(final BundleContext context, final int level, final long timeout, final TimeUnit units) throws InterruptedException, TimeoutException {
        final ServiceReference sref = context.getServiceReference(StartLevel.class.getName());
        final StartLevel startLevel = (StartLevel) context.getService(sref);
        if (level != startLevel.getStartLevel()) {
            final CountDownLatch latch = new CountDownLatch(1);
            context.addFrameworkListener(new FrameworkListener() {
                public void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED && level == startLevel.getStartLevel()) {
                        latch.countDown();
                    }
                }
View Full Code Here

                                        }
                                        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

                        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

    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

        doSetStartLevel(fsl, level, timeout);
    }

    protected void doSetStartLevel(FrameworkStartLevel fsl, int level, long timeout) throws InterruptedException {
        final CountDownLatch latch = new CountDownLatch(1);
        fsl.setStartLevel(level, new FrameworkListener() {
            public void frameworkEvent(FrameworkEvent event) {
                latch.countDown();
            }
        });
        if (timeout > 0) {
View Full Code Here

                                        }
                                        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

TOP

Related Classes of org.osgi.framework.FrameworkListener

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.