com.atlassian.plugin.parsers
Class XmlDescriptorParser

java.lang.Object
  extended by com.atlassian.plugin.parsers.XmlDescriptorParser
All Implemented Interfaces:
DescriptorParser
Direct Known Subclasses:
OsgiPluginXmlDescriptorParser

public class XmlDescriptorParser
extends java.lang.Object
implements 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:
XmlDescriptorParserFactory

Constructor Summary
XmlDescriptorParser(org.dom4j.Document source, java.lang.String... applicationKeys)
          Constructs a parser with an already-constructed document
XmlDescriptorParser(java.io.InputStream source, java.lang.String... applicationKeys)
          Constructs a parser with a stream of an XML document for a specific application
 
Method Summary
 Plugin 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  org.dom4j.Document createDocument(java.io.InputStream source)
           
protected  ModuleDescriptor<?> createModuleDescriptor(Plugin plugin, org.dom4j.Element element, ModuleDescriptorFactory moduleDescriptorFactory)
           
protected  PluginInformation createPluginInformation(org.dom4j.Element element)
           
protected  org.dom4j.Document getDocument()
           
 java.lang.String getKey()
           
 PluginInformation getPluginInformation()
           
 int getPluginsVersion()
           
 boolean isSystemPlugin()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlDescriptorParser

public XmlDescriptorParser(org.dom4j.Document source,
                           java.lang.String... applicationKeys)
                    throws PluginParseException
Constructs a parser with an already-constructed document

Parameters:
source - the source document
applicationKeys - the application key to filter modules with, null for all unspecified
Throws:
PluginParseException - if there is a problem reading the descriptor from the XML InputStream.
Since:
2.2.0

XmlDescriptorParser

public XmlDescriptorParser(java.io.InputStream source,
                           java.lang.String... applicationKeys)
                    throws PluginParseException
Constructs a parser with a stream of an XML document for a specific application

Parameters:
source - The descriptor stream
applicationKeys - the application key to filter modules with, null for all unspecified
Throws:
PluginParseException - if there is a problem reading the descriptor from the XML InputStream.
Since:
2.2.0
Method Detail

createDocument

protected org.dom4j.Document createDocument(java.io.InputStream source)
                                     throws PluginParseException
Throws:
PluginParseException

getDocument

protected org.dom4j.Document getDocument()

configurePlugin

public Plugin configurePlugin(ModuleDescriptorFactory moduleDescriptorFactory,
                              Plugin plugin)
                       throws PluginParseException
Description copied from interface: DescriptorParser
Sets the configuration on the plugin argument to match the configuration specified in the plugin descriptor (typically an XML file).

Specified by:
configurePlugin in interface DescriptorParser
Parameters:
moduleDescriptorFactory - a factory for instantiating the required plugin modules
plugin - the plugin whose configuration will be modified
Returns:
the original plugin with the configuration changed and the module descriptors added
Throws:
PluginParseException - if there was an error getting information about the plugin

createModuleDescriptor

protected ModuleDescriptor<?> createModuleDescriptor(Plugin plugin,
                                                     org.dom4j.Element element,
                                                     ModuleDescriptorFactory moduleDescriptorFactory)
                                              throws PluginParseException
Throws:
PluginParseException

createPluginInformation

protected PluginInformation createPluginInformation(org.dom4j.Element element)

getKey

public java.lang.String getKey()
Specified by:
getKey in interface DescriptorParser
Returns:
the key of the plugin specified in the descriptor

getPluginsVersion

public int getPluginsVersion()
Specified by:
getPluginsVersion in interface DescriptorParser
Returns:
The version of the plugin system expected by this plugin. If unknown, it is assumed to be 1.

getPluginInformation

public PluginInformation getPluginInformation()
Specified by:
getPluginInformation in interface DescriptorParser

isSystemPlugin

public boolean isSystemPlugin()
Specified by:
isSystemPlugin in interface DescriptorParser
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).


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.