Class CustomMacroModuleDescriptor
java.lang.Object
com.atlassian.plugin.descriptors.AbstractModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>
com.atlassian.confluence.plugin.descriptor.CustomMacroModuleDescriptor
- All Implemented Interfaces:
MacroMetadataSource,MacroModuleDescriptor,PluginModuleFactory<com.atlassian.renderer.v2.macro.Macro>,UserLocaleAware,com.atlassian.plugin.ModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>,com.atlassian.plugin.Resourced,com.atlassian.plugin.ScopeAware,com.atlassian.plugin.StateAware,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public final class CustomMacroModuleDescriptor
extends com.atlassian.plugin.descriptors.AbstractModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>
implements MacroModuleDescriptor, org.springframework.context.ApplicationContextAware, PluginModuleFactory<com.atlassian.renderer.v2.macro.Macro>, UserLocaleAware, MacroMetadataSource
A plugin macro in Confluence with metadata and notation guide help.
- See Also:
-
Field Summary
Fields inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor
key, moduleClass, moduleClassName, moduleFactory, name, plugin, resources -
Constructor Summary
ConstructorsConstructorDescriptionCustomMacroModuleDescriptor(com.atlassian.plugin.module.ModuleFactory moduleFactory, MacroMetadataParser macroMetadataParser) -
Method Summary
Modifier and TypeMethodDescriptioncom.atlassian.renderer.v2.macro.Macrovoiddisabled()voidenabled()Used by code that automatically converts a V2 macro to an XHTML macro.getHelp()Returns the macro help as rendered HTML, or null if there is no help.com.atlassian.plugin.elements.ResourceDescriptorReturns the macro help descriptor, or null if there is no help.Returns the section of notation guide in which the macro help appears.com.atlassian.renderer.v2.macro.MacroReturns the macro defined by this module descriptor.booleanhasBody()A method that determines the return value ofMacro.hasBody()without initialising the module (or macro).booleanhasHelp()Returns true if the macro has help, otherwise false.voidinit(@NonNull com.atlassian.plugin.Plugin plugin, @NonNull com.atlassian.plugin.module.Element element) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetI18NBeanFactory(I18NBeanFactory i18NBeanFactory) Methods inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor
assertModuleClassImplements, checkPermissions, destroy, equals, getCompleteKey, getDescription, getDescriptionKey, getI18nNameKey, getKey, getMinJavaVersion, getModuleClass, getModuleClassName, getName, getParams, getPlugin, getPluginKey, getRequiredPermissions, getResourceDescriptor, getResourceDescriptors, getResourceLocation, getScopeKey, hashCode, isBroken, isEnabled, isEnabledByDefault, isSystemModule, loadClass, satisfiesMinJavaVersion, setBroken, setPlugin, toString, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.atlassian.plugin.ModuleDescriptor
destroy, equals, getCompleteKey, getDescription, getDescriptionKey, getDisplayName, getI18nNameKey, getKey, getMinJavaVersion, getModuleClass, getName, getParams, getPlugin, getPluginKey, hashCode, isBroken, isEnabled, isEnabledByDefault, isSystemModule, satisfiesMinJavaVersion, setBrokenMethods inherited from interface com.atlassian.plugin.Resourced
getResourceDescriptor, getResourceDescriptors, getResourceLocationMethods inherited from interface com.atlassian.plugin.ScopeAware
getScopeKey
-
Constructor Details
-
CustomMacroModuleDescriptor
public CustomMacroModuleDescriptor(com.atlassian.plugin.module.ModuleFactory moduleFactory, MacroMetadataParser macroMetadataParser)
-
-
Method Details
-
init
public void init(@NonNull com.atlassian.plugin.Plugin plugin, @NonNull com.atlassian.plugin.module.Element element) throws com.atlassian.plugin.PluginParseException - Specified by:
initin interfacecom.atlassian.plugin.ModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>- Overrides:
initin classcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>- Throws:
com.atlassian.plugin.PluginParseException
-
getModule
public com.atlassian.renderer.v2.macro.Macro getModule()Returns the macro defined by this module descriptor.- Specified by:
getModulein interfacecom.atlassian.plugin.ModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>- Specified by:
getModulein classcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>
-
createModule
public com.atlassian.renderer.v2.macro.Macro createModule()- Specified by:
createModulein interfacePluginModuleFactory<com.atlassian.renderer.v2.macro.Macro>
-
enabled
public void enabled()- Specified by:
enabledin interfacecom.atlassian.plugin.StateAware- Overrides:
enabledin classcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>
-
disabled
public void disabled()- Specified by:
disabledin interfacecom.atlassian.plugin.StateAware- Overrides:
disabledin classcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<com.atlassian.renderer.v2.macro.Macro>
-
hasHelp
public boolean hasHelp()Returns true if the macro has help, otherwise false. Help can be provided by defining a resource inside the macro descriptor in the plugin XML descriptor file. The help resource has a type of "velocity" and a name of "help". It can have either a body or a "location" attribute with a reference to a Velocity file within the plugin. -
getHelpSection
Returns the section of notation guide in which the macro help appears. Should be one of the values defined in NotationHelpAction#SECTION_KEYS. If the macro has no help, returns null. -
getHelpDescriptor
public com.atlassian.plugin.elements.ResourceDescriptor getHelpDescriptor()Returns the macro help descriptor, or null if there is no help. The help is defined as a resource with type "velocity" and name "help" inside the macro descriptor. The resource tag can have a location attribute, referring to a file within the plugin, or a body.- See Also:
-
getHelp
Returns the macro help as rendered HTML, or null if there is no help. The help is defined as a resource with type "velocity" and name "help" inside the macro descriptor. The resource tag can have a location attribute, referring to a file within the plugin, or a body.- See Also:
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getMacroMetadata
- Specified by:
getMacroMetadatain interfaceMacroMetadataSource- Specified by:
getMacroMetadatain interfaceMacroModuleDescriptor- Returns:
- MacroMetadata for this macro, may be null if not defined in the descriptor.
-
setI18NBeanFactory
- Specified by:
setI18NBeanFactoryin interfaceUserLocaleAware- Parameters:
i18NBeanFactory- the user locale sensitive i18n bean factory
-
getBodyType
Used by code that automatically converts a V2 macro to an XHTML macro. V2 macros without a body are automatically converted but bodied macros must specify their body type as a 'body-typeattribute value ("PLAIN_TEXT","RICH_TEXT"or"NONE"- indicates the macro really has no body after all) in the<macro>definition in theatlassian_plugin.xml.- Returns:
- BodyType.NONE for bodless macros and for bodied macros BodyType.PLAIN_TEXT, BodyType.RICH_TEXT or null if the attribute was not specified or was invalid.
-
hasBody
public boolean hasBody()A method that determines the return value ofMacro.hasBody()without initialising the module (or macro). This result of this method is currently required _before_ all plugin modules are parsed and registered (including other plugin modules that may declare spring components). As such, initialising modules when the spring context is not fully initialized will result in invalid plugins being registered. In other words we don't want to break lazy initialization of plugin modules and re-introduce problems like CONF-13386.This is only a best effort attempt. If there is any error constructing the macro using one of its constructors or an error executing hasBody(), then the value is considered false. This should only happen to small percentage of macros.
- Returns:
- the value of
Macro.hasBody()
-