Extension patterns

There are many possible patterns for extensions. Just to give you an idea of your options, we'll list some:

Launching other tools from the console task

This solution involves using Java APIs to launch another program from the pInit() method in the TWGTaskFrame then returning false from pInit() to prevent the task Frame Window from being displayed.

Using IBM Director Server services from the console

This is done by creating a com.tivoil.twg.libs.Command inside the IBM Director Console, addressing the command to the appropriate ServiceNode that exists in the IBM Director Server and sending the command. Usually, you will send the command to the TWGServerServiceNode. Three important points:

  1. From Java GUI code you want to avoid using the synchronous SendCommand() method. instead, you will want to use SendAsynchCommand() and implement a CommandComplete Listener to process the results.
  2. Inside of a CommandComplete() method, you are not on the correct thread to update your GUI components, so you will want to use the jvav invokeLater() method to update the GUI components.
  3. You do not have to include the hostname when addresssing commands from the Console to the IBM Director Server, Commands sent from the Console automatically arrive on teh IBM Director Server.

Writing IBM Director Server code to work with interactive tasks

This is the same as the above case except that you also implement the ServiceNode on the IBM Director Server.

Listening for events and updating hardware status

You can use methods in the TWGEventRouter to listen to IBM Director Events as they arrive at the IBM Director Server. It is critical to return quickly from the EventListener callback. The accepted method is it test for the event type you are intereseted in and then queue the event to another thread using either com.tivoli.twg.QueueBatch.

Working with a coserver

The key issues are

  1. Location of the coserver. Your code on the IBM Director Server or Console must be able to find the coserver.
  2. Communication - this can be solved by using Java socket IO, or in some cases IBM Director IPC

Making code that runs both with and without IBM Director

This can be done in the GUI by creating a pair of wrapper classes that call your core GUI code. One wrapper class runs without IBM Director (eg. an Java application. The other Wrapper is a task Frame.

Using a task to dynamically create other tasks

This is a sometimes useful technique. To see it in action, look at the Event Action Plan Builder. When you create a new action plan, the Builder also creates a Task which represents the plan. That is why the Event Action Plans are shown in the Task Pane of the classic IBM Director Console.

The technique if fairly simple:

  1. Create a task from a properties file
  2. Inside your task code, create the dynamic task. Usually is it done as follows:
    1. Read in a set of default properties from a properties file that you create. It contains a subset of properties in a task properties file
    2. After you read in the properties file, it will be in a java properties object.
    3. Now, in your code, add the reset of the required properties to the properties object. Take special care to put your dynamic properties under your extension's null parent task.
    4. Call new TWGDefaultTask() and apps the properties object as a parameter. Be sure to catch exceptions and log them to debug your code.

To make this technique work, you must create a scheme to calculate a unique TaskID property for every dynamic task.