public interface IManagedProgramInstance extends IProgramInstance
MyProgram.gsp
-------------
extends MyBase
doSomething()
MyBase.gs
---------
package abc
class MyBase implements IManagedProgramInstance {
override function beforeExecution() : boolean {
// determine if the program should execute
}
override function afterExecution( t: Throwable ) {
// handle the Throwable, do what you need to cleanup
}
}
Internally the Gosu compiler generates the evaluate() method like so:
function evaluate( map: IExternalSymbolMap ) : Object {
var $failure : Throwable
if( this.beforeExecution() ) {
try {
[method-body] // returns result
}
catch( $catchFailure: Throwable ) {
$failure = $catchFailure
}
finally {
this.afterExecution( $failure )
}
}
return null // only get here if exception not rethrown in afterExecution()
}
| Modifier and Type | Method and Description |
|---|---|
void |
afterExecution(Throwable error)
Called after IProgramInstance#evaluate().
|
boolean |
beforeExecution()
Called before IProgramInstance#evaluate().
|
evaluate, evaluateRootExprboolean beforeExecution()
void afterExecution(Throwable error)
error - The exception or error if IProgramInstance#evaluate() terminates abnormally, otherwise null.Copyright © 2018. All rights reserved.