Building a K2 Client

RMI administrative connections

Administrators connect to a K2 server through a special kind of RMI connection. As for socket connections, the K2 jar file contains a class, called RMIAdminClient, whose main method provides a command-line interface to a K2 administrative connection. To run it, you must first have the K2 jar file in your CLASSPATH. Then execute the following command:

java K2.system.clients.RMIAdminClient -r RMIname -l username:password

where RMIname is the name that the K2 server registered with the RMI registry, and username and password are valid K2 credentials that have been set up previously. Once RMIAdminClient has been started, it prompts for a command. Entering help will show a list of available commands. These currently include commands to show information about client connections and data source connections, close client connections, and shut down the server. Aditional capabilities are planned.

If you want to build your own administrative client, you need to manage the connection yourself. RMI administrative connections implement the K2 interface RMIAdminConnectionI. To get a new connection, first use the RMI Naming service to look up the K2 server. This will return an object that implements RMIConnectionFactoryI. You can then use the getAdminConnection method to get a connection object. You'll have to pass a new Login object to getAdminConnection, using the same credentials you would use to connect using RMIAdminClient.

Once you have the connection object, you can perform all the same actions that RMIAdminClient can. Be sure to call the close method to close the connection before exiting your program.

[Tech Docs Index]