Package org.osgi.framework

Examples of org.osgi.framework.ServiceEvent


        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


            // matched previously.
            else if (((ServiceEvent) event).getType() == ServiceEvent.MODIFIED)
            {
                if (filter.match(oldProps))
                {
                    final ServiceEvent se = new ServiceEvent(
                        ServiceEvent.MODIFIED_ENDMATCH,
                        ((ServiceEvent) event).getServiceReference());
                    if (System.getSecurityManager() != null)
                    {
                        AccessController.doPrivileged(new PrivilegedAction()
View Full Code Here

        // Notify callback objects about unregistering service.
        if (m_callbacks != null)
        {
            m_callbacks.serviceChanged(
                new ServiceEvent(ServiceEvent.UNREGISTERING, reg.getReference()), null);
        }

        // Now forcibly unget the service object for all stubborn clients.
        synchronized (this)
        {
View Full Code Here

    {
        updateHook(reg.getReference());
        if (m_callbacks != null)
        {
            m_callbacks.serviceChanged(
                new ServiceEvent(ServiceEvent.MODIFIED, reg.getReference()), oldProps);
        }
    }
View Full Code Here

                }
            }
        }

        // Fire service event.
        fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, reg.getReference()), null);

        return reg;
    }
View Full Code Here

    zk = new ZooKeeper(zkAddr + ":" + serverPort, 3000, this);
    create(ROOT_PATH);
    update();
    ServiceReference[] refs = context.getAllServiceReferences(null, null);
    for (ServiceReference ref : refs) {
      ServiceEvent evt = new ServiceEvent(ServiceEvent.REGISTERED, ref);
      process(evt);
    }
  }
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

   
    @Test
    public void testToCompositeData() throws Exception {

        ServiceEvent event = mock(ServiceEvent.class);
        ServiceReference reference = mock(ServiceReference.class);
        Bundle bundle = mock(Bundle.class);
       
        when(event.getType()).thenReturn(ServiceEvent.REGISTERED);
        when(event.getServiceReference()).thenReturn(reference);
        when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(44));
        when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] {"org.apache.aries.jmx.Mock"});
        when(reference.getBundle()).thenReturn(bundle);
        when(bundle.getBundleId()).thenReturn(new Long(1));
        when(bundle.getLocation()).thenReturn("string");
View Full Code Here

        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

   
    @Test
    public void testToCompositeData() throws Exception {

        ServiceEvent event = mock(ServiceEvent.class);
        ServiceReference reference = mock(ServiceReference.class);
        Bundle bundle = mock(Bundle.class);
       
        when(event.getType()).thenReturn(ServiceEvent.REGISTERED);
        when(event.getServiceReference()).thenReturn(reference);
        when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(44));
        when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] {"org.apache.aries.jmx.Mock"});
        when(reference.getBundle()).thenReturn(bundle);
        when(bundle.getBundleId()).thenReturn(new Long(1));
        when(bundle.getLocation()).thenReturn("string");
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.