Examples of BundleEvent


Examples of org.osgi.framework.BundleEvent

    public void afterPropertiesSet() throws Exception {
        // Track bundles
        bundleContext.addBundleListener(this);
        for (Bundle bundle : bundleContext.getBundles()) {
            if (bundle.getState() == Bundle.ACTIVE) {
                bundleChanged(new BundleEvent(BundleEvent.STARTED, bundle));
            }
        }
        // Track deployed components
        deployedComponentsTracker = new ServiceTracker(bundleContext, javax.jbi.component.Component.class.getName(), null) {
            public Object addingService(ServiceReference serviceReference) {
View Full Code Here

Examples of org.osgi.framework.BundleEvent

        deployedAssembliesTracker.open();
    }

    public synchronized void destroy() throws Exception {
        for (Bundle bundle : bundles) {
            bundleChanged(new BundleEvent(BundleEvent.STOPPING, bundle));
        }
        deployedComponentsTracker.close();
        deployedAssembliesTracker.close();
        bundleContext.removeBundleListener(this);
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

            bundleStore.markModified();

            generation.setState(Bundle.INSTALLED);

            fireBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle));

            LOGGER.exiting(CLASS_NAME, "installBundle", bundle);

            return bundle;
        }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

        bundleGeneration.setClassLoader(classLoader);

        bundleGeneration.setState(Bundle.RESOLVED);

        fireBundleEvent(new BundleEvent(BundleEvent.RESOLVED, bundleGeneration.getBundleController()));
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

                bundleStore.markModified();

                generation.setState(Bundle.INSTALLED);

                fireBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle));
            }
            catch (BundleException e)
            {
                e.printStackTrace()//todo: consider this autogenerated code
            }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

            {
                if (bundleGeneration.getState() != Bundle.STARTING)
                {
                    bundleGeneration.setState(Bundle.STARTING);

                    fireBundleEvent(new BundleEvent(BundleEvent.LAZY_ACTIVATION, bundleController));

                    return;
                }

                if (options == Bundle.START_ACTIVATION_POLICY) return;
View Full Code Here

Examples of org.osgi.framework.BundleEvent

            if (bundleGeneration.getState() != Bundle.STARTING) return;

            final BundleController bundleController = bundleGeneration.getBundleController();
            ArchiveStore archiveStore = bundleGeneration.getArchiveStore();

            fireBundleEvent(new BundleEvent(BundleEvent.STARTING, bundleController));

            bundleGeneration.getClassLoader().setLazyActivation(false);

            try
            {
                String bundleActivatorClassName = archiveStore.getBundleActivatorClass();
                if (bundleActivatorClassName != null)
                {
                    Class bundleActivatorClass = bundleGeneration.getClassLoader().loadClass(bundleActivatorClassName);

                    if (bundleActivatorClass == null) throw new BundleException("Bundle activator class " + bundleActivatorClassName + " not found");

                    final BundleActivator bundleActivator = (BundleActivator) bundleActivatorClass.newInstance();

                    bundleController.setBundleActivator(bundleActivator);

                    SecurityUtils.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
                    {
                        public Void run() throws Exception
                        {
                            bundleActivator.start(bundleController.getBundleContext());
                            return null;
                        }
                    },
                                                              framework.getAcc());
                }

                bundleGeneration.setState(Bundle.ACTIVE);

                fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundleController));

                return;
            }
            catch (ClassNotFoundException cnfe)
            {
                LOGGER.log(Level.WARNING, "Unable to load bundle activator class", cnfe);
            }
            catch (InstantiationException ie)
            {
                LOGGER.log(Level.WARNING, "Unable to instantiate bundle activator class", ie);
            }
            catch (IllegalAccessException iae)
            {
                LOGGER.log(Level.WARNING, "Unable to instantiate bundle activator class", iae);
            }
            catch (ClassCastException cce)
            {
                LOGGER.log(Level.WARNING, "Bundle activator not an instance of BundleActivator", cce);
            }
            catch (Throwable t)
            {
                LOGGER.log(Level.WARNING, "Unable to start bundle activator class", t);
            }

            bundleGeneration.setState(Bundle.STOPPING);

            fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundleController));

            bundleGeneration.setState(Bundle.RESOLVED);

            fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundleController));
        }
        catch (InterruptedException ie)
        {
            Thread.currentThread().interrupt();
            throw new BundleException("Interrupted while waiting to start bundle", ie);
View Full Code Here

Examples of org.osgi.framework.BundleEvent

            if (bundleGeneration.getState() != Bundle.ACTIVE) return;

            bundleGeneration.setState(Bundle.STOPPING);

            fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundleController));

            Throwable throwable = null;
            try
            {
                performDeactivation(bundleController);
            }
            catch (Throwable t)
            {
                throwable = t;
            }

            framework.getServiceRegistry().unregister(bundleController);

            bundleController.clearListeners();

            bundleGeneration.setState(Bundle.RESOLVED);

            fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundleController));

            if (throwable != null) throw new BundleException("Errors stopping bundle", throwable);
        }
        catch (InterruptedException ie)
        {
View Full Code Here

Examples of org.osgi.framework.BundleEvent

                store.removeBundleStore(bundleId);
            }

            bundleGeneration.setState(Bundle.UNINSTALLED);

            fireBundleEvent(new BundleEvent(BundleEvent.UNINSTALLED, bundleController));
        }
        catch (InterruptedException ie)
        {
            Thread.currentThread().interrupt();
            throw new BundleException("Interrupted while waiting to start bundle", ie);
View Full Code Here

Examples of org.osgi.framework.BundleEvent

  
    @Test
    public void testToCompositeData() throws Exception {

        BundleEvent event = mock(BundleEvent.class);
        Bundle bundle = mock(Bundle.class);
        when(event.getBundle()).thenReturn(bundle);
        when(bundle.getSymbolicName()).thenReturn("test");
        when(bundle.getBundleId()).thenReturn(new Long(4));
        when(bundle.getLocation()).thenReturn("location");
        when(event.getType()).thenReturn(BundleEvent.INSTALLED);
       
        BundleEventData eventData = new BundleEventData(event);
        CompositeData eventCompositeData = eventData.toCompositeData();
       
        assertEquals(new Long(4), (Long) eventCompositeData.get(IDENTIFIER));
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.