Package org.osgi.framework

Examples of org.osgi.framework.ServiceEvent


    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


    Object target = new Object();
    Method m = target.getClass().getDeclaredMethod("hashCode", null);

    MethodInvocation invocation = new MockMethodInvocation(m);
    createInterceptor(new MockFilter(nullFilter));
    ServiceEvent event = new ServiceEvent(ServiceEvent.UNREGISTERING, reference);
    listener.serviceChanged(event);
    interceptor.getRetryTemplate().reset(3000);
    long now = System.currentTimeMillis();
    try {
      interceptor.invoke(invocation);
View Full Code Here

   * Test method for
   * {@link org.springframework.osgi.service.interceptor.ServiceDynamicInterceptor#getTarget()}.
   */
  public void testGetTarget() throws Throwable {
    // add service
    ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, reference);
    listener.serviceChanged(event);

    Object target = interceptor.getTarget();
    assertSame("target not properly discovered", service, target);
  }
View Full Code Here

    assertSame("target not properly discovered", service, target);
  }

  public void testGetTargetWhenMultipleServicesAreAvailable() throws Throwable {
    // add service
    ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, reference);
    listener.serviceChanged(event);

    event = new ServiceEvent(ServiceEvent.REGISTERED, ref2);
    listener.serviceChanged(event);

    Object target = interceptor.getTarget();
    assertSame("target not properly discovered", service, target);

    createInterceptor(new MockFilter(serv2Filter));
    event = new ServiceEvent(ServiceEvent.UNREGISTERING, reference);
    listener.serviceChanged(event);

    try {
      target = interceptor.getTarget();
    }
View Full Code Here

        continue;

      // Explicitly register the JAXB service by crafting a manual ServiceEvent
      for (ServiceReference ref : refs) {
        try {
          ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);
          jsr311ServiceListener.serviceChanged(event);
        } catch (Throwable t) {
          logger.error("Error registering JAXRS annotated service {} : {}", ref);
        }
      }
View Full Code Here

    for (Bundle bundle : componentContext.getBundleContext().getBundles()) {
      ServiceReference[] refs = bundle.getRegisteredServices();
      if (refs == null)
        continue;
      for (ServiceReference ref : refs) {
        ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);
        jsr311ServiceListener.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.