Package org.osgi.framework

Examples of org.osgi.framework.ServiceEvent


      isDuringDestruction = true;
      if (wrapper != null) {
        ServiceReference ref = wrapper.getReference();
        if (ref != null) {
          // send unregistration event to the listener
          listener.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, ref));
        }
      }
      /** destruction process has ended */
      isDuringDestruction = false;
      // notify also any proxies that still wait on the service
View Full Code Here


              // so another candidate has to be searched from the existing candidates
              // - as they are alive already, we have to send an event for them ourselves
              // MODIFIED will be used for clarity
              if (newReference != null) {
                // update the listeners (through a MODIFIED event
                serviceChanged(new ServiceEvent(ServiceEvent.MODIFIED, newReference));
              }
            }

            // if no new reference was found and the service was indeed removed (it was bound to the interceptor)
            // then do an unbind
View Full Code Here

        ImportedOsgiServiceProxy serviceProxy = (ImportedOsgiServiceProxy) iterator.next();
        ServiceReference ref = serviceProxy.getServiceReference();

        // get first the destruction callback
        ProxyPlusCallback ppc = (ProxyPlusCallback) servicesIdMap.get((Long) ref.getProperty(Constants.SERVICE_ID));
        listener.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, ref));

        try {
          ppc.destructionCallback.destroy();
        }
        catch (Exception ex) {
View Full Code Here

            serviceRegistration = new ServiceRegistrationImpl(p, this);

            serviceEntries.put(serviceId, new ServiceEntry(serviceRegistration, bundleController, service));
        }

        framework.getBundleManager().fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, serviceRegistration.getReference()));

        LOGGER.exiting(CLASS_NAME, "registerService", serviceRegistration);

        return serviceRegistration;
    }
View Full Code Here

            if (entry == null) return;
        }

        ServiceRegistrationImpl serviceRegistration = entry.getRegistration();

        framework.getBundleManager().fireServiceEvent(new ServiceEvent(ServiceEvent.MODIFIED, serviceRegistration.getReference()));
    }
View Full Code Here

        try
        {
            Map<BundleController, BundleServiceReference> bundles = entry.getUsingBundles();
            ServiceRegistrationImpl serviceRegistration = entry.getRegistration();
            framework.getBundleManager().fireServiceEvent(new ServiceEvent(ServiceEvent.UNREGISTERING, serviceRegistration.getReference()));

            for (BundleController bundle : bundles.keySet())
            {
                BundleServiceReference bsr = bundles.get(bundle);
                Object service = bsr.getService();
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(reference.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(44));
        when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] {"org.apache.aries.jmx.Mock"});

        when(context.getAllServiceReferences(null, null)).thenReturn(new ServiceReference[] {reference});

        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

           
            if (transactionManager == null) {
           
                if (this.serviceListeners != null) {
                    for (ServiceListener listener :this.serviceListeners) {
                        listener.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING,TXN_SVC_REFERENCE));
                    }
                }
            }

            // test for properly calling ungetReference().
            assertEquals(0,this.txnRefCount);
            this.transactionManager = transactionManager;
           
            if (transactionManager != null) {
               
                if (this.serviceListeners != null) {
                    for (ServiceListener listener :this.serviceListeners) {
                        listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED,TXN_SVC_REFERENCE));
                    }
                }
            }
        }
View Full Code Here

    try {
      bundleContext.addServiceListener(sl, filter);
      ServiceReference[] srl = bundleContext.getServiceReferences(null, filter);
      if (srl != null) {
        for (ServiceReference sr : srl) {
          sl.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sr));
        }
      }
    } catch (InvalidSyntaxException e) {
      e.printStackTrace();
    }
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.