public class ModuleRunner
extends java.lang.Object
This is a very simple class that will invoke a named XQuery module on the server and return the result.
Click here for the source code for this class
The main() method looks for two command-line args, a URL for the server (
ContentSourceFactory.newContentSource(java.net.URI)
) and theURI of a module to invoke.
This URI should be relative to the "Library" path set in the XDBC server configuration for the
content server you're connecting to (arg #1). This program invokes the named module and then
prints the result sequence to stdout, one item per line.
The class has methods that could be used to set request options and to obtain the results as an
array of Strings or as a real ResultSequence
.
If you want to set external variables for a request, you can call getRequest()
to obtain
a reference to the internal Request
object and set the variable values on it before
calling invoke(String)
.
ToDo: Accept variable names and values on the command line.
Constructor and Description |
---|
ModuleRunner(java.net.URI serverUri)
Construct an instance that will invoke modules on the server represented by the given URI.
|
Modifier and Type | Method and Description |
---|---|
Request |
getRequest()
Returns the
Request object used internally to submit requests. |
ResultSequence |
invoke(java.lang.String moduleUri)
Invoke the module with the given URI and return the resulting
ResultSequence . |
java.lang.String |
invokeToSingleString(java.lang.String moduleUri,
java.lang.String separator) |
java.lang.String[] |
invokeToStringArray(java.lang.String moduleUri) |
static void |
main(java.lang.String[] args) |
void |
setRequestOptions(RequestOptions options)
Set (or clear) the
RequestOptions instance to associate with submitted queries. |
public ModuleRunner(java.net.URI serverUri) throws XccConfigException
serverUri
- A URI that specifies a server per (
ContentSourceFactory.newContentSource(java.net.URI)
).XccConfigException
- If the URI is not a valid XCC server URL.public ResultSequence invoke(java.lang.String moduleUri) throws RequestException
ResultSequence
.moduleUri
- ResultSequence
, possibly with size zero.RequestException
- If an unrecoverable error occurs when submitting or evaluating the request.public java.lang.String[] invokeToStringArray(java.lang.String moduleUri) throws RequestException
RequestException
public java.lang.String invokeToSingleString(java.lang.String moduleUri, java.lang.String separator) throws RequestException
RequestException
public Request getRequest()
Request
object used internally to submit requests. This
object can be used to set external variables that will be bound to the query when submitted.
You should not set your own RequestOptions
object, use
setRequestOptions(com.marklogic.xcc.RequestOptions)
instead.Request
.public void setRequestOptions(RequestOptions options)
RequestOptions
instance to associate with submitted queries.options
- An instance of RequestOptions
or null.public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
Copyright © 2024 MarkLogic Corporation
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com