Specifications

The entry point returns true if initialization was successful and false if it
is not able to initialize appropriately. In the latter case Switch marks all
script instances of this type as a problem process and it retries
initialization at regular intervals. As long as initialization fails, Switch
refrains from invoking jobArrived and timerFired for the script.
If the entry point is absent, this means the script does not need
initialization and the entry point is assumed to return true.
If the script has an execution mode other than persistent this entry point
is never invoked.
If the script has the persistent execution mode, this optional entry point
is invoked to allow the script to release any persistent resources it may
finalizeProcessing( e
: Environment )
have used. The entry point is called when Switch stops processing and
whenever Switch determines that it is meaningful to do so for example,
after the script fails a job.
If the entry point is absent, this means the script doesn’t need finalization.
If the script has an execution mode other than persistent this entry point
is never invoked.
If the script has the persistent execution mode, this optional entry point
is invoked to allow the script to release any persistent resources after its
execution was forcefully aborted due to a time-out.
cleanupAfterAbort (
e : Environment )
If the entry point is absent, this means the script does not need cleanup.
If the script has an execution mode other than persistent this entry point
is never invoked.
Invocation sequence
In persistent execution mode, the invocation sequence is as follows:
( initializeProcessing ( jobArrived | timerFired )+ finalizeProcessing )*
In other words, initialize and finalize bracket one or more processing requests for any script
instance of this execution group. All of these invocations happen in the same thread so that the
contents of the global variable “persistent” is preserved. Thus, for example, the script can start
an external application in the initialize entry point and leave it running until finalize, while
maintaining a persistent reference to the application for use in intermediate invocations. Switch
guarantees the appropriate invocation sequence, so the script does not need to worry about
this.
Abort after time-out
There is one important exception to this guaranteed invocation sequence. If one of the involved
entry points (initializeProcessing, jobArrived, timerFired and finalizeProcessing) does not return
within the maximum allotted time ("abort processes after" in error handling preferences), Switch
aborts the thread and releases all resources attached to it, including its private scripting
environment. Finally, Switch invokes the cleanupAfterAbort entry point to allow the script to
release any external resources.
Unfortunately the cleanupAfterAbort function can no longer access the script’s private persistent
data since it is being called in a new thread (the old one was just destroyed). Communication
448
Enfocus Switch 10