Class XmlDescriptorParser
java.lang.Object
com.atlassian.plugin.internal.parsers.XmlDescriptorParser
- All Implemented Interfaces:
DescriptorParser
Provides access to the descriptor information retrieved from an XML InputStream.
Uses the dom4j SAXReader to parse the XML stream into a document
when the parser is constructed.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionXmlDescriptorParser(InputStream source, Iterable<InputStream> supplementalSources, Set<Application> applications) Constructs a parser with a stream of an XML document for a specific applicationXmlDescriptorParser(InputStream source, Set<Application> applications) Constructs a parser with a stream of an XML document for a specific applicationXmlDescriptorParser(org.dom4j.Document source, Set<Application> applications) Constructs a parser with an already-constructed document -
Method Summary
Modifier and TypeMethodDescriptionaddModule(ModuleDescriptorFactory moduleDescriptorFactory, Plugin plugin, Element module) Create a new module and createElement it with the plugin, then return it.configurePlugin(ModuleDescriptorFactory moduleDescriptorFactory, Plugin plugin) Sets the configuration on the plugin argument to match the configuration specified in the plugin descriptor (typically an XML file).protected static org.dom4j.DocumentcreateDocument(InputStream source) protected ModuleDescriptor<?>createModuleDescriptor(Plugin plugin, Element element, ModuleDescriptorFactory moduleDescriptorFactory) protected PluginInformationprotected org.dom4j.DocumentgetKey()intbooleanprotected static org.dom4j.DocumentmergeDocuments(org.dom4j.Document mainDocument, Iterable<org.dom4j.Document> supplementalDocuments) Retrieves theElements representing the modules from the input source (plugin descriptor file snippet).
-
Constructor Details
-
XmlDescriptorParser
Constructs a parser with an already-constructed document- Parameters:
source- the source documentapplications- the application key to filter modules with, null for all unspecified- Throws:
PluginParseException- if there is a problem reading the descriptor from the XMLInputStream.- Since:
- 2.2.0
-
XmlDescriptorParser
Constructs a parser with a stream of an XML document for a specific application- Parameters:
source- The descriptor streamapplications- the application key to filter modules with, null for all unspecified- Throws:
PluginParseException- if there is a problem reading the descriptor from the XMLInputStream.- Since:
- 2.2.0
-
XmlDescriptorParser
public XmlDescriptorParser(InputStream source, Iterable<InputStream> supplementalSources, Set<Application> applications) Constructs a parser with a stream of an XML document for a specific application- Parameters:
source- The descriptor streamsupplementalSources- a collection of streams containing supplemental ModuleDescriptorsapplications- the application key to filter modules with, null for all unspecified- Throws:
PluginParseException- if there is a problem reading the descriptor from the XMLInputStream.- Since:
- 3.2.16
-
-
Method Details
-
createDocument
-
mergeDocuments
protected static org.dom4j.Document mergeDocuments(org.dom4j.Document mainDocument, Iterable<org.dom4j.Document> supplementalDocuments) -
getDocument
protected org.dom4j.Document getDocument() -
configurePlugin
Description copied from interface:DescriptorParserSets the configuration on the plugin argument to match the configuration specified in the plugin descriptor (typically an XML file).- Specified by:
configurePluginin interfaceDescriptorParser- Parameters:
moduleDescriptorFactory- a factory for instantiating the required plugin modulesplugin- the plugin whose configuration will be modified- Returns:
- the original plugin with the configuration changed and the module descriptors added
-
addModule
public ModuleDescriptor<?> addModule(ModuleDescriptorFactory moduleDescriptorFactory, Plugin plugin, Element module) Description copied from interface:DescriptorParserCreate a new module and createElement it with the plugin, then return it.In the event of a problem loading the module, return an
UnrecognisedModuleDescriptorwith error.- Specified by:
addModulein interfaceDescriptorParser- Parameters:
moduleDescriptorFactory- basic factory, may be overriddenplugin- that the module will be initialised withmodule- to create
-
parseChildModulesFromSource
Description copied from interface:DescriptorParserRetrieves theElements representing the modules from the input source (plugin descriptor file snippet). Does not instantiate or validate that the returned Elements represent valid modules.Eg. For a snippet such as:
<root-element> <module1 key=""/> <module2 key=""><otherModules/></module2> </root-element>The elements returned will be the module1 and module2 elements.- Specified by:
parseChildModulesFromSourcein interfaceDescriptorParser
-
createModuleDescriptor
protected ModuleDescriptor<?> createModuleDescriptor(Plugin plugin, Element element, ModuleDescriptorFactory moduleDescriptorFactory) -
createPluginInformation
-
getKey
- Specified by:
getKeyin interfaceDescriptorParser- Returns:
- the key of the plugin specified in the descriptor
-
getPluginsVersion
public int getPluginsVersion()- Specified by:
getPluginsVersionin interfaceDescriptorParser- Returns:
- The version of the plugin system expected by this plugin. If unknown, it is assumed to be 1.
-
getPluginInformation
- Specified by:
getPluginInformationin interfaceDescriptorParser
-
isSystemPlugin
public boolean isSystemPlugin()- Specified by:
isSystemPluginin interfaceDescriptorParser- Returns:
- true if this plugin is marked as a system plugin in the descriptor. This should only be acted on by plugin loaders which can trust their plugins implicitly (e.g. a classpath plugin loader).
-