Annotation Interface OnStopped
Marker annotation a Processor
or
ReportingTask
implementation
can use to indicate that a method should be called whenever the component is
no longer scheduled to run. Methods marked with this annotation will be
invoked each time the component is stopped and will be invoked only after the
last thread has returned from the onTrigger
method.
This means that the thread executing in this method will be the only thread executing in any part of the Processor. However, since other threads may later execute other parts of the code, member variables must still be protected appropriately. However, access to multiple variables need not be atomic.
To indicate that a method should be called immediately when a component is no
longer scheduled to run (as opposed to after all threads have returned from
the onTrigger
method), see the OnUnscheduled
annotation.
Methods with this annotation are permitted to take either 0 or 1 argument. If
an argument is used, it must be of type ConfigurationContext
if the
component is a ReportingTask or of type ProcessContext
if the
component is a Processor.
Implementation Guidelines:
- Methods with this annotation are expected to perform very quick, short-lived tasks. If the function is
expensive or long-lived, the logic should be performed in the
onTrigger
method instead. - If a method with this annotation does not return (exceptionally or otherwise) within a short period of time (the duration is configurable in the properties file), the Thread may be interrupted.
- Methods that make use of this interface should honor Java's Thread interruption mechanisms and not swallow
InterruptedException
.