Package org.osgi.framework

Examples of org.osgi.framework.BundleContext.addBundleListener()


   
    public void testBundleListener() {
        final BundleListener[] bundleListener = new BundleListener[1];
       
        BundleContext bc = EasyMock.createMock(BundleContext.class);
        bc.addBundleListener((BundleListener) EasyMock.anyObject());
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {           
            public Object answer() throws Throwable {
                bundleListener[0] = (BundleListener) EasyMock.getCurrentArguments()[0];
                return null;
            }
View Full Code Here


    public void testCreatThenShutdown() {
        final List<String> bundleListenerRegs = new ArrayList<String>();
       
        IMocksControl control = EasyMock.createNiceControl();
        BundleContext bc = control.createMock(BundleContext.class);
        bc.addBundleListener((BundleListener) EasyMock.anyObject());
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                assertTrue("Should be a LocalDiscoveryService",
                        EasyMock.getCurrentArguments()[0] instanceof LocalDiscoveryService);
                bundleListenerRegs.add("addBundleListener");
View Full Code Here

  {
    // So we need to cope with multiple equinox frameworks, so we can't just listen to our
    // BundleContext. Instead we add a listener to Bundle 0 of the framework bundle associated
    // with the bundle passed in.
    BundleContext ctx = b.getBundleContext().getBundle(0).getBundleContext();
    ctx.addBundleListener(this);
    ctx.addFrameworkListener(this);
  }

  private synchronized ClassLoader put(Bundle b, ClassLoader cl)
  {
View Full Code Here

        // passed as parameter won't work because a stopping bundle can't receive asynchronous events.
        BundleContext systemBundleContext = bundle.getBundleContext().getBundle(0).getBundleContext();
        Listener listener = new Listener(bundle);
        // Need a framework listener to intercept errors that would otherwise end up only being logged
        systemBundleContext.addFrameworkListener(listener);
        systemBundleContext.addBundleListener(listener);
        try {
            // Note: the stop method may also throw exceptions
            bundle.stop();
            listener.check();
        } finally {
View Full Code Here

    private void setupListener(Bundle b) {
        // So we need to cope with multiple equinox frameworks, so we can't just listen to our
        // BundleContext. Instead we add a listener to Bundle 0 of the framework bundle associated
        // with the bundle passed in.
        BundleContext ctx = b.getBundleContext().getBundle(0).getBundleContext();
        ctx.addBundleListener(this);
        ctx.addFrameworkListener(this);
    }

    private synchronized ClassLoader put(Bundle b, ClassLoader cl) {
        // If the bundle is uninstalled or installed then there is no classloader so we should
View Full Code Here

    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setEntryReturnOnNextCallToGetEntry(null);
    bundleContextControl.expectAndReturn(context.getBundle(), aBundle, MockControl.ONE_OR_MORE);

    // listen for bundle events
    context.addBundleListener(null);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
    bundleContextControl.setVoidCallable(2);

    bundleContextControl.expectAndReturn(context.registerService(new String[0], null, new Properties()),
      new MockServiceRegistration(), MockControl.ONE_OR_MORE);
View Full Code Here

    for (Bundle bundle : bundleCtx.getBundles()) {
      if (bundle.getState() == Bundle.ACTIVE)
        registerResources(bundle);
    }

    bundleCtx.addBundleListener(this);
  }

  /**
   * OSGi callback on component inactivation.
   *
 
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.