Package org.xwiki.extension
Class AbstractExtension
- java.lang.Object
-
- org.xwiki.extension.AbstractExtension
-
- All Implemented Interfaces:
Comparable<Extension>
,Extension
,MutableExtension
- Direct Known Subclasses:
AbstractRemoteExtension
public abstract class AbstractExtension extends Object implements MutableExtension
Base class forExtension
implementations.- Since:
- 4.0M1
- Version:
- $Id: f5425f8baebf68b8d5a755b4fdb919ad349cb664 $
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>
allowedNamespaces
protected List<ExtensionAuthor>
authors
protected String
category
protected List<ExtensionComponent>
components
protected List<ExtensionDependency>
dependencies
protected String
description
protected Set<String>
features
Deprecated.since 8.0M1, usefeaturesMap
insteadprotected Map<String,ExtensionId>
featuresMap
protected ExtensionFile
file
The file of the extension.protected ExtensionId
id
protected ExtensionIssueManagement
issueManagement
protected List<ExtensionLicense>
licenses
protected List<ExtensionDependency>
managedDependencies
protected String
name
protected Map<String,Object>
properties
protected ReentrantLock
propertiesLock
Used to protect properties from concurrent write;protected List<ExtensionRepositoryDescriptor>
repositories
protected ExtensionRepository
repository
protected ExtensionScm
scm
protected String
summary
protected String
type
protected String
website
-
Fields inherited from interface org.xwiki.extension.Extension
FIELD_ALLOWEDNAMESPACE, FIELD_ALLOWEDNAMESPACES, FIELD_AUTHOR, FIELD_AUTHORS, FIELD_CATEGORY, FIELD_COMPONENT, FIELD_COMPONENTS, FIELD_DEPENDENCIES, FIELD_DESCRIPTION, FIELD_EXTENSIONFEATURE, FIELD_EXTENSIONFEATURES, FIELD_FEATURE, FIELD_FEATURES, FIELD_ID, FIELD_ISSUEMANAGEMENT, FIELD_LICENSE, FIELD_LICENSES, FIELD_MANAGEDDEPENDENCIES, FIELD_NAME, FIELD_NAMESPACES, FIELD_PROPERTIES, FIELD_REPOSITORIES, FIELD_REPOSITORY, FIELD_SCM, FIELD_SUMMARY, FIELD_TYPE, FIELD_VERSION, FIELD_WEBSITE, IKEYPREFIX
-
-
Constructor Summary
Constructors Constructor Description AbstractExtension(ExtensionRepository repository, Extension extension)
Create new extension descriptor by copying provided one.AbstractExtension(ExtensionRepository repository, ExtensionId id, String type)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAllowedNamespace(String namespace)
Add a new allowed namespace to the extension.void
addAuthor(ExtensionAuthor author)
Add a new author to the extension.void
addComponent(ExtensionComponent component)
Add a new component to the extension.void
addDependency(ExtensionDependency dependency)
Add a new dependency to the extension.void
addExtensionFeature(ExtensionId feature)
Add a new feature to the extension.void
addFeature(String feature)
Deprecated.void
addLicense(ExtensionLicense license)
Add a new license to the extension.void
addManagedDependency(ExtensionDependency managedDependency)
Add a new managed dependency to the extension.void
addRepository(ExtensionRepositoryDescriptor repository)
Add a new repository to the extension.int
compareTo(Extension o)
boolean
equals(Object obj)
<T> T
get(String fieldName)
Get an extension field by name.Collection<String>
getAllowedNamespaces()
List<ExtensionAuthor>
getAuthors()
String
getCategory()
List<ExtensionComponent>
getComponents()
List<ExtensionDependency>
getDependencies()
String
getDescription()
ExtensionId
getExtensionFeature(String featureId)
Return theExtensionId
object that matches the passed feature id.Collection<ExtensionId>
getExtensionFeatures()
Indicate in an extension a list of provided "functionalities".Collection<String>
getFeatures()
Deprecated.ExtensionFile
getFile()
Access the associated extension file content.ExtensionId
getId()
ExtensionIssueManagement
getIssueManagement()
Collection<ExtensionLicense>
getLicenses()
List<ExtensionDependency>
getManagedDependencies()
Managed dependencies are used to override transitive dependencies (usually the version of this transitive dependency).String
getName()
Map<String,Object>
getProperties()
ExtendsExtension
standard properties.<T> T
getProperty(String key)
<T> T
getProperty(String key, T def)
Get a property.Collection<ExtensionRepositoryDescriptor>
getRepositories()
ExtensionRepository
getRepository()
ExtensionScm
getScm()
String
getSummary()
String
getType()
String
getWebSite()
int
hashCode()
void
putProperty(String key, Object value)
Set a property.<T> T
removeProperty(String key)
Remove the property associated to the passed key and return its value.void
set(Extension extension)
Update optional informations based on the provided extension.void
setAllowedNamespaces(Collection<String> namespaces)
void
setAuthors(Collection<? extends ExtensionAuthor> authors)
void
setCategory(String categrory)
void
setComponents(Collection<? extends ExtensionComponent> components)
void
setDependencies(Collection<? extends ExtensionDependency> dependencies)
void
setDescription(String description)
void
setExtensionFeatures(Collection<ExtensionId> features)
void
setFeatures(Collection<String> features)
Deprecated.protected void
setFile(ExtensionFile file)
protected void
setId(ExtensionId id)
void
setIssueManagement(ExtensionIssueManagement issueManagement)
void
setLicenses(Collection<ExtensionLicense> licenses)
void
setManagedDependencies(Collection<? extends ExtensionDependency> managedDependencies)
void
setName(String name)
void
setProperties(Map<String,Object> properties)
Replace existing properties with provided properties.void
setRepositories(Collection<? extends ExtensionRepositoryDescriptor> repositories)
protected void
setRepository(ExtensionRepository repository)
void
setScm(ExtensionScm scm)
void
setSummary(String summary)
protected void
setType(String type)
void
setWebsite(String website)
String
toString()
-
-
-
Field Detail
-
id
protected ExtensionId id
- See Also:
getId()
-
features
@Deprecated protected Set<String> features
Deprecated.since 8.0M1, usefeaturesMap
instead- See Also:
getExtensionFeatures()
-
featuresMap
protected Map<String,ExtensionId> featuresMap
- See Also:
getExtensionFeatures()
-
licenses
protected List<ExtensionLicense> licenses
- See Also:
getLicenses()
-
summary
protected String summary
- See Also:
getSummary()
-
description
protected String description
- See Also:
getDescription()
-
authors
protected List<ExtensionAuthor> authors
- See Also:
getAuthors()
-
components
protected List<ExtensionComponent> components
- See Also:
getComponents()
-
website
protected String website
- See Also:
getWebSite()
-
allowedNamespaces
protected Set<String> allowedNamespaces
- See Also:
getAllowedNamespaces()
-
repository
protected ExtensionRepository repository
- See Also:
getRepository()
-
properties
protected Map<String,Object> properties
- See Also:
getProperties()
-
propertiesLock
protected ReentrantLock propertiesLock
Used to protect properties from concurrent write;
-
dependencies
protected List<ExtensionDependency> dependencies
- See Also:
getDependencies()
-
managedDependencies
protected List<ExtensionDependency> managedDependencies
- Since:
- 8.1M1
- See Also:
getManagedDependencies()
-
scm
protected ExtensionScm scm
- See Also:
getScm()
-
issueManagement
protected ExtensionIssueManagement issueManagement
- See Also:
getIssueManagement()
-
category
protected String category
- See Also:
getCategory()
-
repositories
protected List<ExtensionRepositoryDescriptor> repositories
- See Also:
getRepositories()
-
file
protected ExtensionFile file
The file of the extension.
-
-
Constructor Detail
-
AbstractExtension
public AbstractExtension(ExtensionRepository repository, ExtensionId id, String type)
- Parameters:
repository
- the repository where this extension comes fromid
- the extension identifiertype
- the extension type
-
AbstractExtension
public AbstractExtension(ExtensionRepository repository, Extension extension)
Create new extension descriptor by copying provided one.- Parameters:
repository
- the repository where this extension comes fromextension
- the extension to copy
-
-
Method Detail
-
set
public void set(Extension extension)
Description copied from interface:MutableExtension
Update optional informations based on the provided extension.- Specified by:
set
in interfaceMutableExtension
- Parameters:
extension
- the extension from which to get informations
-
get
public <T> T get(String fieldName)
Get an extension field by name. Fallback on properties.
-
getId
public ExtensionId getId()
-
setId
protected void setId(ExtensionId id)
- Parameters:
id
- the extension id- See Also:
getId()
-
getFeatures
@Deprecated public Collection<String> getFeatures()
Deprecated.Description copied from interface:Extension
Indicate in an extension a list of provided "functionalities". Then when resolving extensions dependencies they can be matched in this list.- Specified by:
getFeatures
in interfaceExtension
- Returns:
- the extension ids also provided by this extension, an empty collection if there is none
-
setFeatures
@Deprecated public void setFeatures(Collection<String> features)
Deprecated.- Specified by:
setFeatures
in interfaceMutableExtension
- Parameters:
features
- the extension ids also provided by this extension
-
addFeature
@Deprecated public void addFeature(String feature)
Deprecated.Description copied from interface:MutableExtension
Add a new feature to the extension.- Specified by:
addFeature
in interfaceMutableExtension
- Parameters:
feature
- a feature name
-
getExtensionFeatures
public Collection<ExtensionId> getExtensionFeatures()
Description copied from interface:Extension
Indicate in an extension a list of provided "functionalities". Then when resolving extensions dependencies they can be matched in this list.- Specified by:
getExtensionFeatures
in interfaceExtension
- Returns:
- the
ExtensionId
s also provided by this extension, an empty collection if there is none
-
getExtensionFeature
public ExtensionId getExtensionFeature(String featureId)
Description copied from interface:Extension
Return theExtensionId
object that matches the passed feature id.- Specified by:
getExtensionFeature
in interfaceExtension
- Parameters:
featureId
- the id of the feature- Returns:
- the
ExtensionId
associated to the passed id
-
setExtensionFeatures
public void setExtensionFeatures(Collection<ExtensionId> features)
- Specified by:
setExtensionFeatures
in interfaceMutableExtension
- Parameters:
features
- theExtensionId
s also provided by this extension- Since:
- 8.0M1
-
addExtensionFeature
public void addExtensionFeature(ExtensionId feature)
Description copied from interface:MutableExtension
Add a new feature to the extension.- Specified by:
addExtensionFeature
in interfaceMutableExtension
- Parameters:
feature
- a feature name- Since:
- 8.0M1
-
getType
public String getType()
-
setType
protected void setType(String type)
- Parameters:
type
- the type of the extension- See Also:
getType()
-
getName
public String getName()
-
setName
public void setName(String name)
- Specified by:
setName
in interfaceMutableExtension
- Parameters:
name
- the display name of the extension
-
getLicenses
public Collection<ExtensionLicense> getLicenses()
- Specified by:
getLicenses
in interfaceExtension
- Returns:
- the license of the extension, an empty collection if there is none
-
setLicenses
public void setLicenses(Collection<ExtensionLicense> licenses)
- Specified by:
setLicenses
in interfaceMutableExtension
- Parameters:
licenses
- the licenses of the extension
-
addLicense
public void addLicense(ExtensionLicense license)
Description copied from interface:MutableExtension
Add a new license to the extension.- Specified by:
addLicense
in interfaceMutableExtension
- Parameters:
license
- a license
-
getSummary
public String getSummary()
- Specified by:
getSummary
in interfaceExtension
- Returns:
- a short description of the extension
-
setSummary
public void setSummary(String summary)
- Specified by:
setSummary
in interfaceMutableExtension
- Parameters:
summary
- a short description of the extension
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfaceExtension
- Returns:
- a description of the extension
-
setDescription
public void setDescription(String description)
- Specified by:
setDescription
in interfaceMutableExtension
- Parameters:
description
- a description of the extension
-
getAuthors
public List<ExtensionAuthor> getAuthors()
- Specified by:
getAuthors
in interfaceExtension
- Returns:
- the extension authors, an empty collection if there is none
-
setAuthors
public void setAuthors(Collection<? extends ExtensionAuthor> authors)
- Specified by:
setAuthors
in interfaceMutableExtension
- Parameters:
authors
- the authors of the extension
-
addAuthor
public void addAuthor(ExtensionAuthor author)
Description copied from interface:MutableExtension
Add a new author to the extension.- Specified by:
addAuthor
in interfaceMutableExtension
- Parameters:
author
- an author
-
getComponents
public List<ExtensionComponent> getComponents()
- Specified by:
getComponents
in interfaceExtension
- Returns:
- the XWiki components provided by the extension
-
setComponents
public void setComponents(Collection<? extends ExtensionComponent> components)
- Specified by:
setComponents
in interfaceMutableExtension
- Parameters:
components
- the components provided by the extension
-
addComponent
public void addComponent(ExtensionComponent component)
Description copied from interface:MutableExtension
Add a new component to the extension.- Specified by:
addComponent
in interfaceMutableExtension
- Parameters:
component
- a component provided by the extension
-
getWebSite
public String getWebSite()
- Specified by:
getWebSite
in interfaceExtension
- Returns:
- an URL for the extension website
-
setWebsite
public void setWebsite(String website)
- Specified by:
setWebsite
in interfaceMutableExtension
- Parameters:
website
- an URL for the extension website
-
getAllowedNamespaces
public Collection<String> getAllowedNamespaces()
- Specified by:
getAllowedNamespaces
in interfaceExtension
- Returns:
- the namespaces where it's allowed to install this extension
-
addAllowedNamespace
public void addAllowedNamespace(String namespace)
Description copied from interface:MutableExtension
Add a new allowed namespace to the extension.- Specified by:
addAllowedNamespace
in interfaceMutableExtension
- Parameters:
namespace
- a namespace- Since:
- 8.0M1
-
setAllowedNamespaces
public void setAllowedNamespaces(Collection<String> namespaces)
- Specified by:
setAllowedNamespaces
in interfaceMutableExtension
- Parameters:
namespaces
- the namespaces where it's allowed to install this extension- Since:
- 8.0M1
-
addDependency
public void addDependency(ExtensionDependency dependency)
Description copied from interface:MutableExtension
Add a new dependency to the extension.- Specified by:
addDependency
in interfaceMutableExtension
- Parameters:
dependency
- a dependency
-
getDependencies
public List<ExtensionDependency> getDependencies()
- Specified by:
getDependencies
in interfaceExtension
- Returns:
- the dependencies of the extension, an empty collection if there is none
-
setDependencies
public void setDependencies(Collection<? extends ExtensionDependency> dependencies)
- Specified by:
setDependencies
in interfaceMutableExtension
- Parameters:
dependencies
- the dependencies of the extension- See Also:
Extension.getDependencies()
-
addManagedDependency
public void addManagedDependency(ExtensionDependency managedDependency)
Description copied from interface:MutableExtension
Add a new managed dependency to the extension.- Specified by:
addManagedDependency
in interfaceMutableExtension
- Parameters:
managedDependency
- a managed dependency;- Since:
- 8.1M1
-
getManagedDependencies
public List<ExtensionDependency> getManagedDependencies()
Description copied from interface:Extension
Managed dependencies are used to override transitive dependencies (usually the version of this transitive dependency).- Specified by:
getManagedDependencies
in interfaceExtension
- Returns:
- the managed dependencies, empty list if there is none
-
setManagedDependencies
public void setManagedDependencies(Collection<? extends ExtensionDependency> managedDependencies)
- Specified by:
setManagedDependencies
in interfaceMutableExtension
- Parameters:
managedDependencies
- the managed dependencies of the extension- See Also:
Extension.getManagedDependencies()
-
getRepository
public ExtensionRepository getRepository()
- Specified by:
getRepository
in interfaceExtension
- Returns:
- the repository of the extension
-
setRepository
protected void setRepository(ExtensionRepository repository)
- Parameters:
repository
- the repository of the extension- See Also:
getRepository()
-
getScm
public ExtensionScm getScm()
-
setScm
public void setScm(ExtensionScm scm)
- Specified by:
setScm
in interfaceMutableExtension
- Parameters:
scm
- informations related to extensions's Source Control Management;- Since:
- 6.3M1
-
getIssueManagement
public ExtensionIssueManagement getIssueManagement()
- Specified by:
getIssueManagement
in interfaceExtension
- Returns:
- informations related to extension's issues management
-
setIssueManagement
public void setIssueManagement(ExtensionIssueManagement issueManagement)
- Specified by:
setIssueManagement
in interfaceMutableExtension
- Parameters:
issueManagement
- informations related to extension's issues management- Since:
- 6.3M1
-
getFile
public ExtensionFile getFile()
Description copied from interface:Extension
Access the associated extension file content.
-
setFile
protected void setFile(ExtensionFile file)
- Parameters:
file
- the file of the extension
-
getCategory
public String getCategory()
- Specified by:
getCategory
in interfaceExtension
- Returns:
- the category of the extension
-
setCategory
public void setCategory(String categrory)
- Specified by:
setCategory
in interfaceMutableExtension
- Parameters:
categrory
- the category of the extension;- Since:
- 7.0M2
-
getRepositories
public Collection<ExtensionRepositoryDescriptor> getRepositories()
- Specified by:
getRepositories
in interfaceExtension
- Returns:
- the custom repositories provided by the extension (usually to resolve dependencies)
-
setRepositories
public void setRepositories(Collection<? extends ExtensionRepositoryDescriptor> repositories)
- Specified by:
setRepositories
in interfaceMutableExtension
- Parameters:
repositories
- the custom repositories provided by the extension (usually to resolve dependencies)- Since:
- 7.3M1
-
addRepository
public void addRepository(ExtensionRepositoryDescriptor repository)
Description copied from interface:MutableExtension
Add a new repository to the extension.- Specified by:
addRepository
in interfaceMutableExtension
- Parameters:
repository
- a repository descriptor;- Since:
- 7.3M1
-
getProperties
public Map<String,Object> getProperties()
Description copied from interface:Extension
ExtendsExtension
standard properties.Theses are generally provided by specific repositories. For example a maven repository will provide group and artifacts ids.
- Specified by:
getProperties
in interfaceExtension
- Returns:
- the properties
-
getProperty
public <T> T getProperty(String key)
- Specified by:
getProperty
in interfaceExtension
- Type Parameters:
T
- type of the property value- Parameters:
key
- the property key- Returns:
- the property value
-
getProperty
public <T> T getProperty(String key, T def)
Description copied from interface:Extension
Get a property.- Specified by:
getProperty
in interfaceExtension
- Type Parameters:
T
- type of the property value- Parameters:
key
- the property keydef
- the value to return if no property is associated to the provided key- Returns:
- the property value or
default
of the property is not found - See Also:
Extension.getProperty(String)
-
putProperty
public void putProperty(String key, Object value)
Description copied from interface:MutableExtension
Set a property.- Specified by:
putProperty
in interfaceMutableExtension
- Parameters:
key
- the property keyvalue
- the property value- See Also:
Extension.getProperty(String)
-
setProperties
public void setProperties(Map<String,Object> properties)
Description copied from interface:MutableExtension
Replace existing properties with provided properties.- Specified by:
setProperties
in interfaceMutableExtension
- Parameters:
properties
- the properties
-
removeProperty
public <T> T removeProperty(String key)
Description copied from interface:MutableExtension
Remove the property associated to the passed key and return its value.- Specified by:
removeProperty
in interfaceMutableExtension
- Type Parameters:
T
- type of the property value- Parameters:
key
- the property key- Returns:
- the previous value associated with
key
, ornull
if there was no mapping forkey
- Since:
- 8.3M1
-
compareTo
public int compareTo(Extension o)
- Specified by:
compareTo
in interfaceComparable<Extension>
-
-