Java Docs

 

com.adventnet.snmp.scripting 
Interface ScriptHandler


public interface ScriptHandler

ScriptHandler interface is the bridge/pipe between ManageEngine MibBrowser and custom class.
Using ScriptHandler, user can execute their own actions or other libraries outside of ManageEngine Mibbrowser.
"Customized Class" should implements SctiptHandler Interface to executes the own set of classes in Mibbrowser.  

1. Implement Custom class

  • Custom class  implements ScriptHandler and should defined in com.adventnet.snmp.scripting package.
  • Customized class can be saved in any location.

     E.g : SampleCustomClass.java

package com.adventnet.snmp.scripting;
import com.adventnet.snmp.snmp2.SnmpPDU;

class CustomTrapForwarder implements ScriptHandler 
{
    SnmpPDU pdu;
	
    public CustomTrapForwarder(SnmpPDU tpdu)
    {
	
	//Should define a Parameterized Contructor with parameter type SnmpPDU

        this.pdu = tpdu;//receives the SNMP pdu	

        System.out.println("Commmunity Value : "+pdu.getCommunity());

    }

    public void execute() 
    {
        
	// executes the set of codes which defined in this method

    }

    public void setFilePath(String path)
    {

	// set a file location to execute any script files

    }
}
2. Compile the Custom / User defined classes

     Compile the java file for Windows in any of the following ways :

           Open the Command Prompt, change the directory to <Product_Home> 
           Run the setclasspath.bat, which is used to set the required jars in classpath 
           Compile java file, javac -d classes  "<java file location>\SampleCustomClass.java"

                                                (or)

           Open the Command Prompt, go to custom java file location
           Set the required classpath, ( e.g. set classpath=<product_home>\jars\AdventNetScript.jar;<product_home>\jars\AdventNetSnmp.jar )
           Compile java file, javac -d <Product_Home>\classes SampleCustomClass.java

     Compile the java file for Linux :

           Open the Terminal, change the directory to <Product_Home> 
           Run the setclasspath.sh, which is used to set the required jars in classpath (. <SPACE> setclasspath.sh) 
           Compile java file, javac -d classes  "<java file location>\SampleCustomClass.java"

                                                (or)

           Open the Terminal, go to custom java file location
           Set the required classpath, ( e.g. export classpath=<product_home>/jars/AdventNetScript.jar:<product_home>/jars/AdventNetSnmp.jar:$CLASSPATH)
           Compile java file, javac -d <Product_Home>/classes SampleCustomClass.java

Note : Compile your java file in JDK 1.6.0

Now the compiled customized classes will be present in <ProductHome>\classes directory.

Download the sample code for custom class CustomTrapForwarder.java
 


Method Summary
 void execute () 
          This is method execute the customized code that defined by the user.
 void setFilePath(java.lang.String path) 
           This is method used to set the location for the file.

 

Method Detail

execute

void execute()
Method to execute the customized code that defined by the user.
 

setFilePath

void setFilePath(java.lang.String path)
Parameters:
path - set the location for the file