Setting Up for CORBA API

 

The classes needed for CORBA client to access the WebNMS SNMP API are provided in the com.adventnet.snmp.corba package. The CLASSPATH should be set to AdventNetSnmp.jar, AdventNetLogging.jar, and AdventNetCorba.jar.

 

The CORBA interfaces and the implementation classes internally use the high-level API. Therefore, the users need not bother about the underlying SNMP communication that is wrapped in the CORBA classes.

 

The Java files of the CORBA package are generated from corba.idl, available with the WebNMS SNMP package, using Sun's idltojava compiler. The idltojava compiler generates the respective stubs and skeletons for each interface declared in the corba.idl file. These stubs and skeletons are used by the server as well as the client-side code.

 

For example, for the SnmpTarget interface in the corba.idl file, the following Java files are generated.

The steps involved in developing management applications using CORBA interfaces and implementation classes are:

  1. Run the Java IDL name server.

tnameserv -ORBInitialPort serverport

 

The above command starts the name server listening at the specified port. If the server port is not specified, the name server starts at the default port 900.

 

tnameserv -ORBInitialPort 8000

 

The above command starts the name server listening at port 8000.

  1. Start the WebNMS CORBA server.

java com.adventnet.snmp.corba.server

 

The above command binds the WebNMS CORBA server with the name server at the default port 900. If the WebNMS CORBA server starts successfully then the following message is displayed.

 

"Factory is ready

Server is ready

Ready to receive client requests ... "

  1. To start the CORBA server at different port, type the following command.

java com.adventnet.snmp.corba.server -ORBInitialPort nameserverport

e.g java com.adventnet.snmp.corba.server -ORBInitialPort 8000

 

The server class does the following on startup.

 

//initialize the ORB

org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

//Create the "Factory"

com.adventnet.snmp.corba.SnmpFactory factory = new com.adventnet.snmp.corba.SnmpFactoryImpl ("WebNMSSnmpFactory");

//Export to the ORB the newly created object

orb.connect(factory);

//Use Naming Service and bind the Object Reference in Naming

 

The SnmpFactory interface has several methods, such as createRequestServer, createTable, createTarget, etc., and the corresponding destroy methods that are used by the client applications to create and destroy the respective instances after getting the remote object handle.

 

The client applications need to do the following.

  1. Initialize the ORB.

org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

  1. Use naming service.

org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

  1. Narrow the object reference.

NamingContext ncRef = NamingContextHelper.narrow(objRef);

  1. Bind the object reference in naming.

NameComponent nc = new NameComponent("WebNMSSnmpFactory", "");

NameComponent[] path = {nc};

  1. Bind to the factory object.

com.adventnet.snmp.corba.SnmpFactory factory =

com.adventnet.snmp.corba.SnmpFactoryHelper.narrow(ncRef.resolve(path));

  1. Get a target object.

com.adventnet.snmp.corba.SnmpTarget target = factory.createTarget();

 

The above code creates an SnmpTargetImpl instance that internally calls the SnmpTarget bean. After this, the target instance can be used in the same way as in the high-level API.

 

note.jpg

Note: Certain operations, such as target.loadMibs("../RFC1213-MIB"), are relative to the server path because the objects are remotely executed.



Copyright © 2012, ZOHO Corp. All Rights Reserved.