Package org.apache.felix.cm.impl.helper
Class BaseTracker<S>
java.lang.Object
org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
org.apache.felix.cm.impl.helper.BaseTracker<S>
- All Implemented Interfaces:
org.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>>
- Direct Known Subclasses:
ManagedServiceFactoryTracker,ManagedServiceTracker
public abstract class BaseTracker<S>
extends org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
The
BaseTracker is the base class for tracking
ManagedService and ManagedServiceFactory
services. It maps their ServiceRegistration to the
ConfigurationMap mapping their service PIDs to provided
configuration.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsFields inherited from class org.osgi.util.tracker.ServiceTracker
context, filter -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseTracker(ConfigurationManager cm, boolean managedServiceFactory) -
Method Summary
Modifier and TypeMethodDescriptionaddingService(org.osgi.framework.ServiceReference<S> reference) private voidconfigure(org.osgi.framework.ServiceReference<S> reference, String[] pids, ConfigurationMap<?> configurations) protected abstract ConfigurationMap<?> createConfigurationMap(String[] pids) static AccessControlContextgetAccessControlContext(org.osgi.framework.Bundle bundle) protected final Dictionary<String, Object> getProperties(Dictionary<String, ?> rawProperties, org.osgi.framework.ServiceReference<?> service, String configPid, String factoryPid) protected final SgetRealService(org.osgi.framework.ServiceReference<S> reference) private static String[]getServicePid(org.osgi.framework.ServiceReference reference) Returns theservice.pidproperty of the service reference as an array of strings ornullif the service reference does not have a service PID property.abstract StringgetServicePid(org.osgi.framework.ServiceReference<S> service, TargetedPID pid) Returns the String to be used as the PID of the service PID for thepidretrieved from the configuration.getServices(TargetedPID pid) protected final voidhandleCallBackError(Throwable error, org.osgi.framework.ServiceReference target, TargetedPID pid) voidmodifiedService(org.osgi.framework.ServiceReference<S> reference, ConfigurationMap<?> service) abstract voidprovideConfiguration(org.osgi.framework.ServiceReference<S> service, TargetedPID configPid, TargetedPID factoryPid, Dictionary<String, ?> properties, long revision, ConfigurationMap<?> configurationMap) Updates the given service with the provided configuration.abstract voidremoveConfiguration(org.osgi.framework.ServiceReference<S> service, TargetedPID configPid, TargetedPID factoryPid) Remove the configuration indicated by theconfigPidfrom the service.voidremovedService(org.osgi.framework.ServiceReference<S> reference, ConfigurationMap<?> service) protected final voidungetRealService(org.osgi.framework.ServiceReference<S> reference) Methods inherited from class org.osgi.util.tracker.ServiceTracker
close, getService, getService, getServiceReference, getServiceReferences, getServices, getServices, getTracked, getTrackingCount, isEmpty, open, open, remove, size, waitForService
-
Field Details
-
cm
-
managedServiceFactory
private final boolean managedServiceFactory
-
-
Constructor Details
-
BaseTracker
-
-
Method Details
-
addingService
- Specified by:
addingServicein interfaceorg.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>> - Overrides:
addingServicein classorg.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
-
modifiedService
public void modifiedService(org.osgi.framework.ServiceReference<S> reference, ConfigurationMap<?> service) - Specified by:
modifiedServicein interfaceorg.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>> - Overrides:
modifiedServicein classorg.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
-
removedService
public void removedService(org.osgi.framework.ServiceReference<S> reference, ConfigurationMap<?> service) - Specified by:
removedServicein interfaceorg.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>> - Overrides:
removedServicein classorg.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
-
configure
private void configure(org.osgi.framework.ServiceReference<S> reference, String[] pids, ConfigurationMap<?> configurations) -
getServices
-
createConfigurationMap
-
getServicePid
public abstract String getServicePid(org.osgi.framework.ServiceReference<S> service, TargetedPID pid) Returns the String to be used as the PID of the service PID for thepidretrieved from the configuration.This method will return
TargetedPID.getServicePid()most of the time except if the service PID used for the consumer's service registration contains one or more pipe symbols (|). In this caseTargetedPID.getRawPid()might be returned.- Parameters:
service- The reference ot the service for which the service PID is to be returned.pid- TheTargetedPIDfor which to return the service PID.- Returns:
- The service PID or
nullif the service does not respond to the targeted PID at all.
-
provideConfiguration
public abstract void provideConfiguration(org.osgi.framework.ServiceReference<S> service, TargetedPID configPid, TargetedPID factoryPid, Dictionary<String, ?> properties, long revision, ConfigurationMap<?> configurationMap) Updates the given service with the provided configuration.See the implementations of this method for more information.
- Parameters:
service- The reference to the service to updateconfigPid- The targeted configuration PIDfactoryPid- The targeted factory PID ornullfor a non-factory configurationproperties- The configuration properties, which may benullif this is the provisioning call upon service registration of a ManagedServicerevision- The configuration revision or -1 if there is no configuration actually to provide.configurationMap- The PID to configuration map for PIDs used by the service to update- See Also:
-
removeConfiguration
public abstract void removeConfiguration(org.osgi.framework.ServiceReference<S> service, TargetedPID configPid, TargetedPID factoryPid) Remove the configuration indicated by theconfigPidfrom the service.- Parameters:
service- The reference to the service from which the configuration is to be removed.configPid- TheTargetedPIDof the configurationfactoryPid- Thefactory PIDof the configuration. This may benullfor a non-factory configuration.
-
getRealService
-
ungetRealService
-
getProperties
protected final Dictionary<String,Object> getProperties(Dictionary<String, ?> rawProperties, org.osgi.framework.ServiceReference<?> service, String configPid, String factoryPid) -
handleCallBackError
protected final void handleCallBackError(Throwable error, org.osgi.framework.ServiceReference target, TargetedPID pid) -
getServicePid
Returns theservice.pidproperty of the service reference as an array of strings ornullif the service reference does not have a service PID property.The service.pid property may be a single string, in which case a single element array is returned. If the property is an array of string, this array is returned. If the property is a collection it is assumed to be a collection of strings and the collection is converted to an array to be returned. Otherwise (also if the property is not set)
nullis returned.- Throws:
NullPointerException- if reference isnullArrayStoreException- if the service pid is a collection and not all elements are strings.
-
getAccessControlContext
-