/** @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */
  public void stop(BundleContext bundleContext) {
    // shut down the trackers.
    m_eventAdmin.destroy();

    // Clean up the listeners.
    bundleContext.removeBundleListener(m_frameworkHandler);
    bundleContext.removeFrameworkListener(m_frameworkHandler);
    bundleContext.removeServiceListener(m_frameworkHandler);

    // Remove the global handler for all JDK Logging (java.util.logging).
    if (m_JdkHandler != null) {
      Logger rootLogger = LogManager.getLogManager().getLogger("");
      rootLogger.removeHandler(m_JdkHandler);
      m_JdkHandler.flush();
      m_JdkHandler.close();
      m_JdkHandler = null;
    }

    m_RegistrationPaxLogging.unregister();
    m_RegistrationPaxLogging = null;

    m_registrationLogReaderService.unregister();
    m_registrationLogReaderService = null;

    m_paxLogging.stop();
    m_paxLogging = null;
  }
 /**
  * Close this {@code BundleTracker}.
  *
  * <p>This method should be called when this {@code BundleTracker} should end the tracking of
  * bundles.
  *
  * <p>This implementation calls {@link #getBundles()} to get the list of tracked bundles to
  * remove.
  */
 public void close() {
   final Bundle[] bundles;
   final Tracked outgoing;
   synchronized (this) {
     outgoing = tracked;
     if (outgoing == null) {
       return;
     }
     if (DEBUG) {
       System.out.println("BundleTracker.close"); // $NON-NLS-1$
     }
     outgoing.close();
     bundles = getBundles();
     tracked = null;
     try {
       context.removeBundleListener(outgoing);
     } catch (IllegalStateException e) {
       /* In case the context was stopped. */
     }
   }
   if (bundles != null) {
     for (int i = 0; i < bundles.length; i++) {
       outgoing.untrack(bundles[i], null);
     }
   }
 }
Exemplo n.º 3
0
  public void dispose() {
    bundleContext.removeBundleListener(this);

    synchronized (delayedBundles) {
      delayedBundles.clear();
    }
  }
Exemplo n.º 4
0
 @Override
 public synchronized void stop(BundleContext bundleContext) throws Exception {
   debug("deactivating");
   bundleContext.removeBundleListener(this);
   while (!bundleWrappers.isEmpty()) {
     unregister(bundleWrappers.keySet().iterator().next());
   }
   debug("deactivated");
   this.bundleContext = null;
 }
  @Test
  public void testBundleListener() throws Exception {
    Bundle bundle = installBundle(getBundleArchiveA());
    try {
      bundle.start();
      BundleContext bundleContext = bundle.getBundleContext();
      assertNotNull(bundleContext);

      try {
        bundleContext.addBundleListener(null);
        fail("Should not be here!");
      } catch (IllegalArgumentException t) {
        // expected
      }

      try {
        bundleContext.removeBundleListener(null);
        fail("Should not be here!");
      } catch (IllegalArgumentException t) {
        // expected
      }

      bundle.stop();

      getSystemContext().addBundleListener(this);

      bundle.start();
      assertBundleEvent(BundleEvent.STARTING, bundle);
      assertBundleEvent(BundleEvent.STARTED, bundle);
      assertNoBundleEvent();

      bundle.stop();
      assertBundleEvent(BundleEvent.STOPPING, bundle);
      assertBundleEvent(BundleEvent.STOPPED, bundle);
      assertNoBundleEvent();

      getSystemContext().removeBundleListener(this);
      bundle.start();
      bundle.stop();
      assertNoBundleEvent();

      getSystemContext().addBundleListener(this);
      getSystemContext().addBundleListener(this);
      bundle.start();
      assertBundleEvent(BundleEvent.STARTING, bundle);
      assertBundleEvent(BundleEvent.STARTED, bundle);
      assertNoBundleEvent();

      bundle.stop();
      assertBundleEvent(BundleEvent.STOPPING, bundle);
      assertBundleEvent(BundleEvent.STOPPED, bundle);
      assertNoBundleEvent();

      bundle.start();
      assertBundleEvent(BundleEvent.STARTING, bundle);
      assertBundleEvent(BundleEvent.STARTED, bundle);
      assertNoBundleEvent();

      // [TODO] test asynch BundleListener
    } finally {
      bundle.uninstall();
    }
    assertBundleEvent(BundleEvent.STOPPING, bundle);
    assertBundleEvent(BundleEvent.STOPPED, bundle);
    assertBundleEvent(BundleEvent.UNINSTALLED, bundle);
    getSystemContext().removeBundleListener(this);
  }
 /** component stop */
 public void destroy() throws Exception {
   bundleContext.removeBundleListener(this);
 }
Exemplo n.º 7
0
 public void stop(BundleContext context) {
   context.removeBundleListener(this);
 }
 public void removeBundleListener(BundleListener listener) {
   delegate.removeBundleListener(listener);
 }
Exemplo n.º 9
0
 public void preDestroy() {
   bundleContext.removeBundleListener(this);
   cancelTimers();
 }