All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sgi.sysadm.ui.TaskRegistry

java.lang.Object
   |
   +----com.sgi.sysadm.ui.TaskRegistry

public abstract class TaskRegistry
extends Object
TaskRegistry determines tasks pertaining to CategoryView and ItemView

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:

  1. Applicable to all items
     public boolean testItem(Item item) {
         return true;
     }
     
  2. Applicable to items of type "User"
     public boolean testItem(Item item) {
     	if (item.getType().equals("User")) {
    		return true;
    	}
     }
     
  3. Applicable to items of type "FS" if filesystem name = "foo" and filesystem is mounted and total number of blocks > some limit
     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.");
     }
 });
 


Variable Index

 o TASK_REGISTRY

Constructor Index

 o TaskRegistry()

Method Index

 o computeTaskList(String)
Subclasses override this method that TaskRegistry calls when it needs the list of tasks for a particular category.
 o getTaskList(Item, ResultListener)
Determines the tasks relevant to the state of an item.
 o getTaskList(String, ResultListener)
Determines the tasks relevant to a Category.
 o setHostContext(HostContext)
Set the HostContext needed for creating TaskLoader instances.
 o setTaskList(String, TaskLoader[])
Called by subclass to report result of computeTaskList.

Variables

 o TASK_REGISTRY
 protected static final String TASK_REGISTRY

Constructors

 o TaskRegistry
 public TaskRegistry()

Methods

 o setHostContext
 public void setHostContext(HostContext hostContext)
Set the HostContext needed for creating TaskLoader instances.

Parameters:
hostContext - HostContext for creating TaskLoader instances.
 o getTaskList
 public synchronized void getTaskList(String catName,
                                      ResultListener listener)
Determines the tasks relevant to a Category.

Parameters:
catName - Category Name.
listener - Gets result of this operation. The getResult method should be called on the ResultEvent passed to listener.succeeded to get the task list for "catName". The task list takes the form of an array of TaskLoaders.
 o getTaskList
 public void getTaskList(Item item,
                         ResultListener listener)
Determines the tasks relevant to the state of an item.

Parameters:
item - Item under consideration.
listener - Gets result of this operation. The getResult method should be called on the ResultEvent passed to listener.succeeded to get the task list for "catName". The task list takes the form of an array of TaskLoaders.
 o computeTaskList
 protected abstract void computeTaskList(String catName)
Subclasses override this method that TaskRegistry calls when it needs the list of tasks for a particular category. Subclass must eventually call setTaskList when it is done computing the task list.

Parameters:
catName - Name of category to compute task list for.
 o setTaskList
 protected synchronized void setTaskList(String catName,
                                         TaskLoader taskArray[])
Called by subclass to report result of computeTaskList.

Parameters:
catName - Name of category this is a task list for.
taskArray - List of tasks for this category.

All Packages  Class Hierarchy  This Package  Previous  Next  Index