public class

XhtmlMacroManager

extends Object
implements MacroManager
java.lang.Object
   ↳ com.atlassian.confluence.macro.xhtml.XhtmlMacroManager

Class Overview

Listens for com.atlassian.plugin.event.events.PluginModuleEnabledEvent and com.atlassian.plugin.event.events.PluginModuleDisabledEvent to register Macros with itself.

All macros will be wrapped in a LazyLoadingMacroWrapper and will have their resource path set if they are ResourceAware. If they are not ResourceAware then they will be wrapped in a dynamic proxy that does implement the interface (and the path will be set).

Summary

Constants
String RESOURCE_PREFIX
Public Constructors
XhtmlMacroManager(EventPublisher eventPublisher)
Public Methods
LazyReference<Macro> createLazyMacroReference(ModuleDescriptor<?> moduleDescriptor)
Macros are lazy loaded to avoid plugin module ordering problems like CONF-13386.
Macro getMacroByName(String macroName)
Gives the Macro registered with the given name, or null if there is none registered with the manager.
void pluginModuleDisabled(PluginModuleDisabledEvent event)
void pluginModuleEnabled(PluginModuleEnabledEvent event)
void registerMacro(String name, Macro macro)
Registers a new macro with the given name.
void setPluginEventManager(PluginEventManager pluginEventManager)
void unregisterMacro(String name)
Unregisters the macro with the given name.
static Macro unwrapMacroProxy(Macro proxy)
Unwraps a macro proxy that is wrapped with a ResourceAwareMacroInvocationHandler.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.confluence.macro.xhtml.MacroManager

Constants

public static final String RESOURCE_PREFIX

Constant Value: "/download/resources/"

Public Constructors

public XhtmlMacroManager (EventPublisher eventPublisher)

Public Methods

public LazyReference<Macro> createLazyMacroReference (ModuleDescriptor<?> moduleDescriptor)

Macros are lazy loaded to avoid plugin module ordering problems like CONF-13386.

Parameters
moduleDescriptor describes the macro we are creating a lazy reference to.
Returns
  • a LazyReference to a macro as described by the supplied ModuleDescriptor

public Macro getMacroByName (String macroName)

Gives the Macro registered with the given name, or null if there is none registered with the manager.

Parameters
macroName The macro to get.
Returns
  • The Macro, or null if there is none registered.

public void pluginModuleDisabled (PluginModuleDisabledEvent event)

public void pluginModuleEnabled (PluginModuleEnabledEvent event)

public void registerMacro (String name, Macro macro)

Registers a new macro with the given name. If a macro already exists with that name, it is replaced by the new macro.

Parameters
name the name to register the macro under. For example, 'code'.
macro the macro to register

public void setPluginEventManager (PluginEventManager pluginEventManager)

public void unregisterMacro (String name)

Unregisters the macro with the given name. Does nothing if no such macro is registered.

Parameters
name the name of the macro to unregister. For example, 'code'.

public static Macro unwrapMacroProxy (Macro proxy)

Unwraps a macro proxy that is wrapped with a ResourceAwareMacroInvocationHandler. If the macro is not proxied with this invocation handler then the passed in proxy is returned.

Parameters
proxy The proxy to unwrap
Returns
  • The proxied instance if it is using the ResourceAwareMacroInvocationHandler