|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
es.iac.ing.codeso.publisher.client.SubscriberLinkCheckerTask
class SubscriberLinkCheckerTask
Provides a means of periodically verifying the link to the subscriber.
The scheduling of link verifications is determined by the initialDelay
and retryInterval
parameters passed in the class constructor.
Once created this task runs indefinitely until either a) it is cancelled
by the user via the cancel
method or b) an attempt to verify
the subscription results in failure.
The termination of this task and the reason for its termination may be
detected via the isTerminated
and getTerminationReason
methods respectively.
This task extends the java.util.Observable
class to provide a
single notifiable event generated when (or if) the task unexpectedly terminates.
Notification is sent to interested parties who implement the java.util.Observer
interface. The notification includes details of the source of the event (this class)
and the reason the task terminated as described by the SubscriberLinkCheckerTask.TerminationReason
enumeration.
Note: the termination event is NOT generated if the task is cancelled by the user.
This class is thread-safe.
Nested Class Summary | |
---|---|
static class |
SubscriberLinkCheckerTask.TerminationReason
An enumeration describing the possible reasons why the link checker task terminated. |
Field Summary | |
---|---|
private java.util.Timer |
executionTimer
Reference to a timer which will be used to schedule periodic execution of the link checking operation. |
private int |
initialDelay
Interval in milliseconds before the first attempt to verify the link. |
private PublisherProxyDataModel |
publisherProxyDataModel
Reference to the object which will be informed of the results if the lease renewer fails. |
private int |
retryInterval
Interval in milliseconds between subsequent attempts to verify the link. |
private es.iac.ing.codeso.idl.publisher.IdlSubscribable |
subscribable
Reference to the CORBA object to whom the link verification requests should be made. |
private SubscriberId |
subscriberId
Id of the subscriber whose link is to be checked. |
private SubscriberLinkCheckerTask.TerminationReason |
terminationReason
Holds the reason why the task terminated. |
Constructor Summary | |
---|---|
private |
SubscriberLinkCheckerTask(es.iac.ing.codeso.idl.publisher.IdlSubscribable subscribable,
PublisherProxyDataModel publisherProxyDataModel,
SubscriberId subscriberId,
int initialDelay,
int retryInterval)
Constructs a new SubscriberLinkCheckerTask which will
periodically attempt tocheck a subscriber's link. |
Method Summary | |
---|---|
void |
cancel()
Cancels this task, if it is still running. |
private void |
checkSubscriberLink()
Checks the subscribers link. |
SubscriberLinkCheckerTask.TerminationReason |
getTerminationReason()
Returns the reason why the task has terminated (if it has). |
boolean |
isTerminated()
Returns a boolean indicating whether the task has terminated. |
static SubscriberLinkCheckerTask |
newInstance(es.iac.ing.codeso.idl.publisher.IdlSubscribable subscribable,
PublisherProxyDataModel publisherProxyDataModel,
SubscriberId subscriberId,
int initialDelay,
int retryInterval)
Returns a new instance of a SubscriberLinkCheckerTask . |
private void |
setAndNotifyTerminated(SubscriberLinkCheckerTask.TerminationReason reason,
java.lang.String additionalInformation)
Terminates this task storing the reason why and notifying observers of this class. |
private void |
start()
Starts the task. |
private void |
stop()
Stops the task. |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final SubscriberId subscriberId
private final es.iac.ing.codeso.idl.publisher.IdlSubscribable subscribable
private final PublisherProxyDataModel publisherProxyDataModel
private final int initialDelay
private final int retryInterval
private java.util.Timer executionTimer
private SubscriberLinkCheckerTask.TerminationReason terminationReason
Constructor Detail |
---|
private SubscriberLinkCheckerTask(es.iac.ing.codeso.idl.publisher.IdlSubscribable subscribable, PublisherProxyDataModel publisherProxyDataModel, SubscriberId subscriberId, int initialDelay, int retryInterval)
SubscriberLinkCheckerTask
which will
periodically attempt tocheck a subscriber's link.
This constructor should not be used directly. Instead please use
the newInstance
method which will safely construct
the object before starting the internal thread which will perform the
link checking operation.
subscribable
- CORBA reference to the object to whom the
link verification requests should be made.publisherProxyDataModel
- reference to the data model which
is to be informed of failure if the link checker fails.subscriberId
- the id of the subscriber whose status is to be
checked.initialDelay
- delay in milliseconds which will be applied
after the construction of a new instance of this class
before the first attempt to verify the subscriber link.retryInterval
- delay in milliseconds which will be applied
between subsequent attempts to verify the subscriber link.
java.lang.NullPointerException
- if either of the reference parameters were
null.
java.lang.IllegalArgumentException
- if the initialDelay
parameter was negative.
java.lang.IllegalArgumentException
- if the retryInterval
parameter was less than or equal to zero.Method Detail |
---|
public static SubscriberLinkCheckerTask newInstance(es.iac.ing.codeso.idl.publisher.IdlSubscribable subscribable, PublisherProxyDataModel publisherProxyDataModel, SubscriberId subscriberId, int initialDelay, int retryInterval)
SubscriberLinkCheckerTask
.
subscribable
- CORBA reference to the object to whom the
link verification requests should be made.publisherProxyDataModel
- reference to the data model which
is to be informed of failure if the link checker fails.subscriberId
- the id of the subscriber whose status is to be
checked.initialDelay
- delay in milliseconds which will be applied
after the construction of a new instance of this class
before the first attempt to verify the subscriber link.retryInterval
- delay in milliseconds which will be applied
between subsequent attempts to verify the subscriber link.
java.lang.NullPointerException
- if either of the reference parameters were
null.
java.lang.IllegalArgumentException
- if the initialDelay
parameter was negative.
java.lang.IllegalArgumentException
- if the retryInterval
parameter was less than or equal to zero.public void cancel()
Sets the reason for termination to TerminationReason.TASK_CANCELLED_BY_USER
but does NOT notify the user.
This method may be called repeatedly; the second and subsequent calls
have no effect.
public boolean isTerminated()
public SubscriberLinkCheckerTask.TerminationReason getTerminationReason()
TerminationReason.NOT_TERMINATED
value
will be returned.
private void start()
private void setAndNotifyTerminated(SubscriberLinkCheckerTask.TerminationReason reason, java.lang.String additionalInformation)
reason
- the reason why.additionalInformation
- optional field providing additional
information about the cause of the error. Typically, this
information will be acquired at runtime. This field may be
set to null or an empty string if not required.private void checkSubscriberLink()
private void stop()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |