Class RegionConfigurationSupport
java.lang.Object
org.apache.felix.scr.impl.manager.RegionConfigurationSupport
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Long
private final org.osgi.framework.BundleContext
private final org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin>
private final ScrLogger
private org.osgi.framework.ServiceRegistration<org.osgi.service.cm.ConfigurationListener>
private final AtomicInteger
-
Constructor Summary
ConstructorsConstructorDescriptionRegionConfigurationSupport
(ScrLogger logger, org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> reference, org.osgi.framework.Bundle bundle) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
checkBundleLocation
(String configBundleLocation, org.osgi.framework.Bundle bundle) private boolean
checkBundleLocation
(org.osgi.service.cm.Configuration config, org.osgi.framework.Bundle bundle) void
configurationEvent
(org.osgi.service.cm.ConfigurationEvent event) Called by the Configuration Admin service if a configuration is updated or removed.boolean
configureComponentHolder
(ComponentHolder<?> holder) The return value is only relevant for the call fromconfigurationEvent(ConfigurationEvent)
in the case of a deleted configuration which is not a factory configuration!boolean
(package private) static final String
see core spec 3.2.7.private String
private org.osgi.service.cm.Configuration[]
findConfigurations
(org.osgi.service.cm.ConfigurationAdmin ca, String filter) private Collection<org.osgi.service.cm.Configuration>
findFactoryConfigurations
(org.osgi.service.cm.ConfigurationAdmin ca, String factoryPid, org.osgi.framework.Bundle bundle) Returns all configurations whose factory PID equals the given factory PID ornull
if no such configurations existorg.osgi.service.cm.Configuration
findSingletonConfiguration
(org.osgi.service.cm.ConfigurationAdmin ca, String pid, org.osgi.framework.Bundle bundle) Returns the configuration whose PID equals the given pid.protected abstract Collection<ComponentHolder<?>>
private org.osgi.service.cm.ConfigurationAdmin
getConfigAdmin
(org.osgi.framework.BundleContext bundleContext) getConfigurationInfo
(TargetedPID pid, TargetedPID targetedPid, ComponentHolder<?> componentHolder, org.osgi.framework.BundleContext bundleContext) This gets config admin, gets the requested configuration, extracts the info we need from it, and ungets config admin.private String
getEventType
(org.osgi.service.cm.ConfigurationEvent event) private org.osgi.framework.ServiceReference<org.osgi.service.cm.ManagedService>
getManagedServiceReference
(org.osgi.framework.BundleContext bundleContext) private String
getTargetedPidFilter
(String pid, org.osgi.framework.Bundle bundle, String key) boolean
void
start()
-
Field Details
-
logger
-
caReference
private final org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> caReference -
caBundleContext
private final org.osgi.framework.BundleContext caBundleContext -
bundleId
-
referenceCount
-
m_registration
private volatile org.osgi.framework.ServiceRegistration<org.osgi.service.cm.ConfigurationListener> m_registration
-
-
Constructor Details
-
RegionConfigurationSupport
public RegionConfigurationSupport(ScrLogger logger, org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> reference, org.osgi.framework.Bundle bundle) - Parameters:
bundleContext
- of the ConfigurationAdmin we are trackingregistry
-
-
-
Method Details
-
start
public void start() -
getBundleId
-
reference
public boolean reference() -
dereference
public boolean dereference() -
configureComponentHolder
The return value is only relevant for the call fromconfigurationEvent(ConfigurationEvent)
in the case of a deleted configuration which is not a factory configuration! -
configurationEvent
public void configurationEvent(org.osgi.service.cm.ConfigurationEvent event) Called by the Configuration Admin service if a configuration is updated or removed.This method is really only called upon configuration changes; it is not called for existing configurations upon startup of the Configuration Admin service. To bridge this gap, the
ComponentRegistry#serviceChanged(org.osgi.framework.ServiceEvent)
method called when the Configuration Admin service is registered calls #configureComponentHolders which calls this method for all existing configurations to be able to forward existing configurations to components.- Parameters:
event
- The configuration change event
-
getComponentHolders
-
getEventType
-
getConfigurationInfo
private RegionConfigurationSupport.ConfigurationInfo getConfigurationInfo(TargetedPID pid, TargetedPID targetedPid, ComponentHolder<?> componentHolder, org.osgi.framework.BundleContext bundleContext) This gets config admin, gets the requested configuration, extracts the info we need from it, and ungets config admin. Some versions of felix config admin do not allow access to configurations after the config admin instance they were obtained from are ungot. Extracting the info we need into "configInfo" solves this problem.- Parameters:
pid
- TargetedPID for the desired configurationtargetedPid
- the targeted factory pid for a factory configuration or the pid for a singleton configurationcomponentHolder
- ComponentHolder that holds the old change count (for r4 fake change counting)bundleContext
- BundleContext to get the CA from- Returns:
- ConfigurationInfo object containing the info we need from the configuration.
-
getManagedServiceReference
private org.osgi.framework.ServiceReference<org.osgi.service.cm.ManagedService> getManagedServiceReference(org.osgi.framework.BundleContext bundleContext) -
filter
-
findSingletonConfiguration
public org.osgi.service.cm.Configuration findSingletonConfiguration(org.osgi.service.cm.ConfigurationAdmin ca, String pid, org.osgi.framework.Bundle bundle) Returns the configuration whose PID equals the given pid. If no such configuration exists,null
is returned.- Parameters:
ca
- Configuration Admin servicepid
- Pid for desired configurationbundle
- bundle of the component we are configuring (used in targeted pids)- Returns:
- configuration with the specified Pid
-
findFactoryConfigurations
private Collection<org.osgi.service.cm.Configuration> findFactoryConfigurations(org.osgi.service.cm.ConfigurationAdmin ca, String factoryPid, org.osgi.framework.Bundle bundle) Returns all configurations whose factory PID equals the given factory PID ornull
if no such configurations exist- Parameters:
ca
- ConfigurationAdmin servicefactoryPid
- factory Pid we want the configurations forbundle
- bundle we're working for (for location and location permission)- Returns:
- the configurations specifying the supplied factory Pid.
-
checkBundleLocation
private boolean checkBundleLocation(org.osgi.service.cm.Configuration config, org.osgi.framework.Bundle bundle) -
checkBundleLocation
-
findConfigurations
private org.osgi.service.cm.Configuration[] findConfigurations(org.osgi.service.cm.ConfigurationAdmin ca, String filter) -
getTargetedPidFilter
-
escape
see core spec 3.2.7. Escape \*() with preceding \- Parameters:
value
-- Returns:
- escaped string
-
getConfigAdmin
private org.osgi.service.cm.ConfigurationAdmin getConfigAdmin(org.osgi.framework.BundleContext bundleContext)
-