Management plugin examples
The source code for two example management integration API plugin classes is provided.
- The
JMXManagementPluginclass returns data requested by an external application. Communication between the plugin API and the external application uses the JMX protocol. - The
AWSManagementPlugindoes not return data, but instead performs a repeated action. The plugin publishes PolicyCenter metrics to AWS (Amazon Web Services) Cloudwatch. The publishing operation is scheduled to repeat intermittently. External applications can access the published metrics as desired.
Java source code for the example plugins can be found in the java-examples.zip file, which is located in the PolicyCenter directory.
Extract the files in the archive file. The source files for the example plugins will be located in the following PolicyCenter directory.
examples/src/examples/pl/plugins/managementInitialization methods
The ManagementPlugin interface provides methods to start and stop the communication channel
used to receive and respond to API calls.
function start()
function stop()
The JMXManagementPlugin example plugin implements these methods to set up and close the JMX
communication channel it uses to receive and respond to API requests. The AWSManagementPlugin
start method gains access to AWS Cloudwatch and schedules a daemon thread to intermittently
perform the metric publishing operation. Its stop method kills the thread.
Methods to register and unregister management beans
The ManagementPlugin interface also defines methods that can set up a repository of the data
resources that the plugin can return.
function registerBean(bean : gw.plugin.management.GWMBean)
function unregisterBean(bean : gw.plugin.management.GWMBean)
function unregisterBeanByNamePrefix(prefix : String)
The GWMBean arguments reference Guidewire management beans which are PolicyCenter resources, such as current users, running batch processes, and configuration
parameters. Each GWMBean contains information about itself, including its name, description,
attribute values, notifications, and operations it can perform.
The JMXManagementPlugin methods register and unregister the received bean argument. The
AWSManagementPlugin does not need a data repository, so its example methods log notification
messages when they are called.
Notification method
The ManagementPlugin interface defines a method to have a particular GWMBean
generate a notification. A notification can signal that its state has changed or an event or problem has
occurred.
function sendNotification(notification : Notification)
The notification argument references a Notification object containing
information, including the name of the relevant GWMBean. The Gosu Notification
class is similar to the javax.management.Notification class. The plugin can utilize the Java
Notification framework if desired, but it is not mandatory.
The JMXManagementPlugin
sendNotification method demonstrates how to utilize the Java Notification
framework to have the relevant GWMBean send a notification. If the referenced
GWMBean exists, the properties of the method’s notification argument are passed to the
javax.management.Notification constructor. The AWSManagementPlugin does not
support notifications and so its implementation of the sendNotification method is empty.
Authorization callback method
The ManagementPlugin interface defines a method to receive a
ManagementAuthorizationCallbackHandler object. The referenced callback handler implements a
method called hasManagementPermission. The handler’s
hasManagementPermission method is called to authenticate whether the current user has the
required management permission to perform the requested operation.
function setAuthorizationCallbackHandler(handler : ManagementAuthorizationCallbackHandler)
The JMXManagementPlugin implementation saves the handler argument in a local variable and
passes it to the JMXRMIConnector constructor when the JMX communication channel is create. The
callback method is ultimately referenced by the JMXAuthenticatorImpl class which calls its
hasManagementPermission method to authenticate the user. For details concerning the
JMXAuthenticator class and related management classes and methods, refer to the
javax.management.remote documentation.
