org.apache.felix.metatype.internal
Class ServiceMetaTypeInformation

java.lang.Object
  extended by org.apache.felix.metatype.internal.MetaTypeInformationImpl
      extended by org.apache.felix.metatype.internal.ServiceMetaTypeInformation
All Implemented Interfaces:
EventListener, ServiceListener, MetaTypeInformation, MetaTypeProvider

public class ServiceMetaTypeInformation
extends MetaTypeInformationImpl
implements ServiceListener

The ServiceMetaTypeInformation extends the MetaTypeInformationImpl adding support to register and unregister ManagedServices and ManagedServiceFactorys also implementing the MetaTypeProvider interface.

Author:
fmeschbe

Field Summary
 
Fields inherited from class org.apache.felix.metatype.internal.MetaTypeInformationImpl
SERVICE_FACTORYPID
 
Constructor Summary
ServiceMetaTypeInformation(BundleContext bundleContext, Bundle bundle)
          Creates an instance of this class handling services of the given bundle.
 
Method Summary
protected  void addService(ServiceReference serviceRef)
          Registers the service described by the serviceRef with this instance if the service is a MetaTypeProvider instance and either a service.factoryPid or service.pid property is set in the service registration properties.
protected  void removeService(ServiceReference serviceRef)
          Unregisters the service described by the serviceRef from this instance.
 void serviceChanged(ServiceEvent event)
          Handles service registration and unregistration events ignoring all services not belonging to the Bundle which is handled by this instance.
 
Methods inherited from class org.apache.felix.metatype.internal.MetaTypeInformationImpl
addFactoryPids, addMetaData, addMetaTypeProvider, addPids, getBundle, getFactoryPids, getLocales, getObjectClassDefinition, getPids, removeFactoryPid, removeMetaTypeProvider, removePid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceMetaTypeInformation

public ServiceMetaTypeInformation(BundleContext bundleContext,
                                  Bundle bundle)
Creates an instance of this class handling services of the given bundle.

Parameters:
bundleContext - The BundleContext used to get and unget services.
bundle - The Bundle whose services are handled by this class.
Method Detail

serviceChanged

public void serviceChanged(ServiceEvent event)
Handles service registration and unregistration events ignoring all services not belonging to the Bundle which is handled by this instance.

Specified by:
serviceChanged in interface ServiceListener
Parameters:
event - The ServiceEvent

addService

protected void addService(ServiceReference serviceRef)
Registers the service described by the serviceRef with this instance if the service is a MetaTypeProvider instance and either a service.factoryPid or service.pid property is set in the service registration properties.

If the service is registered, this bundle keeps a reference, which is ungot when the service is unregistered or this bundle is stopped.

Parameters:
serviceRef - The ServiceReference describing the service to be checked and handled.

removeService

protected void removeService(ServiceReference serviceRef)
Unregisters the service described by the serviceRef from this instance. Unregistration just checks for the service.factoryPid and service.pid service properties but does not care whether the service implements the MetaTypeProvider interface. If the service is registered it is simply unregistered.

If the service is actually unregistered the reference retrieved by the registration method is ungotten.

Parameters:
serviceRef - The ServiceReference describing the service to be unregistered.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.