Class DummyPlugin

java.lang.Object
com.atlassian.plugin.DummyPlugin
All Implemented Interfaces:
Plugin, Resourced, ScopeAware, Comparable<Plugin>

@Internal public class DummyPlugin extends Object implements Plugin
Dummy plugin implementation that returns java default values and does nothing.

Should be extended when a Plugin implementation is required, however must be compatible with multiple versions of that interface.

All methods are guaranteed to be implemented.

Since:
3.2.22
  • Constructor Details

    • DummyPlugin

      public DummyPlugin()
  • Method Details

    • getPluginsVersion

      public int getPluginsVersion()
      Description copied from interface: Plugin
      Gets the version of the plugins system to handle this plugin
      Specified by:
      getPluginsVersion in interface Plugin
      Returns:
      The plugins version. If undefined, assumed to be 1.
    • setPluginsVersion

      public void setPluginsVersion(int version)
      Description copied from interface: Plugin
      Sets the version of the plugins system
      Specified by:
      setPluginsVersion in interface Plugin
      Parameters:
      version - The version
    • getName

      public String getName()
      Description copied from interface: Plugin
      Returns the non-localised name of this plugin if defined.

      This corresponds to the value of the name field in the plugin's XML configuration file.

      You would expect a plugin developer to fill in one of either name, or i18n-name-key, but the framework does no validation and makes no guarantees that this is the case.

      Specified by:
      getName in interface Plugin
      Returns:
      the non-localised name of this plugin if defined, or null.
      See Also:
    • setName

      public void setName(String name)
      Description copied from interface: Plugin
      Sets the non-localised name of this plugin.
      Specified by:
      setName in interface Plugin
      Parameters:
      name - the name.
      See Also:
    • getI18nNameKey

      public String getI18nNameKey()
      Description copied from interface: Plugin
      Returns the i18nKey used to get an internationalised name for this plugin.

      This corresponds to the value of the i18n-name-key field in the plugin's XML configuration file.

      You would expect a plugin developer to fill in one of either name, or i18n-name-key, but the framework does no validation and makes no guarantees that this is the case.

      Specified by:
      getI18nNameKey in interface Plugin
      Returns:
      the i18n Name Key for this plugin if defined, or null.
      See Also:
    • setI18nNameKey

      public void setI18nNameKey(String i18nNameKey)
      Description copied from interface: Plugin
      Sets the i18nKey used to get an internationalised name for this plugin.
      Specified by:
      setI18nNameKey in interface Plugin
      Parameters:
      i18nNameKey - the i18n Name Key.
      See Also:
    • getKey

      public String getKey()
      Specified by:
      getKey in interface Plugin
    • setKey

      public void setKey(String aPackage)
      Specified by:
      setKey in interface Plugin
    • addModuleDescriptor

      public void addModuleDescriptor(ModuleDescriptor<?> moduleDescriptor)
      Specified by:
      addModuleDescriptor in interface Plugin
    • getModuleDescriptors

      public Collection<ModuleDescriptor<?>> getModuleDescriptors()
      Description copied from interface: Plugin
      Get the Collection of descriptors.

      The iteration order of the collection is the order that the modules will be enabled, and should be the same order that the modules appear in the plugin descriptor.

      Specified by:
      getModuleDescriptors in interface Plugin
      Returns:
      the modules contained by this plugin in the order they are to be enabled
    • getModuleDescriptor

      public ModuleDescriptor<?> getModuleDescriptor(String key)
      Description copied from interface: Plugin
      Get the ModuleDescriptor for a particular key. Returns null if the plugin does not exist.

      Note: The ModuleDescriptor.getModule() may throw ClassCastException if the expected type is incorrect.

      Specified by:
      getModuleDescriptor in interface Plugin
      Parameters:
      key - the String complete key of the module, in the form "org.example.plugin:module-key".
      Returns:
      the ModuleDescriptor of the expected type.
    • getModuleDescriptorsByModuleClass

      public <M> List<ModuleDescriptor<M>> getModuleDescriptorsByModuleClass(Class<M> moduleClass)
      Description copied from interface: Plugin
      Get the descriptors whose module class implements or is assignable from the supplied Class.

      Note: The ModuleDescriptor.getModule() may throw ClassCastException if the expected type is incorrect. Normally this method would not be supplied with anything other than Object or <?>, unless you are confident in the super type of the module classes this Plugin provides.

      Specified by:
      getModuleDescriptorsByModuleClass in interface Plugin
      Type Parameters:
      M - The expected module type of the returned descriptors.
      Parameters:
      moduleClass - the super class the descriptors return.
      Returns:
      the List of descriptors of the expected type.
    • getInstallationMode

      public InstallationMode getInstallationMode()
      Description copied from interface: Plugin
      Gets the installation mode
      Specified by:
      getInstallationMode in interface Plugin
      Returns:
      the plugin's installation mode, local or remote.
    • isEnabledByDefault

      public boolean isEnabledByDefault()
      Specified by:
      isEnabledByDefault in interface Plugin
    • setEnabledByDefault

      public void setEnabledByDefault(boolean enabledByDefault)
      Specified by:
      setEnabledByDefault in interface Plugin
    • getPluginInformation

      public PluginInformation getPluginInformation()
      Specified by:
      getPluginInformation in interface Plugin
    • setPluginInformation

      public void setPluginInformation(PluginInformation pluginInformation)
      Specified by:
      setPluginInformation in interface Plugin
    • setResources

      public void setResources(Resourced resources)
      Specified by:
      setResources in interface Plugin
    • getPluginState

      public PluginState getPluginState()
      Description copied from interface: Plugin
      Returns this plugin's current state.
      Specified by:
      getPluginState in interface Plugin
      Returns:
      the current state of the plugin.
    • isSystemPlugin

      public boolean isSystemPlugin()
      Description copied from interface: Plugin
      Whether the plugin is a "system" plugin that shouldn't be made visible to the user.
      Specified by:
      isSystemPlugin in interface Plugin
      Returns:
      true if this plugin is a "system" plugin.
    • setSystemPlugin

      public void setSystemPlugin(boolean system)
      Specified by:
      setSystemPlugin in interface Plugin
      Parameters:
      system - whether the plugin is a "system" plugin that shouldn't be made visible to the user.
    • containsSystemModule

      public boolean containsSystemModule()
      Specified by:
      containsSystemModule in interface Plugin
    • isBundledPlugin

      public boolean isBundledPlugin()
      Description copied from interface: Plugin
      Whether the plugin is a "bundled" plugin that can't be removed.
      Specified by:
      isBundledPlugin in interface Plugin
      Returns:
      true if this plugin is a "bundled" plugin.
    • getDateLoaded

      public Date getDateLoaded()
      Description copied from interface: Plugin
      The date this plugin was loaded into the system.
      Specified by:
      getDateLoaded in interface Plugin
      Returns:
      The date this plugin was loaded into the system.
    • getDateInstalled

      public Date getDateInstalled()
      Description copied from interface: Plugin
      The date this plugin was installed into the system, is the same as the loaded date for non artifact backed plugins
      Specified by:
      getDateInstalled in interface Plugin
      Returns:
      The date this plugin was installed into the system
    • isUninstallable

      public boolean isUninstallable()
      Description copied from interface: Plugin
      Whether or not this plugin can be 'uninstalled'.
      Specified by:
      isUninstallable in interface Plugin
      Returns:
      true if this plugin can be 'uninstalled'.
    • isDeleteable

      public boolean isDeleteable()
      Description copied from interface: Plugin
      Should the plugin file be deleted on uninstall?
      Specified by:
      isDeleteable in interface Plugin
      Returns:
      true if this plugin file should be deleted on uninstall.
    • isDynamicallyLoaded

      public boolean isDynamicallyLoaded()
      Description copied from interface: Plugin
      Whether or not this plugin is loaded dynamically at runtime.
      Specified by:
      isDynamicallyLoaded in interface Plugin
      Returns:
      true if this plugin is loaded dynamically at runtime.
    • loadClass

      public <T> Class<T> loadClass(String clazz, Class<?> callingClass) throws ClassNotFoundException
      Description copied from interface: Plugin
      Get the plugin to load a specific class.
      Specified by:
      loadClass in interface Plugin
      Parameters:
      clazz - The name of the class to be loaded
      callingClass - The class calling the loading (used to help find a classloader)
      Returns:
      The loaded class.
      Throws:
      ClassNotFoundException - if the class cannot be located.
    • getClassLoader

      public ClassLoader getClassLoader()
      Description copied from interface: Plugin
      Get the classloader for the plugin.
      Specified by:
      getClassLoader in interface Plugin
      Returns:
      The classloader used to load classes for this plugin
    • getResource

      public URL getResource(String path)
      Description copied from interface: Plugin
      Retrieve the URL of the resource from the plugin.
      Specified by:
      getResource in interface Plugin
      Parameters:
      path - the name of the resource to be loaded
      Returns:
      The URL to the resource, or null if the resource is not found
    • getResourceAsStream

      public InputStream getResourceAsStream(String name)
      Description copied from interface: Plugin
      Load a given resource from the plugin. Plugins that are loaded dynamically will need to implement this in a way that loads the resource from the same context as the plugin. Static plugins can just pull them from their own classloader.
      Specified by:
      getResourceAsStream in interface Plugin
      Parameters:
      name - The name of the resource to be loaded.
      Returns:
      An InputStream for the resource, or null if the resource is not found.
    • install

      public void install()
      Description copied from interface: Plugin
      Installs the plugin into any internal, managing container. This method will be called on every startup. Unless an exception is thrown, the plugin should be in the PluginState.INSTALLED state. If the plugin is already in the PluginState.INSTALLED state, nothing will happen.
      Specified by:
      install in interface Plugin
    • uninstall

      public void uninstall()
      Description copied from interface: Plugin
      Uninstalls the plugin from any internal container. This method will be called on every shutdown. Unless an exception is thrown, the plugin should be in the PluginState.UNINSTALLED state. If the plugin is already in the PluginState.UNINSTALLED state, nothing will happen.
      Specified by:
      uninstall in interface Plugin
    • enable

      public void enable()
      Description copied from interface: Plugin
      Enables the plugin. Unless an exception is thrown, the plugin should then be in either the PluginState.ENABLING or PluginState.ENABLED state. If the plugin is already in the PluginState.ENABLING or PluginState.ENABLED state, nothing will happen.
      Specified by:
      enable in interface Plugin
    • disable

      public void disable()
      Description copied from interface: Plugin
      Disables the plugin. Unless an exception is thrown, the plugin should be in the PluginState.DISABLED state. If the plugin is already in the PluginState.DISABLED state, nothing will happen.
      Specified by:
      disable in interface Plugin
    • getDependencies

      @Nonnull public PluginDependencies getDependencies()
      Description copied from interface: Plugin
      Determines which plugin keys are dependencies, categorising them as mandatory, optional or dynamic.
      Specified by:
      getDependencies in interface Plugin
      Returns:
      not null, possibly empty
    • getActivePermissions

      public Set<String> getActivePermissions()
      Specified by:
      getActivePermissions in interface Plugin
      Returns:
      the list of permissions currently valid for the plugin
    • hasAllPermissions

      public boolean hasAllPermissions()
      Specified by:
      hasAllPermissions in interface Plugin
      Returns:
      true if the plugin has all the permissions
    • resolve

      public void resolve()
      Description copied from interface: Plugin
      Perform any required resolution. This is a hook to allow the plugin system to perform a resolution pass over a group of modules before the enable pass.
      Specified by:
      resolve in interface Plugin
    • getDateEnabling

      @Nullable public Date getDateEnabling()
      Description copied from interface: Plugin
      Obtain the date that the plugin system most recently commenced enabling this plugin. This may return null if the plugin has never commenced enabling, or if the value is unavailable for other reasons, such as wrappers around legacy implementations.
      Specified by:
      getDateEnabling in interface Plugin
      Returns:
      the date that the plugin most recently entered PluginState.ENABLING.
    • getDateEnabled

      @Nullable public Date getDateEnabled()
      Description copied from interface: Plugin
      Obtain the date that the plugin system most recently completed enabling of this plugin. This will return null if the plugin has never been enabled, has not completed enabling since it most recently started enabling, or if the value is unavailable for any other reason, such as wrappers around legacy implementations.
      Specified by:
      getDateEnabled in interface Plugin
      Returns:
      the date that the plugin most recently entered PluginState.ENABLED, if this was not before the most recent PluginState.ENABLING, otherwise null.
    • getPluginArtifact

      public PluginArtifact getPluginArtifact()
      Description copied from interface: Plugin
      Retrieve the original, unprocessed or transformed PluginArtifact used to create this plugin instance.

      Note that this method may be removed without notice; it is for use only by the host application.

      This method was originally part of the internal PluginArtifactBackedPlugin interface that is no longer present.

      Specified by:
      getPluginArtifact in interface Plugin
      Returns:
      null if this plugin has no artifact
    • compareTo

      public int compareTo(Plugin o)
      Specified by:
      compareTo in interface Comparable<Plugin>
    • getResourceDescriptors

      public List<ResourceDescriptor> getResourceDescriptors()
      Description copied from interface: Resourced
      Get a List of all the descriptors .

      Note: since 2.2 this list must be immutable, previously modifying this list could modify the underlying list.

      Specified by:
      getResourceDescriptors in interface Resourced
      Returns:
      all resource descriptors this object supports.
    • getResourceDescriptor

      public ResourceDescriptor getResourceDescriptor(String type, String name)
      Description copied from interface: Resourced
      Get a ResourceDescriptor of a particular type and name.
      Specified by:
      getResourceDescriptor in interface Resourced
      Returns:
      the specified resource descriptor if found, null otherwise.
    • getResourceLocation

      public ResourceLocation getResourceLocation(String type, String name)
      Description copied from interface: Resourced
      Get a ResourceLocation of a particular type and name.
      Specified by:
      getResourceLocation in interface Resourced
      Returns:
      the specified resource location if found, null otherwise.