Class Configuration

java.lang.Object
org.apache.sling.feature.Configuration
All Implemented Interfaces:
Serializable, Comparable<Configuration>

public class Configuration extends Object implements Comparable<Configuration>, Serializable
A configuration has either
  • a pid
  • or a factory pid and a name
and properties. This class is not thread-safe.
See Also:
  • Field Details

    • CONFIGURATOR_PREFIX

      public static final String CONFIGURATOR_PREFIX
      Prefix for instructions for the configurator.
      See Also:
    • PROP_PREFIX

      public static final String PROP_PREFIX
      Prefix for special properties which are not configuration properties.
      See Also:
    • PROP_ARTIFACT_ID

      public static final String PROP_ARTIFACT_ID
      This optional configuration property stores the artifact id (mvn id) of the bundle this configuration belongs to.
      See Also:
    • PROP_FEATURE_ORIGINS

      public static final String PROP_FEATURE_ORIGINS
      This optional configuration property stores the artifact ids (array) of the features this configuration has been specified.
      Since:
      1.6
      See Also:
  • Constructor Details

    • Configuration

      public Configuration(String pid)
      Create a new configuration
      Parameters:
      pid - The pid
      Throws:
      IllegalArgumentException - If pid is null
  • Method Details

    • compareTo

      public int compareTo(Configuration o)
      Specified by:
      compareTo in interface Comparable<Configuration>
    • getPid

      public String getPid()
      Get the pid.
      Returns:
      The pid
    • isFactoryConfiguration

      public boolean isFactoryConfiguration()
      Check whether the pid is a factory pid
      Returns:
      true if it's a factory pid
      Since:
      1.3
    • getFactoryPid

      public String getFactoryPid()
      Return the factory pid of a pid if it's a factory configuration
      Returns:
      The factory pid or null.
      Since:
      1.3
      See Also:
    • getName

      public String getName()
      Return the name for a factory configuration if it is a factory configuration.
      Returns:
      The name or null.
      Since:
      1.3
      See Also:
    • isFactoryConfiguration

      public static boolean isFactoryConfiguration(String pid)
      Check whether the pid is a factory pid
      Parameters:
      pid - The pid
      Returns:
      true if it's a factory pid
    • getFactoryPid

      public static String getFactoryPid(String pid)
      Return the factory pid of a pid if it's a factory configuration
      Parameters:
      pid - The pid
      Returns:
      The factory pid or null.
      See Also:
    • getName

      public static String getName(String pid)
      Return the name for a factory configuration if it is a factory configuration.
      Parameters:
      pid - The pid
      Returns:
      The name or null.
      See Also:
    • getProperties

      public Dictionary<String,Object> getProperties()
      Get all properties of the configuration. This method returns a mutable dictionary which can be mutated to alter the properties for this configuration.
      Returns:
      The properties
    • getFeatureOrigins

      public List<ArtifactId> getFeatureOrigins()
      Get the feature origins - if recorded
      Returns:
      A immutable list of feature artifact ids - list might be empty
      Throws:
      IllegalArgumentException - If the stored values are not valid artifact ids
      Since:
      1.6
    • getFeatureOrigins

      public List<ArtifactId> getFeatureOrigins(ArtifactId self)
      Get the feature origins. If no origins are recorded, the provided id is returned.
      Parameters:
      self - The id of the current feature
      Returns:
      A immutable list of feature artifact ids
      Throws:
      IllegalArgumentException - If the stored values are not valid artifact ids
      Since:
      1.7
    • setFeatureOrigins

      public void setFeatureOrigins(List<ArtifactId> featureOrigins)
      Set the feature origins
      Parameters:
      featureOrigins - the list of artifact ids or null to remove the info from this object
      Since:
      1.6
    • getFeatureOrigins

      public List<ArtifactId> getFeatureOrigins(String propertyName)
      Get the feature origins for a property - if recorded
      Parameters:
      propertyName - The name of the property
      Returns:
      A immutable list of feature artifact ids - list might be empty
      Throws:
      IllegalArgumentException - If the stored values are not valid artifact ids
      Since:
      1.8
    • getFeatureOrigins

      public List<ArtifactId> getFeatureOrigins(String propertyName, ArtifactId self)
      Get the feature origins for a property. If no origins are recorded, the provided id is returned.
      Parameters:
      propertyName - The name of the property
      self - The id of the current feature
      Returns:
      A immutable list of feature artifact ids
      Throws:
      IllegalArgumentException - If the stored values are not valid artifact ids
      Since:
      1.8
    • setFeatureOrigins

      public void setFeatureOrigins(String propertyName, List<ArtifactId> featureOrigins)
      Set the feature origins for a property
      Parameters:
      propertyName - The name of the property
      featureOrigins - the list of artifact ids or null to remove the info from this object
      Since:
      1.8
    • getConfigurationProperties

      public Dictionary<String,Object> getConfigurationProperties()
      Get the configuration properties of the configuration. This configuration properties are all properties minus properties used to manage the configuration. Managing properties have to start with #CONFIGURATOR_PREFIX. The returned copy is a mutable dictionary which represents a snapshot of the properties at the time this method is called.
      Returns:
      The configuration properties
    • copy

      public Configuration copy(String aPid)
      Create a copy of the configuration with a provided PID.
      Parameters:
      aPid - The pid of the configuration
      Returns:
      A copy of this configuration with the given PID
    • toString

      public String toString()
      Overrides:
      toString in class Object