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
FieldsModifier and TypeFieldDescriptionprotected StringThe author who created the pluginprotected List<PluginController>The list of custom controllers registered into the pluginprotected StringA simple description of what the plugin providesprotected StringThe fileName of the jar the plugin is packaged in.protected StringURL for reporting issues with the plugin (if applicable).protected MorpheusContextReference to the main Morpheus Context.protected StringThe name of the pluginprotected List<Permission>The list of permissions this plugin provides that may affect display of otherUIExtensionProviderbased 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 StringSource code location for this pluginprotected StringThe current version of the pluginprotected StringAn optional URL to the website for the maintainer of the plugin -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckForProviderConflict(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 allPluginControllerclasses 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 allPluginProviderclasses 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 ofOptionTypesettings 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.booleanA conditional flag to check if this plugin registers a custom renderer outside of the default one provided by thePluginManager.voidregisterProvider(PluginProvider provider) Registers an instance (typically a singleton) of a PluginProvider for registration with MorpheusvoidregisterProviders(PluginProvider... providers) Registers an instance (typically a singleton) of many PluginProviders for registration with MorpheusvoidregisterProviders(Collection<PluginProvider> providers) Registers an instance (typically a singleton) of many PluginProviders for registration with MorpheusvoidSets the author of who created / maintains this plugin implementation.voidsetClassLoader(ClassLoader classLoader) Sets the plugin specific class loader for reference by provider classes or other areas of the plugin.voidsetControllers(List<PluginController> controllers) Sets the controllers for custom url endpoints/view rendering that are provided with this plugin.voidsetDescription(String description) Sets teh current description of the plugin implementation.voidsetFileName(String fileName) Sets the file name of the jar the plugin was instantiated from for reference.voidsetIssueTrackerUrl(String issueTrackerUrl) Sets the issue tracker url where the consumers of the plugin can report issues or suggestions to the maintainer.voidSets the plugin name.voidsetPermissions(List<Permission> permissions) Typically called during the initialize method of the plugin.voidsetRenderer(Renderer<?> renderer) Set the template renderer for ths plugin.voidsetSettings(List<OptionType> settings) Sets the setting types for this plugin.voidsetSourceCodeLocationUrl(String sourceCodeLocationUrl) Sets the SCM Repository URL for the location to which the source code for this plugin is maintained.voidsetVersion(String version) Sets the current version of the plugin implementation.voidsetWebsiteUrl(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, waitMethods 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 otherUIExtensionProviderbased 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 theOptionTypesettings for this plugin.
-
getSettings
Returns a list ofOptionTypesettings 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 allPluginControllerclasses 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 allPluginProviderclasses 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 allPluginProviderclasses 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:
getNamein 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:
setNamein 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:
getFileNamein 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:
setFileNamein 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:
getVersionin interfacePluginInterface- Returns:
- the current plugin version
-
setVersion
Sets the current version of the plugin implementation.- Specified by:
setVersionin 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:
getDescriptionin 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:
setDescriptionin interfacePluginInterface- Parameters:
description- the desired description of the plugin.
-
getAuthor
Returns the author of who created / maintains this current plugin implementation.- Specified by:
getAuthorin interfacePluginInterface- Returns:
- the authors name
-
setAuthor
Sets the author of who created / maintains this plugin implementation.- Specified by:
setAuthorin 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:
getWebsiteUrlin 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:
setWebsiteUrlin 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:
getSourceCodeLocationUrlin 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:
setSourceCodeLocationUrlin 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:
getIssueTrackerUrlin 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:
setIssueTrackerUrlin 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 thePluginManagerduring 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
-