Class XhtmlMacroManager

java.lang.Object
com.atlassian.confluence.macro.xhtml.XhtmlMacroManager
All Implemented Interfaces:
MacroManager

public class XhtmlMacroManager extends Object implements MacroManager

Listens for PluginModuleEnabledEvent and 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).

Since:
4.0
See Also:
  • Field Details

  • Constructor Details

    • XhtmlMacroManager

      public XhtmlMacroManager(com.atlassian.event.api.EventPublisher eventPublisher)
  • Method Details

    • getMacroByName

      public Macro getMacroByName(@NonNull String macroName)
      Description copied from interface: MacroManager
      Gives the Macro registered with the given name, or null if there is none registered with the manager.
      Specified by:
      getMacroByName in interface MacroManager
      Parameters:
      macroName - The macro to get.
      Returns:
      The Macro, or null if there is none registered.
    • getMacros

      public Map<String,Macro> getMacros()
    • registerMacro

      public void registerMacro(@NonNull String name, @NonNull Macro macro)
      Description copied from interface: MacroManager
      Registers a new macro with the given name. If a macro already exists with that name, it is replaced by the new macro.
      Specified by:
      registerMacro in interface MacroManager
      Parameters:
      name - the name to register the macro under. For example, 'code'.
      macro - the macro to register
    • unregisterMacro

      public void unregisterMacro(@NonNull String name)
      Description copied from interface: MacroManager
      Unregisters the macro with the given name. Does nothing if no such macro is registered.
      Specified by:
      unregisterMacro in interface MacroManager
      Parameters:
      name - the name of the macro to unregister. For example, 'code'.
    • pluginModuleEnabled

      public void pluginModuleEnabled(com.atlassian.plugin.event.events.PluginModuleEnabledEvent event)
    • pluginModuleDisabled

      public void pluginModuleDisabled(com.atlassian.plugin.event.events.PluginModuleDisabledEvent event)
    • newLazyMacroReference

      public io.atlassian.util.concurrent.LazyReference<Macro> newLazyMacroReference(com.atlassian.plugin.ModuleDescriptor<?> moduleDescriptor)
      Description copied from interface: MacroManager
      Macros are lazy loaded to avoid plugin module ordering problems like CONF-13386.
      Specified by:
      newLazyMacroReference in interface MacroManager
      Parameters:
      moduleDescriptor - describes the macro we are creating a lazy reference to.
      Returns:
      a LazyReference to a macro as described by the supplied ModuleDescriptor
    • setPluginEventManager

      public void setPluginEventManager(com.atlassian.plugin.event.PluginEventManager pluginEventManager)
    • unwrapMacroProxy

      public static Macro unwrapMacroProxy(Macro proxy)
      Unwraps a macro proxy that is wrapped with a XhtmlMacroManager.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 XhtmlMacroManager.ResourceAwareMacroInvocationHandler