ServerEvaluationCall uses a fluent builder-style API to collect
the parameters for a server-side xquery or javascript eval or
invoke (modulePath) call.
ServerEvaluationCall also conveniently has the eval* methods which
execute those calls and return the results. You must call one and
only one of the following methods: xquery, javascript, or
modulePath. The xquery and javascript methods initialize this call
for server-side eval and accept source code as a String or a
TextWriteHandle (in case you are streaming the source code from the
file system, a URL, or other source that is most easily accessed
via io handles). The modulePath method initializes this call for
server- side invoke given the path to a module previously installed
on the server.
String javascript = "'hello world'";
String response = client.newServerEval()
.javascript(javascript)
.evalAs(String.class);
assertEquals("hello world", response);
or in xquery:
String xquery = "'hello world'";
String response = client.newServerEval()
.xquery(xquery)
.evalAs(String.class);
assertEquals("hello world", response);
Variables can be added with the addVariable methods.
addVariable(String, AbstractWriteHandle) allows
you to pass complex JSON or XML values directly from io handles.
addVariableAs(String,
Object) follows the
shortcut pattern which maps objects by type to the appropriate
handle. For simpler atomic values, convenience addVariable methods
are provided for String, Number, and Boolean types.
String javascript = "var planet;'hello solar system from ' + planet";
String response = client.newServerEval()
.javascript(javascript)
.addVariable("planet", "Mars")
.evalAs(String.class);
assertEquals( "hello solar system from Mars", response);
or in xquery:
String xquery = "declare variable $planet external;'hello solar system from ' || $planet";
String response = client.newServerEval()
.xquery(xquery)
.addVariable("planet", "Mars")
.evalAs(String.class);
assertEquals( "hello solar system from Mars", response);
Each call can be executed within a transaction,
within a particular database, and with particular
namespaces available for expansion of prefixed
variable names.
Each call can be executed with only one expected response of a
particular type
or handle type. Or calls can be
executed with multiple responses
expected. Calls that expect only one response but need
to stream the response should still use eval() and EvalResultIterator
so the response isn't closed before the streaming begins.
NOTE: EvalResultIterator MUST BE CLOSED. If you call
eval() don't forget to call
close() on the returned EvalResultIterator to free up the
underlying resources.
addNamespace (String prefix, String namespaceURI)addVariable (String name, AbstractWriteHandle value)addVariable (String name, Boolean value)addVariable (String name, Number value)addVariable (String name, String value)addVariableAs (String name, Object value)eval()<H extends AbstractReadHandle>
Heval (H responseHandle)<T> Tjavascript (TextWriteHandle javascript)javascript (String javascript)modulePath (String modulePath)namespaceContext (EditableNamespaceContext namespaces)transaction (Transaction transaction)xquery (TextWriteHandle xquery)xquery - the xquery-syntax source code to eval on
the serverxquery - a handle containing the xquery-syntax
source code to eval on the serverjavascript - the javascript-syntax source code to
eval on the serverjavascript - a handle containing the
javascript-syntax source code to eval on the servermodulePath - a path to a module previously
installed in the servername - the variable name, including a namespace
prefix if the prefix is mapped to a uri in the
namespace contextvalue - the atomic variable valuename - the variable name, including a namespace
prefix if the prefix is mapped to a uri in the
namespace contextvalue - the atomic variable valuename - the variable name, including a namespace
prefix if the prefix is mapped to a uri in the
namespace contextvalue - the atomic variable valuename - the variable name, including a namespace
prefix if the prefix is mapped to a uri in the
namespace contextvalue - the handle containing the variable value,
most likely XML or JSONname - the variable name, including a namespace
prefix if the prefix is mapped to a uri in the
namespace contextvalue - the handle containing the variable
valuetransaction - the open transaction under which to
run this call in the serverprefix - the prefix for this mappingnamespaceURI - the uri for this mappingnamespaces - a namespace context specifying the
mapping from prefixes to namespacesT - the type of object that will be returned by
the handle registered for itresponseType - the type desired for the response.
Must be a Class registered to a handle.ForbiddenUserExceptionFailedRequestExceptionH - the type of AbstractReadHandle to returnresponseHandle - the type of handle appropriate
for the expected single resultForbiddenUserExceptionFailedRequestExceptionForbiddenUserExceptionFailedRequestExceptionCopyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.