All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.sgi.sysadm.ui.TaskRegistry
If a task is applicable to a certain category of items, use inst to add an entry to the directory /var/sysadm/taskRegistry/{Category}/. The entry should include the fully qualified name of the Task, for example: com.sgi.sysadm.ui.tests.AddUserTask
To specify the item state that the task is applicable to, the task must first have a directory entry as specified above for the category of the item under consideration. In addition, add a property with key = Task.itemTester in {Task}P.java or any of the property files associated with the task.
The value of the Task.itemTester property should be a String containing the fully qualified name of a class that implements the ItemTester interface. ItemTester.testItem() should be defined to perform whatever checks are required to identify if the task is applicable to the item under consideration and return true, if applicable and false otherwise.
Typical tests might be:
public boolean testItem(Item item) { return true; }
public boolean testItem(Item item) { if (item.getType().equals("User")) { return true; } }
public boolean testItem(Item item) { if (item.getType().equals("FS") && item.getSelector().equals("foo") && item.getBoolean("mounted") && item.getLong("numBlocks") > LIMIT) { return true; } }
In order to get a task list from the TaskRegistry, you must use a ResultListener to get the result from getTaskList. In the succeeded method of the ResultListener, use the getResult method of ResultEvent to get the list of tasks. The Object returned by getResult should be cast to a TaskLoader[]. For example:
getTaskList("Test", new ResultListener() { public void succeeded(ResultEvent event) { TaskLoader[] taskList = (TaskLoader[])event.getResult()); printTaskList(taskList); } public void failed(ResultEvent event) { System.out.println("getTaskList failed."); } });
protected static final String TASK_REGISTRY
public TaskRegistry()
public void setHostContext(HostContext hostContext)
public synchronized void getTaskList(String catName, ResultListener listener)
public void getTaskList(Item item, ResultListener listener)
protected abstract void computeTaskList(String catName)
protected synchronized void setTaskList(String catName, TaskLoader taskArray[])
All Packages Class Hierarchy This Package Previous Next Index