Package org.osgi.framework

Examples of org.osgi.framework.ServiceListener


    this.servlet = servlet;
    this.context = context;
  }
 
  void open() {
    ServiceListener sl = new ServiceListener() {
      public void serviceChanged(ServiceEvent ev) {
        ServiceReference sr = ev.getServiceReference();
        switch(ev.getType()) {
        case ServiceEvent.REGISTERED:
          {
View Full Code Here


        assertEquals(0, this.bundleContext.getBundles().length);
    }

    @Test
    public void testServiceListener() throws Exception {
        ServiceListener serviceListener = mock(ServiceListener.class);
        bundleContext.addServiceListener(serviceListener);

        // prepare test services
        String clazz1 = String.class.getName();
        Object service1 = new Object();
View Full Code Here

        // context is set, register and get existing services
        if ( context != null )
        {
            try
            {
                ServiceListener listener = new ServiceListener()
                {
                    // Add a newly available LogService reference to the singleton.
                    @Override
                    public void serviceChanged( final ServiceEvent event )
                    {
View Full Code Here

        // context is set, register and get existing services
        if ( context != null )
        {
            try
            {
                final ServiceListener listener = new ServiceListener()
                {
                    // Add a newly available LogService reference to the singleton.
                    public void serviceChanged( final ServiceEvent event )
                    {
                        if ( ServiceEvent.REGISTERED == event.getType() )
View Full Code Here

  ///////////////////////////////////////
  public void start(BundleContext context) {
    m_context = context;

    // Listen for factory service events.
    ServiceListener sl = new ServiceListener() {
      public void serviceChanged(ServiceEvent event) {
        ServiceReference ref = event.getServiceReference();
        Object svcObj = m_context.getService(ref);
        if (event.getType() == ServiceEvent.REGISTERED) {
          synchronized (Activator.this) {
View Full Code Here

  /////////////////////
  // Plugin elements //
  /////////////////////
  private void init() throws Exception {
    this.osgiON=new ObjectName(OSGI_ON);
    ServiceListener sl = new ServiceListener() {
      public void serviceChanged(ServiceEvent event) {
        synchronized (ObrProbeTabUI.this) {
          // Ignore additional services if we already have one.
          if ((event.getType() == ServiceEvent.REGISTERED)
              && (m_brsRef != null)) {
View Full Code Here

          default: //nothing todo for the rest of the events
            break;
          }
        }
      };
      sl = new ServiceListener() {
        public void serviceChanged(ServiceEvent event) {
          switch (event.getType()) {
          case ServiceEvent.UNREGISTERING:
            unregisterServiceMBean(event.getServiceReference());
            break;
View Full Code Here

        {
            m_context = context;

            try
            {
                m_context.addServiceListener(new ServiceListener()
                {

                    public void serviceChanged(final ServiceEvent event)
                    {
                        synchronized(m_lock)
                        {
                            switch(event.getType())
                            {
                                case ServiceEvent.REGISTERED:
                                    m_adminRefs
                                        .add(event.getServiceReference());
                                    break;
                                case ServiceEvent.UNREGISTERING:
                                    m_adminRefs.remove(event
                                        .getServiceReference());
                                    break;
                            }

                            check();
                        }
                    }
                }, "(" + Constants.OBJECTCLASS + "="
                    + EventAdmin.class.getName() + ")");

                final ServiceReference[] adminRefs = m_context
                    .getServiceReferences(EventAdmin.class.getName(), null);

                if(null != adminRefs)
                {
                    for(int i = 0; i < adminRefs.length; i++)
                    {
                        m_adminRefs.add(adminRefs[i]);
                    }
                }

                m_context.addServiceListener(new ServiceListener()
                {
                    public void serviceChanged(final ServiceEvent event)
                    {
                        synchronized(m_lock)
                        {
View Full Code Here

        // -- Set up event dispatcher
        EventDispatcher ed = new EventDispatcher(logger, registry);

        // -- Register some listeners
        final List fired = Collections.synchronizedList(new ArrayList());
        ServiceListener sl1 = new ServiceListener()
        {
            public void serviceChanged(ServiceEvent arg0)
            {
                fired.add(this);
            }
        };
        ed.addListener(b1.getBundleContext(), ServiceListener.class, sl1, null);

        ServiceListener sl2 = new ServiceListener()
        {
            public void serviceChanged(ServiceEvent arg0)
            {
                fired.add(this);
            }
        };
        ed.addListener(b2.getBundleContext(), ServiceListener.class, sl2, null);

        ServiceListener sl3 = new ServiceListener()
        {
            public void serviceChanged(ServiceEvent arg0)
            {
                fired.add(this);
            }
View Full Code Here

        this.server = server;
        svcs = new Vector();
        svcs.add(ConfigurationAdmin.class.getName());
        svcs.add(UserAdmin.class.getName());
        svcs.add(LogService.class.getName());
        sl = new ServiceListener() {
            public void serviceChanged(ServiceEvent event) {
                processServiceEvent(event);
            }
        };
    }
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.