Class RegionConfigurationSupport


  • public abstract class RegionConfigurationSupport
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Long bundleId  
      private org.osgi.framework.BundleContext caBundleContext  
      private org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> caReference  
      private ScrLogger logger  
      private org.osgi.framework.ServiceRegistration<org.osgi.service.cm.ConfigurationListener> m_registration  
      private java.util.concurrent.atomic.AtomicInteger referenceCount  
    • Constructor Summary

      Constructors 
      Constructor Description
      RegionConfigurationSupport​(ScrLogger logger, org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> reference, org.osgi.framework.Bundle bundle)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean checkBundleLocation​(java.lang.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 from configurationEvent(ConfigurationEvent) in the case of a deleted configuration which is not a factory configuration!
      boolean dereference()  
      (package private) static java.lang.String escape​(java.lang.String value)
      see core spec 3.2.7.
      private java.lang.String filter​(java.lang.String rawPid)  
      private org.osgi.service.cm.Configuration[] findConfigurations​(org.osgi.service.cm.ConfigurationAdmin ca, java.lang.String filter)  
      private java.util.Collection<org.osgi.service.cm.Configuration> findFactoryConfigurations​(org.osgi.service.cm.ConfigurationAdmin ca, java.lang.String factoryPid, org.osgi.framework.Bundle bundle)
      Returns all configurations whose factory PID equals the given factory PID or null if no such configurations exist
      org.osgi.service.cm.Configuration findSingletonConfiguration​(org.osgi.service.cm.ConfigurationAdmin ca, java.lang.String pid, org.osgi.framework.Bundle bundle)
      Returns the configuration whose PID equals the given pid.
      java.lang.Long getBundleId()  
      protected abstract java.util.Collection<ComponentHolder<?>> getComponentHolders​(TargetedPID pid)  
      private org.osgi.service.cm.ConfigurationAdmin getConfigAdmin​(org.osgi.framework.BundleContext bundleContext)  
      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.
      private java.lang.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 java.lang.String getTargetedPidFilter​(java.lang.String pid, org.osgi.framework.Bundle bundle, java.lang.String key)  
      boolean reference()  
      void start()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • caReference

        private final org.osgi.framework.ServiceReference<org.osgi.service.cm.ConfigurationAdmin> caReference
      • caBundleContext

        private final org.osgi.framework.BundleContext caBundleContext
      • bundleId

        private final java.lang.Long bundleId
      • referenceCount

        private final java.util.concurrent.atomic.AtomicInteger referenceCount
      • m_registration

        private volatile org.osgi.framework.ServiceRegistration<org.osgi.service.cm.ConfigurationListener> m_registration
    • Constructor Detail

      • 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 tracking
        registry -
    • Method Detail

      • start

        public void start()
      • getBundleId

        public java.lang.Long getBundleId()
      • reference

        public boolean reference()
      • dereference

        public boolean dereference()
      • configureComponentHolder

        public boolean configureComponentHolder​(ComponentHolder<?> holder)
        The return value is only relevant for the call from configurationEvent(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
      • getEventType

        private java.lang.String getEventType​(org.osgi.service.cm.ConfigurationEvent event)
      • 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 configuration
        targetedPid - the targeted factory pid for a factory configuration or the pid for a singleton configuration
        componentHolder - 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

        private java.lang.String filter​(java.lang.String rawPid)
      • findSingletonConfiguration

        public org.osgi.service.cm.Configuration findSingletonConfiguration​(org.osgi.service.cm.ConfigurationAdmin ca,
                                                                            java.lang.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 service
        pid - Pid for desired configuration
        bundle - bundle of the component we are configuring (used in targeted pids)
        Returns:
        configuration with the specified Pid
      • findFactoryConfigurations

        private java.util.Collection<org.osgi.service.cm.Configuration> findFactoryConfigurations​(org.osgi.service.cm.ConfigurationAdmin ca,
                                                                                                  java.lang.String factoryPid,
                                                                                                  org.osgi.framework.Bundle bundle)
        Returns all configurations whose factory PID equals the given factory PID or null if no such configurations exist
        Parameters:
        ca - ConfigurationAdmin service
        factoryPid - factory Pid we want the configurations for
        bundle - 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

        private boolean checkBundleLocation​(java.lang.String configBundleLocation,
                                            org.osgi.framework.Bundle bundle)
      • findConfigurations

        private org.osgi.service.cm.Configuration[] findConfigurations​(org.osgi.service.cm.ConfigurationAdmin ca,
                                                                       java.lang.String filter)
      • getTargetedPidFilter

        private java.lang.String getTargetedPidFilter​(java.lang.String pid,
                                                      org.osgi.framework.Bundle bundle,
                                                      java.lang.String key)
      • escape

        static final java.lang.String escape​(java.lang.String value)
        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)