Package org.osgi.framework

Examples of org.osgi.framework.BundleListener


    private void rescheduleStart(Bundle bundle) {
        synchronized (pendingStartBundles) {
            pendingStartBundles.add(bundle);
            if (bundleListener == null) {
                bundleListener = new BundleListener() {
                    public void bundleChanged(BundleEvent event) {
                        if (event.getType() == BundleEvent.RESOLVED) {
                            executor.execute(new Runnable() {
                                public void run() {
                                    retryPendingStartBundles();
View Full Code Here


    bundleListener = getBundleListener();
    bc.addBundleListener(bundleListener);
  }

  protected BundleListener getBundleListener() {
    return new BundleListener() {
      public void bundleChanged(BundleEvent bundleEvent) {
        Notification notification = new Notification(BUNDLE_EVENT_TYPE,
            objectName, sequenceNumber++);
        notification.setUserData(new OSGiBundleEvent(bundleEvent)
            .asCompositeData());
View Full Code Here

     */
    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
        lock.lock();
        try {
            if (bundleListener == null) {
                bundleListener = new BundleListener() {
                    public void bundleChanged(BundleEvent event) {
                        final Notification notification = new Notification(EVENT, OBJECTNAME,
                                notificationSequenceNumber.getAndIncrement());
                        try {
                            notification.setUserData(new BundleEventData(event).toCompositeData());
View Full Code Here

        // capture the BundleListener registered with BundleContext to issue BundleEvents
        ArgumentCaptor<BundleListener> argument = ArgumentCaptor.forClass(BundleListener.class);       
        verify(context).addBundleListener(argument.capture());
       
        //send events
        BundleListener listener = argument.getValue();
        listener.bundleChanged(installedEvent);
        listener.bundleChanged(resolvedEvent);
       
        //shutdown dispatcher via unregister callback
        bundleState.postDeregister();
        //check the BundleListener is cleaned up
        verify(context).removeBundleListener(listener);
View Full Code Here

        // capture the BundleListener registered with BundleContext
        ArgumentCaptor<BundleListener> argument = ArgumentCaptor.forClass(BundleListener.class);       
        verify(context).addBundleListener(argument.capture());
        assertEquals(1, argument.getAllValues().size());
       
        BundleListener listener = argument.getValue();
        assertNotNull(listener);
       
        ExecutorService dispatcher = bundleState.getEventDispatcher();
       
        //do registration with another server
View Full Code Here

    public void start(BundleContext context) throws Exception {
        super.start(context);
        System.out.println("CCWPlugin.start: ENTER");
        plugin = this;
       
        context.addBundleListener(new BundleListener() {
     
      @Override
      public void bundleChanged(BundleEvent evt) {
        if (evt.getBundle() == CCWPlugin.this.getBundle()
          &&  evt.getType() == BundleEvent.STARTED) {
View Full Code Here

    public synchronized void start(final StartContext context) throws StartException {
        sysContext = injectedFramework.getValue().getBundleContext();

        // Register a {@link BundleListener} that installs a {@link ServiceListener}
        // with every Non-OSGi {@link DeploymentService}
        BundleListener bundleListener = new BundleListener() {

            @Override
            public void bundleChanged(BundleEvent event) {
                if (event.getType() == BundleEvent.INSTALLED) {
View Full Code Here

    private BundleContext bundleContext;

    private Collection<File> failedArtifacts = Lists.newLinkedList();

    public void init() {
        bundleContext.addBundleListener(new BundleListener() {
            @Override
            public void bundleChanged(BundleEvent event) {
                if (event.getType() == BundleEvent.STARTED) {
                    try {
                        tryInstallingFailedArtifacts();
View Full Code Here

        for (final Bundle bundle : context.getBundles()) {
            registerHelpers(bundle);
        }

        // Listen to installed bundles
        context.addBundleListener(new BundleListener() {
            public void bundleChanged(BundleEvent event) {
                switch (event.getType()) {
                case BundleEvent.INSTALLED:
                    registerHelpers(event.getBundle());
                    break;
View Full Code Here

    MockBundle anotherBundle = new MockBundle(hdrs);
    anotherBundle.setBundleId(1);

    BundleEvent event = new BundleEvent(BundleEvent.STARTED, anotherBundle);

    BundleListener listener = (BundleListener) ctx.getBundleListeners().iterator().next();

    TestTaskExecutor.called = false;

    listener.bundleChanged(event);
    assertTrue("task executor should have been called if configured properly", TestTaskExecutor.called);
  }
View Full Code Here

TOP

Related Classes of org.osgi.framework.BundleListener

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.