Package org.apache.sling.feature
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
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIGURATOR_PREFIX
Prefix for instructions for the configurator.static String
PROP_ARTIFACT_ID
This optional configuration property stores the artifact id (mvn id) of the bundle this configuration belongs to.static String
PROP_FEATURE_ORIGINS
This optional configuration property stores the artifact ids (array) of the features this configuration has been specified.static String
PROP_PREFIX
Prefix for special properties which are not configuration properties.
-
Constructor Summary
Constructors Constructor Description Configuration(String pid)
Create a new configuration
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Configuration o)
Configuration
copy(String aPid)
Create a copy of the configuration with a provided PID.Dictionary<String,Object>
getConfigurationProperties()
Get the configuration properties of the configuration.String
getFactoryPid()
Return the factory pid of a pid if it's a factory configurationstatic String
getFactoryPid(String pid)
Return the factory pid of a pid if it's a factory configurationList<ArtifactId>
getFeatureOrigins()
Get the feature origins - if recordedList<ArtifactId>
getFeatureOrigins(String propertyName)
Get the feature origins for a property - if recordedList<ArtifactId>
getFeatureOrigins(String propertyName, ArtifactId self)
Get the feature origins for a property.List<ArtifactId>
getFeatureOrigins(ArtifactId self)
Get the feature origins.String
getName()
Return the name for a factory configuration if it is a factory configuration.static String
getName(String pid)
Return the name for a factory configuration if it is a factory configuration.String
getPid()
Get the pid.Dictionary<String,Object>
getProperties()
Get all properties of the configuration.boolean
isFactoryConfiguration()
Check whether the pid is a factory pidstatic boolean
isFactoryConfiguration(String pid)
Check whether the pid is a factory pidvoid
setFeatureOrigins(String propertyName, List<ArtifactId> featureOrigins)
Set the feature origins for a propertyvoid
setFeatureOrigins(List<ArtifactId> featureOrigins)
Set the feature originsString
toString()
-
-
-
Field Detail
-
CONFIGURATOR_PREFIX
public static final String CONFIGURATOR_PREFIX
Prefix for instructions for the configurator.- See Also:
- Constant Field Values
-
PROP_PREFIX
public static final String PROP_PREFIX
Prefix for special properties which are not configuration properties.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
-
Constructor Detail
-
Configuration
public Configuration(String pid)
Create a new configuration- Parameters:
pid
- The pid- Throws:
IllegalArgumentException
- If pid isnull
-
-
Method Detail
-
compareTo
public int compareTo(Configuration o)
- Specified by:
compareTo
in interfaceComparable<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:
isFactoryConfiguration()
-
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()
-
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:
isFactoryConfiguration(String)
-
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:
isFactoryConfiguration(String)
-
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 propertyself
- 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 propertyfeatureOrigins
- 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
-
-