DJAVA

au.gov.aao.drama
Class DramaPath.RescheduleHandler

java.lang.Object
  extended by au.gov.aao.drama.DramaPath.RescheduleHandler
All Implemented Interfaces:
DramaTask.Action
Enclosing class:
DramaPath

public static class DramaPath.RescheduleHandler
extends Object
implements DramaTask.Action

A class which handles rescheduling of a DRAMA Action using the DramaPath class to messages to other DRAMA tasks.

You should derived from this class to implement your own handling where necessary by overriding NotHandled, OrphanHandler, Finished, Timeout, Signal, ThreadError or SystemError as you require.

Where a reschedule event is a reply to a message sent by this task and the message has a ResponseHandler assoicated with it, that object is used to handle the reschedule event.

See Also:
DramaPath, DramaPath.ResponseHandler

Constructor Summary
DramaPath.RescheduleHandler()
          Default Reschedule handler constructor.
DramaPath.RescheduleHandler(boolean b)
          Constructor which initialises threadCount to zero.
DramaPath.RescheduleHandler(boolean b, double t)
          Constructor which allows setting of timeout and clearing threadCount.
DramaPath.RescheduleHandler(double t)
          Constructors which allows timeout to be set.
DramaPath.RescheduleHandler(double t, boolean b)
          Constructor which allows setting of timeout and clearing threadCount.
DramaPath.RescheduleHandler(DramaTask task)
          Reschedule handler constructor which does a implicit Enable().
DramaPath.RescheduleHandler(DramaTask task, boolean b)
          Reschedule handler constructor which does a implicit Enable() and sets thread count to 0.
DramaPath.RescheduleHandler(DramaTask task, boolean b, double t)
          Reschedule handler constructor which does a implicit Enable(), sets timeout and zero's thread count.
DramaPath.RescheduleHandler(DramaTask task, double t)
          Reschedule handler constructor which does a implicit Enable() and allows timeout to be set.
DramaPath.RescheduleHandler(DramaTask task, double t, boolean b)
          Reschedule handler constructor which does a implicit Enable(), sets timeout and zero's thread count.
 
Method Summary
 void Enable(DramaTask task)
          Enable this reschedule handler.
 void Finished(DramaTask task)
          Invoked when the last DRAMA message thread has finished.
 void NewThread()
          Increment the thread count, indicating another thread of messages is being controlled by this RecheduleHandler object.
 void NotHandled(DramaTask task)
          Invoked if we received a message which we could not dispatch to a handler because there was no handler assocaited with the transaction.
 void Obey(DramaTask task)
          Implement DramaTask.Action's obey handler.
 void OrphanHandler(DramaTask task)
          Invoked if we receive a message which we could not dispatch to a handler due to it being orphanded (but not forgotten).
 void SetTimeout(double t)
          Explicty set or reset the timeout assoicated with the reschedule handler.
 boolean Signal(DramaTask task)
          Invoked on a Signal (DramaTask.EntReason == REA_SIGNAL).
 void SystemError(DramaTask task, DramaException exception)
          Invoked if there is an overall error whilst handling reschedule messages (an exception has been thrown).
 void ThreadError(DramaTask task, DramaException exception)
          Invoked if an error occurs dispatching a thread.
 boolean Timeout(DramaTask task)
          Invoked on a timeout whilst waiting for messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler()
Default Reschedule handler constructor.

Timeout is disabled and thread count initialized to 1.


DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(double t)
Constructors which allows timeout to be set.

Thread count will be initialized to 1.

Parameters:
t - The timeout in seconds. Timeout will be invoked if no message is received in this time.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(boolean b)
Constructor which initialises threadCount to zero.

This is usefull if you are doing a NewThread for each message you send. The boolean's value is not use.

Parameters:
b - Not used, just indicates the particular constructor.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(double t,
                                   boolean b)
Constructor which allows setting of timeout and clearing threadCount.

Parameters:
t - The timeout in seconds. Timeout will be invoked if no message is received in this time.
b - Not used, just indicates the particular constructor.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(boolean b,
                                   double t)
Constructor which allows setting of timeout and clearing threadCount.

Parameters:
b - Not used, just indicates the particular constructor.
t - The timeout in seconds. Timeout will be invoked if no message is received in this time.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(DramaTask task)
                            throws DramaException
Reschedule handler constructor which does a implicit Enable().

Timeout is disabled and thread count initialized to 1.

Parameters:
task - The task to invoke PutObeyHandler() with.
Throws:
DramaException

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(DramaTask task,
                                   double t)
                            throws DramaException
Reschedule handler constructor which does a implicit Enable() and allows timeout to be set.

Thread count initialized to 1.

Parameters:
task - The task to invoke PutObeyHandler() with.
t - The timeout in seconds. Timeout will be invoked if no message is received in this time.
Throws:
DramaException - Thrown on errors in the DRAMA code.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(DramaTask task,
                                   boolean b)
                            throws DramaException
