[java-support] branch master updated: Add ability to manipulate script result.
Scott Cantor
cantor.2 at osu.edu
Thu May 4 21:28:05 EDT 2017
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=1068c3d81d0c6c44cf09bc55e527f63b20cb1e69
The following commit(s) were added to refs/heads/master by this push:
new 1068c3d Add ability to manipulate script result.
1068c3d is described below
commit 1068c3d81d0c6c44cf09bc55e527f63b20cb1e69
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu May 4 21:27:54 2017 -0400
Add ability to manipulate script result.
---
.../support/scripting/AbstractScriptEvaluator.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/scripting/AbstractScriptEvaluator.java b/src/main/java/net/shibboleth/utilities/java/support/scripting/AbstractScriptEvaluator.java
index c3e570a..f5cdc69 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/scripting/AbstractScriptEvaluator.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/scripting/AbstractScriptEvaluator.java
@@ -168,7 +168,7 @@ public abstract class AbstractScriptEvaluator {
*
* @return script result
*/
- protected Object evaluate(@Nullable final Object... input) {
+ @Nullable protected Object evaluate(@Nullable final Object... input) {
final SimpleScriptContext scriptContext = new SimpleScriptContext();
scriptContext.setAttribute("custom", getCustomObject(), ScriptContext.ENGINE_SCOPE);
@@ -183,7 +183,7 @@ public abstract class AbstractScriptEvaluator {
return getReturnOnError();
}
- return result;
+ return finalizeContext(scriptContext, result);
} catch (final ScriptException e) {
if (getHideExceptions()) {
@@ -202,4 +202,19 @@ public abstract class AbstractScriptEvaluator {
*/
protected abstract void prepareContext(@Nonnull final ScriptContext scriptContext, @Nullable final Object... input);
+ /**
+ * Complete processing by evaluating the result of the script and returning the final result to the caller.
+ *
+ * <p>The default implementation just returns the result.</p>
+ *
+ * @param scriptContext the context after execution
+ * @param scriptResult the result of script execution
+ *
+ * @return the final result to return, or null
+ * @throws ScriptException to signal a failure after script execution
+ */
+ @Nullable protected Object finalizeContext(@Nonnull final ScriptContext scriptContext,
+ @Nullable final Object scriptResult) throws ScriptException {
+ return scriptResult;
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list