Distributed API

 

The Remote Method Invocation (RMI) provides the mechanism by which the server and the client communicate and pass information back and forth allowing the remote clients to perform CLI operations. The advantage of using the RMI APIs is to allow a server to perform the CLI functions, while the leaner clients only makes the RMI calls to the server. For example, the server can run on the web server, while the application makes RMI calls to the server to perform CLI functions.

 

 

The figure illustrates the use of RMI from a Java application at the client end. In this architecture, the client uses the server to perform CLI operations and the communication with the server is via RMI calls over TCP socket while communication with the device is through the transport provider framework.

 

The sample application provided in the examples directory shows the use of the WebNMS CLI API by doing RMI calls to perform CLI operations. Here we briefly describe the basic operations, which is common for all RMI interfaces. The RMI server can be started as a standalone server or as a part of another Java application, e.g. a web server. The main interface for all the RMI operations is the

 

com.adventnet.CLI.rmi.CLIFactoryinterface. This interface is implemented by the com.adventnet.CLI.rmi.CLIFactoryImpl class, which can be started from the command line or from another Java application. When started from the command line, this class is published as WebNMS CLIFactory and registered with the RMI Registry. When started from another Java application, you have to publish the factory interface to allow remote access.

 

CLIFactoryImpl class implements the CLIFactory interface for creating the remote server objects from an RMI client to the RMI server. The server objects are created by calling createCLISession()method and the references are passed back to the client. CLIFactory interface has methods for creating instance of classes for CLI services on the server. These methods return RMI interfaces for getting access to the services provided by the CLI service classes.

 

String hostname = "myserver";

CLIFactory factory = (CLIFactory)Naming.lookup( "rmi://"+ hostname + "/AdventnetCLIFactory" );

TelnetProtocolOptionsImpl tpoi = new TelnetProtocolOptionsImpl(); CLISession session = factory.createCLISession(tpoi,false);

session.open();

 

Once the com.adventnet.CLI.rmi.CLIFactory interface is obtained, the RMI client can use its methods similar to a local instance of CLISession. The method signatures between the corresponding Beans and RMI interfaces are mostly identical.

 

How to start the CLI Factory

 

The classes needed for accessing RMI client to the WebNMS CLI API are provided in the com.adventnet.CLI.rmi package. Following steps explains how to start CLI Factory:

Note:

  • The rmiregistry is located at the IP address of whatever machine it has started, but it must also be listening at a port. If you invoke the rmiregistry as above, with no argument, the registry’s port will default to 1099. If you want it to be at some other port, you add an argument on the command line to specify the port. For example, the port is located at 2005, so the rmiregistry should be started like this under 32-bit Windows:
    start rmiregistry 2005
    for Windows
    rmiregistry 2005 &
    for UNIX

  • With JDK1.2 there are some issues to be taken care for RMI. This has to do with the new security model. One way of specifying permissions is with policy files. For details please refer the Known Issues

 

Please refer Java documentation for complete details.

Related Topics

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.