Reschedule handler constructor which does a implicit Enable() and sets thread count to 0.

Timeout is disabled.

This is usefull if you are doing a NewThread for each message you send. The boolean's value is not use.

Parameters:
b - Not used, just indicates the particular constructor.
task - The task to invoke PutObeyHandler() with.
Throws:
DramaException - Thrown on errors in the DRAMA code.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(DramaTask task,
                                   double t,
                                   boolean b)
                            throws DramaException
Reschedule handler constructor which does a implicit Enable(), sets timeout and zero's thread count.

Parameters:
task - The task to invoke PutObeyHandler() with.
t - The timeout in seconds. Timeout will be invoked if no message is received in this time.
b - Not used, just indicates the particular constructor.
Throws:
DramaException - Thrown on errors in the DRAMA code.

DramaPath.RescheduleHandler

public DramaPath.RescheduleHandler(DramaTask task,
                                   boolean b,
                                   double t)
                            throws DramaException
Reschedule handler constructor which does a implicit Enable(), sets timeout and zero's thread count.

Parameters:
task - The task to invoke PutObeyHandler() with.
t - The timeout in seconds. Timeout will be invoked if no message is received in this time.
b - Not used, just indicates the particular constructor.
Throws:
DramaException - Thrown on errors in the DRAMA code.
Method Detail

Enable

public void Enable(DramaTask task)
            throws DramaException
Enable this reschedule handler.

This must be called either to make this object the obey handler for this action and to set up the reschedule information. If we are handling UFACE context messages, it must be invoked before we send any messages.

Note that constructors which take a DramaTask object parameter invoke Enable() themselves.

Parameters:
task - The task to invoke PutObeyHandler() with.
Throws:
DramaException - Thrown on errors in the DRAMA code.

SetTimeout

public void SetTimeout(double t)
Explicty set or reset the timeout assoicated with the reschedule handler.

Parameters:
t - The new reschedule timeout

NewThread

public void NewThread()
Increment the thread count, indicating another thread of messages is being controlled by this RecheduleHandler object.


Obey

public final void Obey(DramaTask task)
                throws DramaException
Implement DramaTask.Action's obey handler. Not meant to be invoked or overriden by the user.

Specified by:
Obey in interface DramaTask.Action
Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.
See Also:
DramaTask.Action

NotHandled

public void NotHandled(DramaTask task)
                throws DramaException
Invoked if we received a message which we could not dispatch to a handler because there was no handler assocaited with the transaction.

The user of the DramaPath.RescheduleHandler can override this to handle such messages themselves.

The default behaviour is to throw an exception.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.

OrphanHandler

public void OrphanHandler(DramaTask task)
                   throws DramaException
Invoked if we receive a message which we could not dispatch to a handler due to it being orphanded (but not forgotten).

The user of the DramaPath.RescheduleHandler can override this to handle such messages themselves.

The default behaviour is to throw an exception.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.

Finished

public void Finished(DramaTask task)
              throws DramaException
Invoked when the last DRAMA message thread has finished.

The default behavioud is that If we had an error on a thread, then we throw that error now, which should cause SystemError to be invoked.

The user of the DramaPath.RescheduleHandler can override this to handle such messages themselves.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.

Timeout

public boolean Timeout(DramaTask task)
                throws DramaException
Invoked on a timeout whilst waiting for messages.

The user of the DramaPath.RescheduleHandler can override this to handle such messages themselves.

The default behaviour is to throw an exception.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.

Signal

public boolean Signal(DramaTask task)
               throws DramaException
Invoked on a Signal (DramaTask.EntReason == REA_SIGNAL).

The user of the DramaPath.RescheduleHandler can override this to handle such messages themselves.

The default behaviour is to throw an exception.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.

ThreadError

public void ThreadError(DramaTask task,
                        DramaException exception)
                 throws DramaException
Invoked if an error occurs dispatching a thread.

In the default behaviour, if there only one thread, we re-throw this exception (control passes to SystemError).

If there is more then one thread, we output the details, recording the exception details for the first exception only.

The user of the DramaPath.RescheduleHandler can override this to handle such messages themselves.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
Throws:
DramaException - Thrown on errors in the DRAMA code.

SystemError

public void SystemError(DramaTask task,
                        DramaException exception)
                 throws DramaException
Invoked if there is an overall error whilst handling reschedule messages (an exception has been thrown).

The default implementation reports the details of the exception using DramaException.Report and then throws the exception.

For Actions, the result is that the action completes and the DRAMA status associated with the exception becomes the action completion status.

Note When used in its intended way, this method is always invoked in the DRAMA thread and with the DRAMA semaphore taken. Please see thread Issues for important information, particuarly if you are updating Swing widgets from your implemention of this method.

Parameters:
task - The task which received the message
exception - The exception which was thrown.
Throws:
DramaException - Thrown on errors in the DRAMA code.

DJAVA

Click here for the DRAMA home page and here for the AAO home page.

For more information, contact tjf@aaoepp.aao.gov.au.