Class AbstractComponentManager<S>

java.lang.Object
org.apache.felix.scr.impl.manager.AbstractComponentManager<S>
All Implemented Interfaces:
ComponentManager<S>
Direct Known Subclasses:
ComponentFactoryImpl, SingleComponentManager

public abstract class AbstractComponentManager<S> extends Object implements ComponentManager<S>
The default ComponentManager. Objects of this class are responsible for managing implementation object's lifecycle.
  • Field Details

  • Constructor Details

    • AbstractComponentManager

      protected AbstractComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods)
      The constructor receives both the container and the methods.
      Parameters:
      container - The component container
      componentMethods - The component methods
    • AbstractComponentManager

      protected AbstractComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods, boolean factoryInstance)
      The constructor receives both the container and the methods.
      Parameters:
      container - The component container
      componentMethods - The component methods
      factoryInstance - Flag whether this is a factory instance
  • Method Details

    • enable

      public final org.osgi.util.promise.Promise<Void> enable(boolean async)
    • disable

      public final org.osgi.util.promise.Promise<Void> disable(boolean async)
    • dispose

      public void dispose(int reason)
      Disposes off this component deactivating and disabling it first as required. After disposing off the component, it may not be used anymore.

      This method unlike the other state change methods immediately takes action and disposes the component. The reason for this is, that this method has to actually complete before other actions like bundle stopping may continue.

    • getId

      public long getId()
      Specified by:
      getId in interface ComponentManager<S>
    • getBundle

      public org.osgi.framework.Bundle getBundle()
      Returns the Bundle providing this component. If the component as already been disposed off, this method returns null.
    • isImmediate

      protected boolean isImmediate()
    • isFactory

      public boolean isFactory()
    • deleteComponent

      protected abstract void deleteComponent(int reason)
    • getProvidedServices

      protected String[] getProvidedServices()
    • registerService

      protected boolean registerService()
      Registers the service on behalf of the component.
    • unregisterService

      protected boolean unregisterService()
    • getServiceRegistration

      protected org.osgi.framework.ServiceRegistration<S> getServiceRegistration()
    • collectDependencies

      protected boolean collectDependencies(ComponentContextImpl<S> componentContext)
      Collect and store in m_dependencies_map all the services for dependencies, outside of any locks.
      Parameters:
      componentContext - possible instance key for prototype scope references
      Returns:
      true if all references can be collected, false if some dependency is no longer available.
    • getActivator

      public ComponentActivator getActivator()
    • getLogger

      public ComponentLogger getLogger()
    • toString

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

      protected boolean verifyDependencyManagers()
    • getReferenceManagers

      public List<? extends ReferenceManager<S,?>> getReferenceManagers()
      Specified by:
      getReferenceManagers in interface ComponentManager<S>
    • getProperties

      public abstract Map<String,Object> getProperties()
      Specified by:
      getProperties in interface ComponentManager<S>
    • setServiceProperties

      public abstract void setServiceProperties(Dictionary<String,?> serviceProperties)
    • getServiceProperties

      public Dictionary<String,Object> getServiceProperties()
      Returns the subset of component properties to be used as service properties. These properties are all component properties where property name does not start with dot (.), properties which are considered private.
    • copyTo

      protected static Dictionary<String,Object> copyTo(Dictionary<String,Object> target, Map<String,?> source, boolean allProps)
      Copies the properties from the source Dictionary into the target Dictionary except for private properties (whose name has a leading dot) which are only copied if the allProps parameter is true.
      Parameters:
      target - The Dictionary into which to copy the properties. If null a new Hashtable is created.
      source - The Dictionary providing the properties to copy. If null or empty, nothing is copied.
      allProps - Whether all properties (true) or only the public properties (false) are to be copied.
      Returns:
      The target is returned, which may be empty if source is null or empty and target was null or all properties are private and had not to be copied
    • copyToMap

      protected static Map<String,Object> copyToMap(Dictionary<String,?> source, boolean allProps)
      Copies the properties from the source Dictionary into the target Dictionary except for private properties (whose name has a leading dot) which are only copied if the allProps parameter is true.
      Parameters:
      source - The Dictionary providing the properties to copy. If null or empty, nothing is copied.
      allProps - Whether all properties (true) or only the public properties (false) are to be copied.
      Returns:
      The target is returned, which may be empty if source is null or empty and target was null or all properties are private and had not to be copied
    • copyToDictionary

      protected static Dictionary<String,Object> copyToDictionary(Dictionary<String,?> source, boolean allProps)
    • getComponentMetadata

      public ComponentMetadata getComponentMetadata()
    • getSpecState

      public int getSpecState()
      Specified by:
      getSpecState in interface ComponentManager<S>
    • getFailureReason

      public String getFailureReason()
      Specified by:
      getFailureReason in interface ComponentManager<S>
    • setFailureReason

      public void setFailureReason(Throwable e)
      Set the activation failure reason
      Parameters:
      e - The exception which caused the activation to fail
    • setServiceProperties

      public void setServiceProperties(MethodResult methodResult, Integer trackingCount)
    • reconfigure

      public abstract void reconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
    • getComponentManagers

      public abstract void getComponentManagers(List<AbstractComponentManager<S>> cms)
    • getRegisteredServiceReference

      public final org.osgi.framework.ServiceReference<S> getRegisteredServiceReference()
      Specified by:
      getRegisteredServiceReference in interface ComponentManager<S>