Examples of serviceChanged()


Examples of org.osgi.framework.ServiceListener.serviceChanged()

                EasyMock.expect(cdRef.getProperty(CommandProcessor.COMMAND_FUNCTION)).andReturn("bar");
                EasyMock.expect(cdRef.getProperty("service.ranking")).andReturn("1");
                EasyMock.replay(cdRef);

                ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, cdRef);
                commandListener.serviceChanged(event);
                assertEquals(4, scp.getCommands().size());
                assertTrue(scp.getCommands().contains("foo:bar"));

                ServiceReference<?> cd2Ref = EasyMock.createMock(ServiceReference.class);
                EasyMock.expect(cd2Ref.getProperty(CommandProcessor.COMMAND_SCOPE)).andReturn("xxx");
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

                        new String[] {"aaa", "bbb"});
                EasyMock.expect(cd2Ref.getProperty("service.ranking")).andReturn("2");
                EasyMock.replay(cd2Ref);

                ServiceEvent event2 = new ServiceEvent(ServiceEvent.REGISTERED, cd2Ref);
                commandListener.serviceChanged(event2);
                assertEquals(6, scp.getCommands().size());
                assertTrue(scp.getCommands().contains("xxx:aaa"));
                assertTrue(scp.getCommands().contains("xxx:bbb"));

                return null;
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    try {
      bundleContext.addServiceListener(sl, filter);
      ServiceReference[] srl = bundleContext.getServiceReferences(null, filter);
      if (srl != null) {
        for (ServiceReference sr : srl) {
          sl.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sr));
        }
      }
    } catch (InvalidSyntaxException e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

        String filter = "(objectclass=" + Servlet.class.getName() + ")";
        try {
            bc.addServiceListener(sl, filter);
            ServiceReference[] servlets = bc.getServiceReferences(null, filter);
            for (int i = 0; servlets != null && i < servlets.length; i++) {
                sl.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, servlets[i]));
            }
        } catch (InvalidSyntaxException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    assertFalse(col.isEmpty());
    Set listeners = bundleContext.getServiceListeners();

    ServiceListener list = (ServiceListener) listeners.iterator().next();
    list.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, ref));

    try {
      // disable filter
      col.isEmpty();
      fail("should have thrown exception");
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    services.put(ref, service);

    for (Iterator iter = context.getServiceListeners().iterator(); iter.hasNext();) {
      ServiceListener listener = (ServiceListener) iter.next();
      listener.serviceChanged(event);
    }
  }

  protected void addService(Object service) {
    addService(service, new Properties());
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    ServiceEvent event = new ServiceEvent(ServiceEvent.UNREGISTERING, ref);

    for (Iterator iter = context.getServiceListeners().iterator(); iter.hasNext();) {
      ServiceListener listener = (ServiceListener) iter.next();
      listener.serviceChanged(event);
    }

  }
}
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    // save old ref and invalidate it so new services are not found
    ServiceReference oldRef = refs[0];
    refs = null;

    sl.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, oldRef));

    assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(1, SimpleTargetSourceLifecycleListener.UNBIND);
  }
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);

    assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);

    sl.serviceChanged(event);

    assertEquals(2, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);
  }
View Full Code Here

Examples of org.osgi.framework.ServiceListener.serviceChanged()

    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);

    ServiceListener sl = (ServiceListener) bundleContext.getServiceListeners().iterator().next();

    // unregister the old service
    sl.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, refs[0]));

    // a new one is found since the mock context will return one again
    assertEquals(2, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);
  }
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.