Package org.apache.sling.feature
Class Extension
- java.lang.Object
-
- org.apache.sling.feature.Extension
-
- All Implemented Interfaces:
Serializable
public class Extension extends Object implements Serializable
An Extension can either be of type- Artifacts : it contains a list of artifacts
- Text : it contains text
- JSON : it contains a blob of JSON
An extension can be in one of these states
- Required : Required extensions need to be processed by tooling
- Optional : Optional extensions might be processed by tooling, for example they might contain environment specific parts
- Transient: Transient extensions are cache like extensions where tooling can store additional information to avoid reprocessing of down stream tooling. However such tooling must work without the transient extension being available.
This class is not thread-safe.
- See Also:
ExtensionType, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXTENSION_NAME_ASSEMBLED_FEATURESExtension name containing the assembled features as produced byFeatureBuilder.assemble(ArtifactId, BuilderContext, Feature...).static StringEXTENSION_NAME_CONTENT_PACKAGESCommon extension name to specify the content packages for Apache Sling.static StringEXTENSION_NAME_INTERNAL_DATAExtension name containing internal data.static StringEXTENSION_NAME_REPOINITCommon extension name to specify the repoinit part for Apache Sling.
-
Constructor Summary
Constructors Constructor Description Extension(ExtensionType type, String name, ExtensionState state)Create a new extension
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Extensioncopy()Create a copy of the Extensionbooleanequals(Object obj)ArtifactsgetArtifacts()Get the artifacts of the extensionStringgetJSON()Get the JSON of the extensionjakarta.json.JsonStructuregetJSONStructure()Get the JSON structure of the extensionStringgetName()Get the extension nameExtensionStategetState()Get the extension stateStringgetText()Get the text of the extensionExtensionTypegetType()Get the extension typeinthashCode()voidsetJSON(String text)Set the JSON of the extensionvoidsetJSONStructure(jakarta.json.JsonStructure struct)Set the JSON structure of the extensionvoidsetText(String text)Set the text of the extensionStringtoString()
-
-
-
Field Detail
-
EXTENSION_NAME_REPOINIT
public static final String EXTENSION_NAME_REPOINIT
Common extension name to specify the repoinit part for Apache Sling. This extension is of typeExtensionType.TEXTand is required.- See Also:
- Constant Field Values
-
EXTENSION_NAME_CONTENT_PACKAGES
public static final String EXTENSION_NAME_CONTENT_PACKAGES
Common extension name to specify the content packages for Apache Sling. This extension is of typeExtensionType.ARTIFACTSand is required.- See Also:
- Constant Field Values
-
EXTENSION_NAME_ASSEMBLED_FEATURES
public static final String EXTENSION_NAME_ASSEMBLED_FEATURES
Extension name containing the assembled features as produced byFeatureBuilder.assemble(ArtifactId, BuilderContext, Feature...). This extension is of typeExtensionType.ARTIFACTSand is optional.- See Also:
- Constant Field Values
-
EXTENSION_NAME_INTERNAL_DATA
public static final String EXTENSION_NAME_INTERNAL_DATA
Extension name containing internal data. An extension with this name must not be created by hand, it is managed by the feature model implementation. This extension is of typeExtensionType.JSONand is optional.- Since:
- 1.7.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Extension
public Extension(ExtensionType type, String name, ExtensionState state)
Create a new extension- Parameters:
type- The type of the extensionname- The name of the extensionstate- The state of the extension- Throws:
IllegalArgumentException- If name, type or state isnull- Since:
- 1.1
-
-
Method Detail
-
getType
public ExtensionType getType()
Get the extension type- Returns:
- The type
-
getState
public ExtensionState getState()
Get the extension state- Returns:
- The state
- Since:
- 1.1
-
getName
public String getName()
Get the extension name- Returns:
- The name
-
getText
public String getText()
Get the text of the extension- Returns:
- The text
- Throws:
IllegalStateException- if the type is notExtensionType#TEXT
-
setText
public void setText(String text)
Set the text of the extension- Parameters:
text- The text- Throws:
IllegalStateException- if the type is notExtensionType#TEXT
-
getJSON
public String getJSON()
Get the JSON of the extension- Returns:
- The JSON or
null - Throws:
IllegalStateException- if the type is notExtensionType#JSON
-
setJSON
public void setJSON(String text)
Set the JSON of the extension- Parameters:
text- The JSON- Throws:
IllegalStateException- if the type is notExtensionType#JSONIllegalArgumentException- If the structure is not valid
-
getJSONStructure
public jakarta.json.JsonStructure getJSONStructure()
Get the JSON structure of the extension- Returns:
- The JSON object or
null - Throws:
IllegalStateException- if the type is notExtensionType#JSON- Since:
- 1.1
-
setJSONStructure
public void setJSONStructure(jakarta.json.JsonStructure struct)
Set the JSON structure of the extension- Parameters:
struct- The JSON structure- Throws:
IllegalStateException- if the type is notExtensionType#JSONIllegalArgumentException- If the structure is not valid- Since:
- 1.1
-
getArtifacts
public Artifacts getArtifacts()
Get the artifacts of the extension- Returns:
- The artifacts
- Throws:
IllegalStateException- if the type is notExtensionType#ARTIFACTS
-
copy
public Extension copy()
Create a copy of the Extension- Returns:
- A copy of the Extension
-
-