Creating Plugins
Required Fields and Methods
Only a single field or two methods are required to be defined to create a custom plugin. The field depends on whether theAbstractPlugin
class is inherited in the custom plugin.Inheriting AbstractPlugin
When the custom plugin extends the AbstractPlugin class, a single field named
pluginPersistenceService
needs to be defined. This service is used in the default implementation of the poll
method
by updating jobs, nodes, and virtual machines retrieved with the custom implementations of getJobs
, getNodes
, and
getVirtualMachines
. If one or more of these methods are not defined, they will simply not be used.Declaring the required field is achieved in different ways for Java and Groovy respectively.Java
public IPluginPersistenceService getPluginPersistenceService()
public void setPluginPersistenceService(IPluginPersistenceService pluginPersistenceService)
IPluginPersistenceService pluginPersistenceService
(both methods will be inserted by groovy dynamically for this field)
Not Inheriting AbstractPlugin
When the AbstractPlugin is not used, only a single field is required - id
. Again, this is achieved in two different ways
depending on the language used.Java
public String getId()
public void setId(String id)
String id
(both methods will be inserted by groovy dynamically for this field)
Using Services
To use the built-in services, declare a variable with the correct name as a property in the plugin class.Using Services in Java
package example;import com.ace.mws.plugins.services.*;class ExamplePlugin { IPluginControlService pluginControlService; IPluginDatabaseService pluginDatabaseService; IPluginConfigurationService pluginConfigurationService; public List<?> getNodes() { // Use service… pluginControlService.stop("pluginId"); } }
Using Services in Groovy
package example;import com.ace.mws.plugins.services.*;class ExamplePlugin { def pluginControlService def pluginDatabaseService def pluginConfigurationService public List<?> getNodes() { // Use service… pluginControlService.stop("pluginId") } }
Creating Custom Web Services
Add any public method with a single Map argument that returns a list, map, or complex object. This can then be called as a web service.The return value of the method is translated directly to the JSON returned to the caller. For this reason, a simple type such as String, Integer, or Double may not be returned. It is recommended to use a list of a single element if a simple type is desired to be returned.