Class Plugin

  • All Implemented Interfaces:
    PluginInterface

    public abstract class Plugin
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String author
      The author who created the plugin
      protected java.util.List<PluginController> controllers
      The list of custom controllers registered into the plugin
      protected java.lang.String description
      A simple description of what the plugin provides
      protected java.lang.String fileName
      The fileName of the jar the plugin is packaged in.
      protected java.lang.String issueTrackerUrl
      URL for reporting issues with the plugin (if applicable).
      protected MorpheusContext morpheus
      Reference to the main Morpheus Context.
      protected java.lang.String name
      The name of the plugin
      protected java.util.List<Permission> permissions
      The list of permissions this plugin provides that may affect display of other UIExtensionProvider based providers.
      protected java.util.Map<java.lang.String,​PluginProvider> pluginProviders
      All registered plugin providers by provider code.
      protected Renderer<?> renderer
      The default renderer to be used for UI based plugins.
      protected java.util.List<OptionType> settings
      The list of settings for the plugin
      protected java.lang.String sourceCodeLocationUrl
      Source code location for this plugin
      protected java.lang.String version
      The current version of the plugin
      protected java.lang.String websiteUrl
      An optional URL to the website for the maintainer of the plugin
    • Constructor Summary

      Constructors 
      Constructor Description
      Plugin()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAuthor()
      Returns the author of who created / maintains this current plugin implementation.
      java.lang.ClassLoader getClassLoader()
      Returns the plugin specific class loader to be used for all class resolution within the plugin.
      java.util.List<PluginController> getControllers()
      Returns a list of all PluginController classes registered with this plugin
      java.lang.String getDescription()
      Gets the current description of the plugin.
      java.lang.String getFileName()
      Returns the file name of the jar the plugin is coming from.
      java.lang.String getIssueTrackerUrl()
      Gets the issue tracker url for the plugin.
      java.lang.String getName()
      Gets the name of the current plugin.
      java.util.List<Permission> getPermissions()
      Returns a list of custom permissions defined by the plugin that may affect the display of various UI Providers
      PluginManager getPluginManager()
      All plugins reside in a Plugin Manager responsible for loading all plugins.
      PluginProvider getProviderByCode​(java.lang.String code)
      Grabs an instance of a plugin provider loaded by a unique code as defined by the implementation of the provider
      java.util.Collection<PluginProvider> getProviders()
      Provides a collection of all PluginProvider classes that this plugin provides in Singleton Form.
      java.util.Collection<PluginProvider> getProvidersByType​(java.lang.Class clazz)
      Returns a Collection of all Providers provided by this Plugin based on Type class.
      protected Renderer<?> getRenderer()
      Get the template renderer for this plugin.
      java.util.List<OptionType> getSettings()
      Returns a list of OptionType settings for this plugin.
      java.lang.String getSourceCodeLocationUrl()
      Returns the SCM Repository URL for where the source code is maintained (i.e.
      java.lang.String getVersion()
      Gets the current version of the plugin.
      java.lang.String getWebsiteUrl()
      The Website associated with the plugin.
      boolean hasCustomRender()
      A conditional flag to check if this plugin registers a custom renderer outside of the default one provided by the PluginManager.
      void registerProvider​(PluginProvider provider)
      Registers an instance (typically a singleton) of a PluginProvider for registration with Morpheus
      void setAuthor​(java.lang.String author)
      Sets the author of who created / maintains this plugin implementation.
      void setClassLoader​(java.lang.ClassLoader classLoader)
      Sets the plugin specific class loader for reference by provider classes or other areas of the plugin.
      void setControllers​(java.util.List<PluginController> controllers)
      Sets the controllers for custom url endpoints/view rendering that are provided with this plugin.
      void setDescription​(java.lang.String description)
      Sets teh current description of the plugin implementation.
      void setFileName​(java.lang.String fileName)
      Sets the file name of the jar the plugin was instantiated from for reference.
      void setIssueTrackerUrl​(java.lang.String issueTrackerUrl)
      Sets the issue tracker url where the consumers of the plugin can report issues or suggestions to the maintainer.
      void setName​(java.lang.String name)
      Sets the plugin name.
      void setPermissions​(java.util.List<Permission> permissions)
      Typically called during the initialize method of the plugin.
      void setRenderer​(Renderer<?> renderer)
      Set the template renderer for ths plugin.
      void setSettings​(java.util.List<OptionType> settings)
      Sets the setting types for this plugin.
      void setSourceCodeLocationUrl​(java.lang.String sourceCodeLocationUrl)
      Sets the SCM Repository URL for the location to which the source code for this plugin is maintained.
      void setVersion​(java.lang.String version)
      Sets the current version of the plugin implementation.
      void setWebsiteUrl​(java.lang.String websiteUrl)
      Sets the web url of the plugin.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pluginProviders

        protected java.util.Map<java.lang.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 java.util.List<PluginController> controllers
        The list of custom controllers registered into the plugin
      • settings

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

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

        protected java.lang.String name
        The name of the plugin
      • fileName

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

        protected java.lang.String version
        The current version of the plugin
      • author

        protected java.lang.String author
        The author who created the plugin
      • description

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

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

        protected java.lang.String sourceCodeLocationUrl
        Source code location for this plugin
      • issueTrackerUrl

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

      • Plugin

        public Plugin()
    • Method Detail

      • setSettings

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

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

        public void setControllers​(java.util.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 java.util.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 java.util.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​(java.lang.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 java.util.Collection<PluginProvider> getProvidersByType​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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 java.lang.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​(java.lang.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​(java.lang.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 java.lang.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 java.util.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​(java.util.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.