This sample demonstrates how to write the contents of a roster to a log file. This sample uses the sample RosterHelper(VWSession, Logger) class to display roster information. Run the sample by entering a command similar to the following:
java RosterSample username password <server name>:<port number>/<router instance name> [output_filename]
Note For a detailed explanation of the command line, see the Run the sample application section of the Run the Unmodified Samples topic.
The RosterSample class contains two methods: the main method main(String args[]) and the constructor method RosterSample(VWSession vwSession, Logger logger).
The main method uses common techniques for validating and defaulting argument values. The default value for the log output file is RosterSample.out. The main method constructs and passes vwSession and Logger objects to the sample constructor. Main() handles the login and logoff for the session with the login() and logoff() methods of the sample SessionHelper class. It provides workflow logging with an instance of the sample Logger class. The main method passes the session and the logger to the sample's class constructor.
The constructor RosterSample(VWSession vwSession, Logger logger) performs common exception handling and invokes the rosterHelper.displayRosterContents() method with the following two lines of code:
// Create the roster helper object.
rosterHelper = new RosterHelper(vwSession, logger);
// Display the contents of the roster.
rosterHelper.displayRosterContents();