Package org.apache.sling.feature
Class Extension
- java.lang.Object
-
- org.apache.sling.feature.Extension
-
public class Extension extends Object
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
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_NAME_ASSEMBLED_FEATURES
Extension name containing the assembled features as produced byFeatureBuilder.assemble(ArtifactId, BuilderContext, Feature...)
.static String
EXTENSION_NAME_CONTENT_PACKAGES
Common extension name to specify the content packages for Apache Sling.static String
EXTENSION_NAME_INTERNAL_DATA
Extension name containing internal data.static String
EXTENSION_NAME_REPOINIT
Common extension name to specify the repoinit part for Apache Sling.
-
Constructor Summary
Constructors Constructor Description Extension(ExtensionType t, String name, boolean required)
Deprecated.Extension(ExtensionType type, String name, ExtensionState state)
Create a new extension
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Extension
copy()
Create a copy of the Extensionboolean
equals(Object obj)
Artifacts
getArtifacts()
Get the artifacts of the extensionString
getJSON()
Get the JSON of the extensionjavax.json.JsonStructure
getJSONStructure()
Get the JSON structure of the extensionString
getName()
Get the extension nameExtensionState
getState()
Get the extension stateString
getText()
Get the text of the extensionExtensionType
getType()
Get the extension typeint
hashCode()
boolean
isOptional()
Deprecated.UsegetState()
boolean
isRequired()
Deprecated.UsegetState()
void
setJSON(String text)
Set the JSON of the extensionvoid
setJSONStructure(javax.json.JsonStructure struct)
Set the JSON structure of the extensionvoid
setText(String text)
Set the text of the extensionString
toString()
-
-
-
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.TEXT
and 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.ARTIFACTS
and 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.ARTIFACTS
and 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.JSON
and is optional.- Since:
- 1.7.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Extension
@Deprecated public Extension(ExtensionType t, String name, boolean required)
Deprecated.Create a new extension- Parameters:
t
- The type of the extensionname
- The name of the extensionrequired
- Whether the extension is required or optional- Throws:
IllegalArgumentException
- If name or t arenull
-
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
-
isRequired
@Deprecated public boolean isRequired()
Deprecated.UsegetState()
Return whether the extension is required or optional- Returns:
- Return
true
if the extension is required.
-
isOptional
@Deprecated public boolean isOptional()
Deprecated.UsegetState()
Return whether the extension is required or optional- Returns:
- Return
true
if the extension is optional.
-
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#JSON
IllegalArgumentException
- If the structure is not valid
-
getJSONStructure
public javax.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(javax.json.JsonStructure struct)
Set the JSON structure of the extension- Parameters:
struct
- The JSON structure- Throws:
IllegalStateException
- if the type is notExtensionType#JSON
IllegalArgumentException
- 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
-
-