Class ConfigurableComponentHolder<S>

java.lang.Object
org.apache.felix.scr.impl.manager.ConfigurableComponentHolder<S>
All Implemented Interfaces:
ComponentContainer<S>, ComponentHolder<S>

public abstract class ConfigurableComponentHolder<S> extends Object implements ComponentHolder<S>, ComponentContainer<S>
The ConfigurableComponentHolder class is a ComponentHolder for automatically configured components instances that may or may not be configured through Config Admin.

The holder copes with three situations:

  • No configuration is available for the held component. That is there is no configuration whose service.pid or service.factoryPid equals the component name.
  • A singleton configuration is available whose service.pid equals the component name.
  • One or more factory configurations exist whose service.factoryPid equals the component name.
  • Constructor Details

  • Method Details

    • createComponentMethods

      protected abstract ComponentMethods<S> createComponentMethods()
    • getComponentMethods

      protected ComponentMethods<S> getComponentMethods()
    • createComponentManager

      protected AbstractComponentManager<S> createComponentManager(boolean factoryConfiguration)
    • getActivator

      public final ComponentActivator getActivator()
      Description copied from interface: ComponentHolder
      Returns the ComponentActivator owning this component holder. (overlaps ComponentContaienr)
      Specified by:
      getActivator in interface ComponentContainer<S>
      Specified by:
      getActivator in interface ComponentHolder<S>
    • getComponentMetadata

      public final ComponentMetadata getComponentMetadata()
      Description copied from interface: ComponentHolder
      Returns the ComponentMetadata describing and declaring this component. (overlaps ComponentContaienr)
      Specified by:
      getComponentMetadata in interface ComponentContainer<S>
      Specified by:
      getComponentMetadata in interface ComponentHolder<S>
    • configurationDeleted

      public void configurationDeleted(TargetedPID pid, TargetedPID factoryPid)
      The configuration with the given pid (service.pid of the configuration object) is deleted.

      The following situations are supported:

      • The configuration was a singleton configuration (pid equals the component name). In this case the internal component map is empty and the single component has been configured by the singleton configuration and is no "deconfigured".
      • A factory configuration object has been deleted and the configured object is set as the single component. If the single component held the last factory configuration object, it is deconfigured. Otherwise the single component is disposed off and replaced by another component in the map of existing components.
      • A factory configuration object has been deleted and the configured object is not set as the single component. In this case the component is simply disposed off and removed from the internal map.
      Specified by:
      configurationDeleted in interface ComponentHolder<S>
      Parameters:
      pid - The PID of the deleted configuration
      factoryPid - The factory PID of the deleted configuration
    • configurationUpdated

      public boolean configurationUpdated(TargetedPID pid, TargetedPID factoryPid, Dictionary<String,Object> props, long changeCount)
      Configures a component with the given configuration. This configuration update may happen in various situations:
      • The pid equals the component name. Hence we have a singleton configuration for the single component held by this holder
      • The configuration is a factory configuration and is the first configuration provided. In this case the single component is provided with the configuration and also stored in the map.
      • The configuration is a factory configuration but not the first. In this case a new component is created, configured and stored in the map
      Specified by:
      configurationUpdated in interface ComponentHolder<S>
      Parameters:
      pid - Targeted PID for the configuration
      factoryPid - the (targeted) factory pid or null for a singleton pid
      props - the property dictionary from the configuration.
      changeCount - change count of the configuration, or R4 imitation.
      Returns:
      true if a new configuration was created, false otherwise. TODO there are now 3 states..... still not satisfied, existing, and new
    • copyTo

      protected static void copyTo(Map<String,Object> target, Dictionary<String,?> source)
    • getComponents

      public List<? extends ComponentManager<?>> getComponents()
      Description copied from interface: ComponentHolder
      Returns all Component instances held by this holder.
      Specified by:
      getComponents in interface ComponentHolder<S>
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: ComponentHolder
      whether the component is currently enabled
      Specified by:
      isEnabled in interface ComponentHolder<S>
      Returns:
      whether the component is enabled
    • enableComponents

      public org.osgi.util.promise.Promise<Void> enableComponents(boolean async)
      Description copied from interface: ComponentHolder
      Enables all components of this holder and if satisfied activates them.
      Specified by:
      enableComponents in interface ComponentHolder<S>
      Parameters:
      async - Whether the actual activation should take place asynchronously or not.
    • disableComponents

      public org.osgi.util.promise.Promise<Void> disableComponents(boolean async)
      Description copied from interface: ComponentHolder
      Disables all components of this holder.
      Specified by:
      disableComponents in interface ComponentHolder<S>
      Parameters:
      async - Whether the actual deactivation should take place asynchronously or not.
    • disposeComponents

      public void disposeComponents(int reason)
      Description copied from interface: ComponentHolder
      Disposes off all components of this holder.
      Specified by:
      disposeComponents in interface ComponentHolder<S>
      Parameters:
      reason -
    • disposed

      public void disposed(SingleComponentManager<S> component)
      Description copied from interface: ComponentContainer
      Informs the holder that the component has been disposed as a result of calling the dispose method.
      Specified by:
      disposed in interface ComponentContainer<S>
    • equals

      public boolean equals(Object object)
      Compares this ImmediateComponentHolder object to another object.

      A ImmediateComponentHolder is considered to be equal to another ImmediateComponentHolder if the component names are equal(using String.equals) and they have the same bundle activator

      Overrides:
      equals in class Object
      Parameters:
      object - The ImmediateComponentHolder object to be compared.
      Returns:
      true if object is a ImmediateComponentHolder and is equal to this object; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
      Returns:
      An integer which is a hash code value for this object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getLogger

      public ComponentLogger getLogger()
      Specified by:
      getLogger in interface ComponentContainer<S>
    • getConfigurationTargetedPID

      public TargetedPID getConfigurationTargetedPID(TargetedPID pid, TargetedPID factoryPid)
      Description copied from interface: ComponentHolder
      Returns the targeted PID used to configure this component
      Specified by:
      getConfigurationTargetedPID in interface ComponentHolder<S>
      Parameters:
      pid - a targetedPID containing the service pid for the component desired (the rest of the targeted pid is ignored)
      factoryPid - a targetedPID containing the factory pid for the component desired.
      Returns:
      the complete targeted pid actually used to configure the comonent.