Package com.morpheusdata.core
Class Plugin
java.lang.Object
com.morpheusdata.core.Plugin
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionprotected String
The author who created the pluginprotected List<PluginController>
The list of custom controllers registered into the pluginprotected String
A simple description of what the plugin providesprotected String
The fileName of the jar the plugin is packaged in.protected String
URL for reporting issues with the plugin (if applicable).protected MorpheusContext
Reference to the main Morpheus Context.protected String
The name of the pluginprotected List<Permission>
The list of permissions this plugin provides that may affect display of otherUIExtensionProvider
based providers.protected Map<String,
PluginProvider> All registered plugin providers by provider code.protected Renderer<?>
The default renderer to be used for UI based plugins.protected List<OptionType>
The list of settings for the pluginprotected String
Source code location for this pluginprotected String
The current version of the pluginprotected String
An optional URL to the website for the maintainer of the plugin -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkForProviderConflict
(PluginProvider provider) Returns the author of who created / maintains this current plugin implementation.Returns the plugin specific class loader to be used for all class resolution within the plugin.Returns a list of allPluginController
classes registered with this pluginGets the current description of the plugin.Returns the file name of the jar the plugin is coming from.Gets the issue tracker url for the plugin.getName()
Gets the name of the current plugin.Returns a list of custom permissions defined by the plugin that may affect the display of various UI ProvidersAll plugins reside in a Plugin Manager responsible for loading all plugins.getProviderByCode
(String code) Grabs an instance of a plugin provider loaded by a unique code as defined by the implementation of the providerProvides a collection of allPluginProvider
classes that this plugin provides in Singleton Form.getProvidersByType
(Class clazz) Returns a Collection of all Providers provided by this Plugin based on Type class.protected Renderer<?>
Get the template renderer for this plugin.Returns a list ofOptionType
settings for this plugin.Returns the SCM Repository URL for where the source code is maintained (i.e.Gets the current version of the plugin.The Website associated with the plugin.boolean
A conditional flag to check if this plugin registers a custom renderer outside of the default one provided by thePluginManager
.void
registerProvider
(PluginProvider provider) Registers an instance (typically a singleton) of a PluginProvider for registration with Morpheusvoid
registerProviders
(PluginProvider... providers) Registers an instance (typically a singleton) of many PluginProviders for registration with Morpheusvoid
registerProviders
(Collection<PluginProvider> providers) Registers an instance (typically a singleton) of many PluginProviders for registration with Morpheusvoid
Sets the author of who created / maintains this plugin implementation.void
setClassLoader
(ClassLoader classLoader) Sets the plugin specific class loader for reference by provider classes or other areas of the plugin.void
setControllers
(List<PluginController> controllers) Sets the controllers for custom url endpoints/view rendering that are provided with this plugin.void
setDescription
(String description) Sets teh current description of the plugin implementation.void
setFileName
(String fileName) Sets the file name of the jar the plugin was instantiated from for reference.void
setIssueTrackerUrl
(String issueTrackerUrl) Sets the issue tracker url where the consumers of the plugin can report issues or suggestions to the maintainer.void
Sets the plugin name.void
setPermissions
(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
(List<OptionType> settings) Sets the setting types for this plugin.void
setSourceCodeLocationUrl
(String sourceCodeLocationUrl) Sets the SCM Repository URL for the location to which the source code for this plugin is maintained.void
setVersion
(String version) Sets the current version of the plugin implementation.void
setWebsiteUrl
(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
Methods inherited from interface com.morpheusdata.core.PluginInterface
getCode, initialize, onDestroy
-
Field Details
-
pluginProviders
All registered plugin providers by provider code. -
morpheus
Reference to the main Morpheus Context. -
renderer
The default renderer to be used for UI based plugins. Typically Handlebars (server side). -
controllers
The list of custom controllers registered into the plugin -
settings
The list of settings for the plugin -
permissions
The list of permissions this plugin provides that may affect display of otherUIExtensionProvider
based providers. -
name
The name of the plugin -
fileName
The fileName of the jar the plugin is packaged in. -
version
The current version of the plugin -
author
The author who created the plugin -
description
A simple description of what the plugin provides -
websiteUrl
An optional URL to the website for the maintainer of the plugin -
sourceCodeLocationUrl
Source code location for this plugin -
issueTrackerUrl
URL for reporting issues with the plugin (if applicable).
-
-
Constructor Details
-
Plugin
public Plugin()
-
-
Method Details
-
setSettings
Sets the setting types for this plugin.- Parameters:
settings
- a list of theOptionType
settings for this plugin.
-
getSettings
Returns a list ofOptionType
settings for this plugin.- Returns:
- this list of settings
-
setControllers
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
Returns a list of allPluginController
classes registered with this plugin- Returns:
- the list of controllers
-
setRenderer
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 thePluginManager
.- Returns:
- whether or not the plugin has a custom renderer.
-
getRenderer
Get the template renderer for this plugin.- Returns:
- the renderer for the plugin
-
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
Provides a collection of allPluginProvider
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
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
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 allPluginProvider
classes implement.- Returns:
- A collection of matched providers by type. If no results are found an empty ArrayList is returned.
-
getName
Gets the name of the current plugin. This is useful for human readable display- Specified by:
getName
in interfacePluginInterface
- Returns:
- the name of the plugin
-
setName
Sets the plugin name. This can be done on the extended class to describe the plugin- Specified by:
setName
in interfacePluginInterface
- Parameters:
name
- the desired name of the plugin implementation
-
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 interfacePluginInterface
- Returns:
- the file name of the jar the plugin resides in.
-
setFileName
Sets the file name of the jar the plugin was instantiated from for reference.- Specified by:
setFileName
in interfacePluginInterface
- Parameters:
fileName
- the file name of the jar the plugin was loaded from
-
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 interfacePluginInterface
- Returns:
- the current plugin version
-
setVersion
Sets the current version of the plugin implementation.- Specified by:
setVersion
in interfacePluginInterface
- Parameters:
version
- the desired version assignment of the plugin
-
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 interfacePluginInterface
- Returns:
- the description of what the plugin provides.
-
setDescription
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 interfacePluginInterface
- Parameters:
description
- the desired description of the plugin.
-
getAuthor
Returns the author of who created / maintains this current plugin implementation.- Specified by:
getAuthor
in interfacePluginInterface
- Returns:
- the authors name
-
setAuthor
Sets the author of who created / maintains this plugin implementation.- Specified by:
setAuthor
in interfacePluginInterface
- Parameters:
author
- the name / username of the author
-
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 interfacePluginInterface
- Returns:
- the plugins web url
-
setWebsiteUrl
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 interfacePluginInterface
- Parameters:
websiteUrl
- the desired url. (Include protocol such as http:// or https://)
-
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 interfacePluginInterface
- Returns:
- the SCM Repository URL
-
setSourceCodeLocationUrl
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 interfacePluginInterface
- Parameters:
sourceCodeLocationUrl
- the desired SCM Url
-
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 interfacePluginInterface
- Returns:
- the issue tracker url (i.e. a JIRA or github issues link)
-
setIssueTrackerUrl
Sets the issue tracker url where the consumers of the plugin can report issues or suggestions to the maintainer.- Specified by:
setIssueTrackerUrl
in interfacePluginInterface
- Parameters:
issueTrackerUrl
- the desired web url for where a user can report issues with the plugin.
-
setClassLoader
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 thePluginManager
during instantiation.- Parameters:
classLoader
- the class loader representing the jar the plugin was loaded from
-
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
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
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
Registers an instance (typically a singleton) of a PluginProvider for registration with Morpheus- Parameters:
provider
- the instance of the plugin provider being registered.
-
registerProviders
Registers an instance (typically a singleton) of many PluginProviders for registration with Morpheus- Parameters:
providers
- the instances of the plugin providers being registered.
-
registerProviders
Registers an instance (typically a singleton) of many PluginProviders for registration with Morpheus- Parameters:
providers
- the instances of the plugin providers being registered.
-
checkForProviderConflict
-