public static void main(String[] args) throws Exception { if(args.length != 3) { System.out.println("Usage: java TaskHistoryMonitor " + "<url> <username> <password>"); return; } ServiceInstance si = new ServiceInstance( new URL(args[0]), args[1], args[2], true); TaskManager taskMgr = si.getTaskManager(); if(taskMgr!=null) { Folder root = si.getRootFolder(); TaskFilterSpec tfs = createTaskFilterSpec(root); TaskHistoryCollector thc = taskMgr.createCollectorForTasks(tfs); // Note: 10 <= pagesize <= 62 thc.setCollectorPageSize(15); System.out.println("Tasks in latestPage:"); TaskInfo[] tis = thc.getLatestPage(); printTaskInfos(tis); System.out.println("\nAll tasks:"); int total = 0; while(true) { tis= thc.readNextTasks(50); if(tis==null) { break; } total += tis.length; printTaskInfos(tis); } System.out.println("\nTotal number " + "of tasks retrieved:" + total); thc.destroyCollector(); } si.getServerConnection().logout(); }
TaskHistoryCollector createCollectorForTasks(TaskFilterSpec filter) throws InvalidState, RuntimeFault, RemoteException;