Package org.osgi.framework

Examples of org.osgi.framework.ServiceEvent


        when(b1.getLocation()).thenReturn("file:/location");
        when(reference.getBundle()).thenReturn(b1);
        when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(44));
        when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] {"org.apache.aries.jmx.Mock"});
       
        ServiceEvent registeredEvent = mock(ServiceEvent.class);
        when(registeredEvent.getServiceReference()).thenReturn(reference);
        when(registeredEvent.getType()).thenReturn(ServiceEvent.REGISTERED);
      
        ServiceEvent modifiedEvent = mock(ServiceEvent.class);
        when(modifiedEvent.getServiceReference()).thenReturn(reference);
        when(modifiedEvent.getType()).thenReturn(ServiceEvent.MODIFIED);
       
        MBeanServer server = mock(MBeanServer.class);
       
        //setup for notification
        ObjectName objectName = new ObjectName(OBJECTNAME);
View Full Code Here


            Dictionary<String, Object> dict) {
        synchronized (listeners) {
            for (Entry<ServiceListener, Filter> entry : listeners.entrySet()) {
                Filter filter = entry.getValue();
                if (filter == null || filter.match(dict)) {
                    entry.getKey().serviceChanged(new ServiceEvent(eventType, serviceReference));
                }
            }
        }
    }
View Full Code Here

        @Override
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void serviceChanged(org.jboss.gravia.runtime.ServiceEvent event) {
            ServiceReference<?> sref = new ServiceReferenceAdaptor(event.getServiceReference());
            delegate.serviceChanged(new ServiceEvent(event.getType(), sref));
        }
View Full Code Here

        @Override
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void serviceChanged(org.jboss.gravia.runtime.ServiceEvent event) {
            ServiceReference<?> sref = new ServiceReferenceAdaptor(event.getServiceReference());
            delegate.serviceChanged(new ServiceEvent(event.getType(), sref));
        }
View Full Code Here

     * @since 1.1
     */
    public static void assertServiceEvent(String message, int eventTypeMask, Filter filter, boolean all, long timeout, TimeUnit timeUnit) {
        assertNotNull("Filter is null", filter);
        assertNotNull("TimeUnit is null", timeUnit);
        ServiceEvent event = waitForServiceEvent(getBundleContext(), filter, eventTypeMask, all, timeout, timeUnit);
        assertNotNull(message, event);
    }
View Full Code Here

     * @since 1.1
     */
    public static void assertServiceEvent(String message, int eventTypeMask, String className, boolean all, long timeout, TimeUnit timeUnit) {
        assertNotNull("Class name is null", className);
        assertNotNull("TimeUnit is null", timeUnit);
        ServiceEvent event = waitForServiceEvent(getBundleContext(), className, eventTypeMask, all, timeout, timeUnit);
        assertNotNull(message, event);
    }
View Full Code Here

     * @since 1.1
     */
    public static void assertServiceEvent(String message, int eventTypeMask, Class clazz, boolean all, long timeout, TimeUnit timeUnit) {
        assertNotNull("Class is null", clazz);
        assertNotNull("TimeUnit is null", timeUnit);
        ServiceEvent event = waitForServiceEvent(getBundleContext(), clazz, eventTypeMask, all, timeout, timeUnit);
        assertNotNull(message, event);
    }
View Full Code Here

   
    private void notifyAllListeners(int eventType) {
      List<ServiceListener> copy = new ArrayList<ServiceListener>(listeners.size());
      copy.addAll(listeners);
      for(ServiceListener listener : copy) {
        listener.serviceChanged(new ServiceEvent(eventType, Skeleton.newMock(this, ServiceReference.class)));
      }
    }
View Full Code Here

            expect(expBundle.getBundleContext()).andReturn(expBundleContext).anyTimes();
            expect(expBundle.getState()).andReturn(Bundle.ACTIVE).anyTimes();

            replay(bundleContext, registration, reference, expBundleContext, expBundle);

            manager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, reference));
            Thread.sleep(1000);

            verify(bundleContext, registration, reference, expBundleContext, expBundle);

        }
View Full Code Here

      log.trace("Calling listener for already registered services: "
          + ObjectUtils.nullSafeToString(alreadyRegistered));

    if (alreadyRegistered != null) {
      for (int i = 0; i < alreadyRegistered.length; i++) {
        listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, alreadyRegistered[i]));
      }
    }
  }
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.