Package org.osgi.framework

Examples of org.osgi.framework.ServiceListener


            EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {

                public Object answer() throws Throwable {
                    System.out.println("->   addServiceListener: "
                                       + 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


            public Object answer() throws Throwable {

                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

        synchronized (m_sidToListenersMap) {
            List /* <ServiceListener> */ list = (ArrayList) m_sidToListenersMap.get(sid);
            if (list != null) {
              Iterator iterator = list.iterator();
              while (iterator.hasNext()) {
                  ServiceListener listener = (ServiceListener) iterator.next();
                  String objectClass = (String) m_listenerToObjectClassMap.get(listener);
                  if (referenceMatchesObjectClass(reference, objectClass)) {
                    notificationList.add(listener);
                  }
              }
            }
        }
        // notify
        Iterator iterator = notificationList.iterator();
        while (iterator.hasNext()) {
          ServiceListener listener = (ServiceListener) iterator.next();
          listener.serviceChanged(event);
        }
    }
View Full Code Here

    public void serviceChanged(ServiceEvent event) {
        Entry[] entries = synchronizeCollection();
        for (int i = 0; i < entries.length; i++) {
            Entry serviceListenerFilterEntry = entries[i];
            ServiceListener serviceListener = (ServiceListener) serviceListenerFilterEntry.getKey();
            String filter = (String) serviceListenerFilterEntry.getValue();
            if (filter == null) {
                serviceListener.serviceChanged(event);
            }
            else {
                // call service changed on the listener if the filter matches the event
                // TODO review if we can be smarter here
                try {
                    if ("(objectClass=*)".equals(filter)) {
                        serviceListener.serviceChanged(event);
                    }
                    else {
                        if (m_context.createFilter(filter).match(event.getServiceReference())) {
                            serviceListener.serviceChanged(event);
                        }
                    }
                }
                catch (InvalidSyntaxException e) {
                    e.printStackTrace();
View Full Code Here

            }
          }
    }
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            ServiceListener listener = (ServiceListener) iterator.next();
            listener.serviceChanged(event);
        }
    }
View Full Code Here

                }
            }
            if (list != null) {
                Iterator iterator = list.iterator();
                while (iterator.hasNext()) {
                    ServiceListener listener = (ServiceListener) iterator.next();
                    listener.serviceChanged(event);
                }
            }
        }
    }
View Full Code Here

    @Override
    public void start(final BundleContext context) throws Exception {

        // Add a listener that tracks {@link Resolver} and {@link Repository}
        ServiceListener listener = new ServiceListener() {

            @Override
            @SuppressWarnings("unchecked")
            public void serviceChanged(ServiceEvent event) {
                if (event.getType() == ServiceEvent.REGISTERED) {
View Full Code Here

   
    /**
     * @see org.cishell.remoting.service.framework.CIShellFramework#closeSession(java.lang.String)
     */
    public void closeSession(String sessionID) {
        ServiceListener listener = (ServiceListener) listeners.getObject(sessionID);
        bContext.removeServiceListener(listener);
       
        listeners.unregister(sessionID);
    }
View Full Code Here

        public CommandTracker() throws Exception {
            BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
            if (context == null) {
                throw new IllegalStateException("Bundle is stopped");
            }
            ServiceListener listener = new ServiceListener() {
                public void serviceChanged(ServiceEvent event) {
                    commands.clear();
                }
            };
            context.addServiceListener(listener,
View Full Code Here

        public CommandTracker() throws Exception {
            BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
            if (context == null) {
                throw new IllegalStateException("Bundle is stopped");
            }
            ServiceListener listener = new ServiceListener() {
                public void serviceChanged(ServiceEvent event) {
                    synchronized (CommandsCompleter.this) {
                        commands.clear();
                    }
                }
View Full Code Here

TOP

Related Classes of org.osgi.framework.ServiceListener

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.