Class Plugin

java.lang.Object
com.morpheusdata.core.Plugin
All Implemented Interfaces:
PluginInterface

public abstract class Plugin extends Object implements PluginInterface
This is the base class for all Plugins that are instantiated within the Morpheus Environment. It contains both metadata related to the plugin itself as well as any providers that may need to be instanced for use within Morpheus. The most important method of implementation should be the PluginInterface.initialize() method. This is where PluginProvider instances are registered into the plugin.

Example:


 import com.Morpheus.core.Plugin;

 class MyPlugin extends Plugin {
     void initialize() {
         this.setName("My Custom Tabs Plugin");
         CustomTabProvider tabProvider = new CustomTabProvider(this, morpheus);
         this.registerProvider(tabProvider);
     }
 }
 
  • Field Details

    • pluginProviders

      protected Map<String,PluginProvider> pluginProviders
      All registered plugin providers by provider code.
    • morpheus

      protected MorpheusContext morpheus
      Reference to the main Morpheus Context.
    • renderer

      protected Renderer<?> renderer
      The default renderer to be used for UI based plugins. Typically Handlebars (server side).
    • controllers

      protected List<PluginController> controllers
      The list of custom controllers registered into the plugin
    • settings

      protected List<OptionType> settings
      The list of settings for the plugin
    • permissions

      protected List<Permission> permissions
      The list of permissions this plugin provides that may affect display of other UIExtensionProvider based providers.
    • name

      protected String name
      The name of the plugin
    • fileName

      protected String fileName
      The fileName of the jar the plugin is packaged in.
    • version

      protected String version
      The current version of the plugin
    • author

      protected String author
      The author who created the plugin
    • description

      protected String description
      A simple description of what the plugin provides
    • websiteUrl

      protected String websiteUrl
      An optional URL to the website for the maintainer of the plugin
    • sourceCodeLocationUrl

      protected String sourceCodeLocationUrl
      Source code location for this plugin
    • issueTrackerUrl

      protected String issueTrackerUrl
      URL for reporting issues with the plugin (if applicable).
  • Constructor Details

    • Plugin

      public Plugin()
  • Method Details

    • setSettings

      public void setSettings(List<OptionType> settings)
      Sets the setting types for this plugin.
      Parameters:
      settings - a list of the OptionType settings for this plugin.
    • getSettings

      public List<OptionType> getSettings()
      Returns a list of OptionType settings for this plugin.
      Returns:
      this list of settings
    • setControllers

      public void setControllers(List<PluginController> controllers)
      Sets the controllers for custom url endpoints/view rendering that are provided with this plugin. These are often not necessary and typically a more advanced use case.
      Parameters:
      controllers - a list of all controller classes (singleton) to be registered with the plugin.
    • getControllers

      public List<PluginController> getControllers()
      Returns a list of all PluginController classes registered with this plugin
      Returns:
      the list of controllers
    • setRenderer

      public void setRenderer(Renderer<?> renderer)
      Set the template renderer for ths plugin.
      Parameters:
      renderer - sets the renderer for the plugin
    • hasCustomRender

      public boolean hasCustomRender()
      A conditional flag to check if this plugin registers a custom renderer outside of the default one provided by the PluginManager.
      Returns:
      whether or not the plugin has a custom renderer.
    • getRenderer

      protected Renderer<?> getRenderer()
      Get the template renderer for this plugin.
      Returns:
      the renderer for the plugin
    • getPluginManager

      public PluginManager getPluginManager()
      All plugins reside in a Plugin Manager responsible for loading all plugins. This allows the PluginManager to be accessed from its children in the event another plugin needs to be referenced.
      Returns:
      The Singleton instance of a PluginManager for the Morpheus App.
    • getProviders

      public Collection<PluginProvider> getProviders()
      Provides a collection of all PluginProvider classes that this plugin provides in Singleton Form. These Providers can range in type from DNS,IPAM or even Cloud Integrations.
      Returns:
      a Collection of cloud providers that have been loaded by this plugin.
    • getProviderByCode

      public PluginProvider getProviderByCode(String code)
      Grabs an instance of a plugin provider loaded by a unique code as defined by the implementation of the provider
      Parameters:
      code - The unique code given to the @{link PluginProvider} implementation.
      Returns:
      A single Plugin Provider matched by code. If the Plugin Provider is not found a null result will be returned.
    • getProvidersByType

      public Collection<PluginProvider> getProvidersByType(Class clazz)
      Returns a Collection of all Providers provided by this Plugin based on Type class. For example, if one wanted to grab all cloud provider classes, this method would be the most efficient way to do that.
      Parameters:
      clazz - The interface class that all PluginProvider classes implement.
      Returns:
      A collection of matched providers by type. If no results are found an empty ArrayList is returned.
    • getName

      public String getName()
      Gets the name of the current plugin. This is useful for human readable display
      Specified by:
      getName in interface PluginInterface
      Returns:
      the name of the plugin
    • setName

      public void setName(String name)
      Sets the plugin name. This can be done on the extended class to describe the plugin
      Specified by:
      setName in interface PluginInterface
      Parameters:
      name - the desired name of the plugin implementation
    • getFileName

      public String getFileName()
      Returns the file name of the jar the plugin is coming from. This can be useful for custom class loaders or determining if a plugin should be reloaded
      Specified by:
      getFileName in interface PluginInterface
      Returns:
      the file name of the jar the plugin resides in.
    • setFileName

      public void setFileName(String fileName)
      Sets the file name of the jar the plugin was instantiated from for reference.
      Specified by:
      setFileName in interface PluginInterface
      Parameters:
      fileName - the file name of the jar the plugin was loaded from
    • getVersion

      public String getVersion()
      Gets the current version of the plugin. This is compared against previously loaded plugins with the same name. If there was a previously loaded version of the same plugin, the plugin is replaced and reloaded.
      Specified by:
      getVersion in interface PluginInterface
      Returns:
      the current plugin version
    • setVersion

      public void setVersion(String version)
      Sets the current version of the plugin implementation.
      Specified by:
      setVersion in interface PluginInterface
      Parameters:
      version - the desired version assignment of the plugin
    • getDescription

      public String getDescription()
      Gets the current description of the plugin. This is typically a more detailed description of a name but still should be a relatively short summary of what the plugin offers.
      Specified by:
      getDescription in interface PluginInterface
      Returns:
      the description of what the plugin provides.
    • setDescription

      public void setDescription(String description)
      Sets teh current description of the plugin implementation. This is typically done when designing a new plugin within the extended plugin class.
      Specified by:
      setDescription in interface PluginInterface
      Parameters:
      description - the desired description of the plugin.
    • getAuthor

      public String getAuthor()
      Returns the author of who created / maintains this current plugin implementation.
      Specified by:
      getAuthor in interface PluginInterface
      Returns:
      the authors name
    • setAuthor

      public void setAuthor(String author)
      Sets the author of who created / maintains this plugin implementation.
      Specified by:
      setAuthor in interface PluginInterface
      Parameters:
      author - the name / username of the author
    • getWebsiteUrl

      public String getWebsiteUrl()
      The Website associated with the plugin. This could be a specific plugin web url or a link to the company that maintains the plugin.
      Specified by:
      getWebsiteUrl in interface PluginInterface
      Returns:
      the plugins web url
    • setWebsiteUrl

      public void setWebsiteUrl(String websiteUrl)
      Sets the web url of the plugin. This could be a plugin specific url or even a company url of who maintains the plugin.
      Specified by:
      setWebsiteUrl in interface PluginInterface
      Parameters:
      websiteUrl - the desired url. (Include protocol such as http:// or https://)
    • getSourceCodeLocationUrl

      public String getSourceCodeLocationUrl()
      Returns the SCM Repository URL for where the source code is maintained (i.e. https://github.com/gomorpheus/morpheus-plugin-core/) This is useful for open source plugins where third party users may want to contribute changes or fixes.
      Specified by:
      getSourceCodeLocationUrl in interface PluginInterface
      Returns:
      the SCM Repository URL
    • setSourceCodeLocationUrl

      public void setSourceCodeLocationUrl(String sourceCodeLocationUrl)
      Sets the SCM Repository URL for the location to which the source code for this plugin is maintained. (i.e. https://github.com/gomorpheus/morpheus-plugin-core/)
      Specified by:
      setSourceCodeLocationUrl in interface PluginInterface
      Parameters:
      sourceCodeLocationUrl - the desired SCM Url
    • getIssueTrackerUrl

      public String getIssueTrackerUrl()
      Gets the issue tracker url for the plugin. This is a url location where a consumer of the plugin could report issues.
      Specified by:
      getIssueTrackerUrl in interface PluginInterface
      Returns:
      the issue tracker url (i.e. a JIRA or github issues link)
    • setIssueTrackerUrl

      public void setIssueTrackerUrl(String issueTrackerUrl)
      Sets the issue tracker url where the consumers of the plugin can report issues or suggestions to the maintainer.
      Specified by:
      setIssueTrackerUrl in interface PluginInterface
      Parameters:
      issueTrackerUrl - the desired web url for where a user can report issues with the plugin.
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Sets the plugin specific class loader for reference by provider classes or other areas of the plugin. This is not typically called directly by a user but is instead called by the PluginManager during instantiation.
      Parameters:
      classLoader - the class loader representing the jar the plugin was loaded from
    • getClassLoader

      public ClassLoader getClassLoader()
      Returns the plugin specific class loader to be used for all class resolution within the plugin.
      Returns:
      the class loader of the plugin and its associated providers.
    • getPermissions

      public List<Permission> getPermissions()
      Returns a list of custom permissions defined by the plugin that may affect the display of various UI Providers
      Returns:
      the list of permissions this plugin provides.
    • setPermissions

      public void setPermissions(List<Permission> permissions)
      Typically called during the initialize method of the plugin. This allows the plugin to register custom permissions that the user can be assigned that affect the various display properties of some of the UI provider based plugins.
      Parameters:
      permissions - a list of permissions provided by the plugin.
    • registerProvider

      public void registerProvider(PluginProvider provider)
      Registers an instance (typically a singleton) of a PluginProvider for registration with Morpheus
      Parameters:
      provider - the instance of the plugin provider being registered.
    • registerProviders

      public void registerProviders(PluginProvider... providers)
      Registers an instance (typically a singleton) of many PluginProviders for registration with Morpheus
      Parameters:
      providers - the instances of the plugin providers being registered.
    • registerProviders

      public void registerProviders(Collection<PluginProvider> providers)
      Registers an instance (typically a singleton) of many PluginProviders for registration with Morpheus
      Parameters:
      providers - the instances of the plugin providers being registered.
    • checkForProviderConflict

      public void checkForProviderConflict(PluginProvider provider)