FileDocCategorySizeDatePackage
SchedulerClient.javaAPI DocExample5457Fri Jun 02 15:59:02 BST 2000None

SchedulerClient

public class SchedulerClient extends Object
SchedulerClient is an XML-RPC client that makes XML-RPC requests to Scheduler.
author
Brett McLaughlin
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public static voidaddEvents(helma.xmlrpc.XmlRpcClient client)

Add events to the Scheduler.

param
client XmlRpcClient to connect to


        System.out.println("\nAdding events...\n");

        // Parameters for events
        Vector params = new Vector();

        // Add an event for next month
        params.addElement("Proofread final draft");

        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, 1);
        params.addElement(cal.getTime());

        // Add the event
        if (((Boolean)client.execute("scheduler.addEvent", params))
                            .booleanValue()) {
            System.out.println("Event added.");
        } else {
            System.out.println("Could not add event.");
        }

        // Add an event for tomorrow
        params.clear();
        params.addElement("Submit final draft");

        cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, 1);
        params.addElement(cal.getTime());

        // Add the event
        if (((Boolean)client.execute("scheduler.addEvent", params))
                            .booleanValue()) {
            System.out.println("Event added.");
        } else {
            System.out.println("Could not add event.");
        }

    
public static voidlistEvents(helma.xmlrpc.XmlRpcClient client)

List the events currently in the Scheduler.

param
client XmlRpcClient to connect to


        System.out.println("\nListing events...\n");

        // Get the events in the scheduler
        Vector params = new Vector();
        Vector events =
            (Vector)client.execute("scheduler.getListOfEvents", params);
        for (int i=0; i<events.size(); i++) {
            System.out.println((String)events.elementAt(i));
        }
    
public static voidmain(java.lang.String[] args)

Static entry point for the demo.

        if (args.length < 1) {
            System.out.println(
                "Usage: java SchedulerClient [configFile]");
            System.exit(-1);
        }


        try {
            // Load Configuration File
            XmlRpcConfiguration config =
                new XmlRpcConfiguration(args[0]);

            // Use the Apache Xerces SAX Parser Implementation
            XmlRpc.setDriver(config.getDriverClass());

            // Connect to server
            XmlRpcClient client =
                new XmlRpcClient("http://" +
                                 config.getHostname() + ":" +
                                 config.getPortNumber());

            // Add some events
            addEvents(client);

            // List events
            listEvents(client);

        } catch (Exception e) {
            System.out.println(e.getMessage());
        }