Package org.osgi.framework

Examples of org.osgi.framework.ServiceEvent


        ImportedOsgiServiceProxy serviceProxy = (ImportedOsgiServiceProxy) iterator.next();
        ServiceReference ref = serviceProxy.getServiceReference();

        // get first the destruction callback
        ProxyPlusCallback ppc = (ProxyPlusCallback) servicesIdMap.get((Long) ref.getProperty(Constants.SERVICE_ID));
        listener.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, ref));

        try {
          ppc.destructionCallback.destroy();
        }
        catch (Exception ex) {
View Full Code Here


      isDuringDestruction = true;
      if (wrapper != null) {
        ServiceReference ref = wrapper.getReference();
        if (ref != null) {
          // send unregistration event to the listener
          listener.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, ref));
        }
      }
      /** destruction process has ended */
      isDuringDestruction = false;
      // notify also any proxies that still wait on the service
View Full Code Here

              // so another candidate has to be searched from the existing candidates
              // - as they are alive already, we have to send an event for them ourselves
              // MODIFIED will be used for clarity
              if (newReference != null) {
                // update the listeners (through a MODIFIED event
                serviceChanged(new ServiceEvent(ServiceEvent.MODIFIED, newReference));
              }
            }

            // if no new reference was found and the service was indeed removed (it was bound to the interceptor)
            // then do an unbind
View Full Code Here

    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

  }

  protected void addService(Object service, Dictionary properties) {

    ServiceReference ref = null;
    ServiceEvent event = null;

    Set intfs = ClassUtils.getAllInterfacesAsSet(service);
    String[] clazzez = new String[intfs.size()];

    int i = 0;
    for (Iterator iter = intfs.iterator(); iter.hasNext();) {
      clazzez[i++] = ((Class) iter.next()).getName();
    }

    ref = new MockServiceReference(null, properties, null, clazzez);

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

    services.put(ref, service);

    for (Iterator iter = context.getServiceListeners().iterator(); iter.hasNext();) {
      ServiceListener listener = (ServiceListener) iter.next();
View Full Code Here

      }
    }

    services.remove(ref);

    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

    assertEquals("UNKNOWN EVENT TYPE", OsgiStringUtils.nullSafeToString(new BundleEvent(-123, bundle)));
  }

  public void testNullSafeToStringServiceEvent() throws Exception {
    ServiceReference ref = new MockServiceReference();
    assertEquals("REGISTERED", OsgiStringUtils.nullSafeToString(new ServiceEvent(ServiceEvent.REGISTERED, ref)));
    assertEquals("MODIFIED", OsgiStringUtils.nullSafeToString(new ServiceEvent(ServiceEvent.MODIFIED, ref)));
    assertEquals("UNREGISTERING",
      OsgiStringUtils.nullSafeToString(new ServiceEvent(ServiceEvent.UNREGISTERING, ref)));
  }
View Full Code Here

  public void testNullSafeToStringServiceEventNull() throws Exception {
    assertNotNull(OsgiStringUtils.nullSafeToString((ServiceEvent) null));
  }

  public void testNullSafeToStringServiceEventInvalidType() throws Exception {
    assertEquals("UNKNOWN EVENT TYPE", OsgiStringUtils.nullSafeToString(new ServiceEvent(-123,
      new MockServiceReference())));
  }
View Full Code Here

    // 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

    // increase service ranking
    props.put(Constants.SERVICE_RANKING, new Integer(10));

    ServiceReference ref = new MockServiceReference(null, props, null);

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

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

    sl.serviceChanged(event);
View Full Code Here

TOP

Related Classes of org.osgi.framework.ServiceEvent

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.