Customizing the PolicyObjectUI - Example



Feature Overview

The word 'policy', in general, refers to a plan of action. Here, in Web NMS context, it refers to executing a task or set of tasks at a specified time based on a set of specified conditions. Policies are tasks that are executed by Web NMS at a system level, at a specified point of time. In Network Management, policies are used to control a variety of network activities like automated backups, routing & prioritization of network traffic, bandwidth allocation, cleaning up database tables, deleting failed nodes, etc.

This policy framework enables scalable administration of the Web NMS server and the network elements managed by it. The primary goal of the policy engine is to enable administration of complex functions easily. In Web NMS, policies can be used to customize the behaviour of the NMS and to provide a framework for adding policies for different network elements.

Web NMS policies can be broadly classified into two categories :

For more details, refer to the following section of our documentation : Developer Guide --> Policy Framework

Example Overview

Example name : Customizing the PolicyObject UI
Related files : ExamplePolicyCustomizer.java and ExamplePolicy.java
Location : <Web NMS Home>/examples/policy

By default a UI has been provided for viewing the PolicyObject properties. If you want to have your own UI, you can plugin your own UI forms. This example explains how this can be done using the PolicyObjectCustomizer.

How to plugin your own property form ?

Follow the steps detailed below to define your own property form :

You need to write two java files, one to define your own customizer class and the other to invoke the customizer class. Here, in this example, the ExamplePolicyCustomizer.java file is used to construct a GUI and pass it as a Window Object to the Policy  Client. The ExamplePolicy.java is for invoking the customizer class.

Code Snippet

The following code snippets would help you in defining your own property forms :

The init (Properties p ) method will be called first, before instantiating the customizer to pass the required PolicyObject properties.
 
public void init(Properties p)

 {
  this.prop = p;
 } 

The getCustomizer() method actually returns a window to be displayed for the PolicyObject. You can construct a GUI as per your requirement and can pass your GUI as a Window Object to the PolicyClient.  Then PolicyClient will take care of displaying the Window for the corresponding PolicyObject.
 
public Window getCustomizer()
 {
  return getGUI();
 } 

Once you complete all the modifications in the property form, it is required to fire the PropertyChanged Event in addition to disposing the customizer Window, to intimate the PolicyClient that all modification has been done. If  you do not want to save the changes, simply dispose the window.
 
public void actionPerformed(ActionEvent ae)
 {
  if(ae.getActionCommand().equals("Sumbit"))
  {
   prop.put("message",textarea.getText());
   dialog.dispose();
   this.firePropertyChange();
  }

Once the PolicyClient listens to the PropertyChanged Event, it get backs the modified properties by the method getProperties()
 
public Properties getProperties()
 {
  return this.prop;
 } 

User written customizer class can be mentioned in the method getPolicyObjectCustomizer() of the corresponding PolicyObject.  This method  is defined in the ExamplePolicy.java file, which is used to invoke the ExamplePolicyCustomizer class.
 
public String getPolicyObjectCustomizer()
{
        return test.policy.policyui.ExamplePolicyCustomizer;

Using the Example

The steps given below will help you in integrating this example with Web NMS. If any of the steps given below are not followed properly, then the example might not function in a desired manner.

The user defined file is compiled and the class files are placed under the directories <Web NMS Home>/ classes/test/policy/policies and <Web NMS Home>/classes/test/policy/policyui. Then the customizer class file is bundled into the NmsClientClasses.jar file. The ExamplePolicy class name should be entered into the Policy.conf file, to invoke the user defined policy.

The following steps are to be followed to use the user defined Policy  from the policies of Web NMS Client.

Classpath Settings

Set the class path as set classpath= <Web NMS Home >/classes, <Web NMS Home>/classes/NmsClientClasses.jar for compiling the ExamplePolicyCustomizer.java file and ExamplePolicy.java file.

Compiling and Bundling with Web NMS

  • Compile the java files from <Web NMS Home>/examples/policy directory using the following command
  • Invoking the Example

    Sample Output

    The image shown below, is the user-defined event details form invoked from the events panel of Web NMS Client.


    Copyright © 1996-2002, AdventNet Inc. All Rights Reserved.