Class ScmModuleDescriptor

java.lang.Object
com.atlassian.plugin.descriptors.AbstractModuleDescriptor<T>
com.atlassian.bitbucket.scm.BaseWeightedModuleDescriptor<Scm>
com.atlassian.bitbucket.scm.ScmModuleDescriptor
All Implemented Interfaces:
Weighted, com.atlassian.plugin.ModuleDescriptor<Scm>, com.atlassian.plugin.Resourced, com.atlassian.plugin.ScopeAware, com.atlassian.plugin.StateAware, Comparable<BaseWeightedModuleDescriptor<Scm>>

public class ScmModuleDescriptor extends BaseWeightedModuleDescriptor<Scm>
ModuleDescriptor which interprets &lt;scm/&gt; tags in atlassian-plugin.xml.

 <scm id="scm" class="com.example.scm.CustomScm" weight="100"/>
 
Because this module descriptor uses the ModuleFactory to create the Scm instance, the "class" for the Scm may also reference a bean:

 <component id="customScm" class="com.example.scm.CustomScm"/>
 <scm id="scm" class="bean:customScm"/>
 
Using the "bean:" approach allows plugins to declare their custom Scm implementations as public components, allowing other plugins to component-import them and use them.

This module descriptor caches the Scm instance it creates, and returns the same instance on subsequent calls until the module is disabled or uninstalled. As a result, as documented on the Scm interface, implementations are required to be thread-safe, because the same instance will be used by multiple threads.

SCMs are weighted, which is used to control the order they are returned in when retrieving available SCMs. The higher the weight, the later in the set they will appear. Additionally, if multiple SCMs are registered with the same ID, the one with the lowest weight will be used.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor

    key, moduleClass, moduleClassName, moduleFactory, name, plugin, resources

    Fields inherited from interface com.atlassian.bitbucket.util.Weighted

    COMPARABLE
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScmModuleDescriptor(com.atlassian.plugin.module.ModuleFactory moduleFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the cached Scm.
    Retrieves the Scm instance for this descriptor.

    Methods inherited from class com.atlassian.bitbucket.scm.BaseWeightedModuleDescriptor

    compareTo, getWeight, init

    Methods inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor

    assertModuleClassImplements, checkPermissions, destroy, enabled, 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, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.atlassian.plugin.ModuleDescriptor

    getDisplayName
  • Field Details

  • Constructor Details

    • ScmModuleDescriptor

      public ScmModuleDescriptor(com.atlassian.plugin.module.ModuleFactory moduleFactory)
  • Method Details

    • disabled

      public void disabled()
      Clears the cached Scm.
      Specified by:
      disabled in interface com.atlassian.plugin.StateAware
      Overrides:
      disabled in class com.atlassian.plugin.descriptors.AbstractModuleDescriptor<Scm>
    • getModule

      public Scm getModule()
      Retrieves the Scm instance for this descriptor.

      The first time this method is called after an SCM plugin is installed or enabled, the Scm will be retrieved from the ModuleFactory and cached. Subsequent calls will retrieve the same instance.

      Specified by:
      getModule in interface com.atlassian.plugin.ModuleDescriptor<Scm>
      Specified by:
      getModule in class com.atlassian.plugin.descriptors.AbstractModuleDescriptor<Scm>
      Returns:
      the Scm instance