Package org.osgi.framework

Examples of org.osgi.framework.ServiceEvent


    {
        updateHook(reg.getReference());
        if (m_callbacks != null)
        {
            m_callbacks.serviceChanged(
                new ServiceEvent(ServiceEvent.MODIFIED, reg.getReference()), oldProps);
        }
    }
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

                }
            }
        }

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

        return reg;
    }
View Full Code Here

    }


    private void fireServiceEvent( ServiceReference ref, int type )
    {
        ServiceEvent se = new ServiceEvent( type, ref );
        for ( Iterator li = serviceListeners.iterator(); li.hasNext(); )
        {
            ( ( ServiceListener ) li.next() ).serviceChanged( se );
        }
    }
View Full Code Here

        EasyMock.replay(new Object[]
            {
                sr
            });

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

        assertEquals("Precondition failed", 0, fired.size());

        Framework framework = EasyMock.createNiceMock(Framework.class);
        EasyMock.replay(new Object[]
View Full Code Here

        Mockito.when(reference.getProperty(Constants.SERVICE_RANKING)).thenReturn(props.get(Constants.SERVICE_RANKING));
        // service registration for ConnectionFactory service
        ServiceRegistration registration = (ServiceRegistration) Mockito.mock(ServiceRegistration.class);
        Mockito.when(registration.getReference()).thenReturn(reference);
        // service event
        ServiceEvent registeredEvent = (ServiceEvent) Mockito.mock(ServiceEvent.class);
        Mockito.when(registeredEvent.getServiceReference()).thenReturn(reference);
        Mockito.when(new Integer(registeredEvent.getType())).thenReturn(new Integer(ServiceEvent.REGISTERED));
        Mockito.when(m_bundleContext.getService(reference)).thenReturn(connFactory);
        // sending registration event
        // service tracker for ConnectionFactory service used by ConnectorService
        // will be informed about service registration
        m_serviceListener.serviceChanged(registeredEvent);
View Full Code Here

                                       + EasyMock.getCurrentArguments()[1]);
                    ServiceListener sl = (ServiceListener)EasyMock.getCurrentArguments()[0];

                    if ("(objectClass=org.osgi.service.remoteserviceadmin.RemoteServiceAdmin)"
                        .equals(EasyMock.getCurrentArguments()[1])) {
                        ServiceEvent se = new ServiceEvent(ServiceEvent.REGISTERED, rsaSref);
                        sl.serviceChanged(se);
                    } else if ("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"
                        .equals(EasyMock.getCurrentArguments()[1])) {
                        ServiceEvent se = new ServiceEvent(ServiceEvent.REGISTERED, eplSref);
                        sl.serviceChanged(se);
                    }

                    return null;
                }
            }).anyTimes();

            bctx.addServiceListener((ServiceListener)EasyMock.anyObject());
            EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {

                public Object answer() throws Throwable {
                    System.out.println("->   addServiceListener ");

                    ServiceListener sl = (ServiceListener)EasyMock.getCurrentArguments()[0];

                    ServiceEvent se = new ServiceEvent(ServiceEvent.REGISTERED, sref);
                    sl.serviceChanged(se);
                    se = new ServiceEvent(ServiceEvent.REGISTERED, eplSref);
                    sl.serviceChanged(se);
                    se = new ServiceEvent(ServiceEvent.REGISTERED, rsaSref);
                    sl.serviceChanged(se);

                    return null;
                }
            }).anyTimes();
View Full Code Here

                System.out.println("->   addServiceListener ");

                ServiceListener sl = (ServiceListener)EasyMock.getCurrentArguments()[0];

                ServiceEvent se = new ServiceEvent(ServiceEvent.REGISTERED, rsaSref);
                sl.serviceChanged(se);

                assertEquals(1,rsal.size());
               
                se = new ServiceEvent(ServiceEvent.UNREGISTERING, rsaSref);
                sl.serviceChanged(se);
               
                assertEquals(0,rsal.size());
               
                return null;
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());
                    ((ServiceListener) l).serviceChanged(se);

                }
View Full Code Here

                }
            }
        }

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

        return reg;
    }
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.