<invoke
method = Qualified name of a Java static method
arguments = string : ""
/>Invokes specified Java™ static method, passing it specified string as an argument.
The method generally belongs to a class which is contained in a jar dynamically discovered by XXE at startup time.
The method must have one of the following signatures:
method(java.lang.String arguments,
java.io.File workingDir);method(java.lang.String arguments,
java.io.File workingDir,
com.xmlmind.xmledit.util.Console console);method(java.lang.String arguments,
java.io.File workingDir,
com.xmlmind.xmledit.util.Console console,
com.xmlmind.xmledit.doc.Document docBeingEdited);The value of the arguments attribute after substituting all variables (%0, %1, %D, %p, %C, etc).
All arguments, if any, are passed as a single string. That is, the method is responsible for properly parsing this string.
The temporary directory created each time a process command is executed. Relative paths are generally relative to this directory.
A simple way to report information and non fatal errors to the user of the process command. Throw an exception to report a fatal error.
The document being edited.
The method may return a value. If it returns a value, this value is converted to a java.lang.String using toString() and then returned by the invoke element (à la read, for use in a macro command for example).
The method may throw any exception.
Examples:
<invoke method="TestInvoke.echo"
arguments="args={%*} doc='%D' pwd='%W' conf='%C'" />
<invoke method="TestInvoke.echo2" />
<invoke method="TestInvoke.gzip" arguments="__doc.xml" />Static methods invoked by the above examples:
public final class TestInvoke {
public static void echo(String arguments, File workingDir,
Console console) {
console.showMessage("arguments='" + arguments + "'", Console.INFO);
console.showMessage("workingDir='" + workingDir + "'", Console.INFO);
}
public static void echo2(String arguments, File workingDir,
Console console, Document docBeingEdited) {
echo(arguments, workingDir, console);
console.showMessage("docBeingEdited='" + docBeingEdited.getLocation()
+ "'", Console.INFO);
}
public static File gzip(String arguments, File workingDir)
throws IOException {
File inFile = new File(workingDir, arguments.trim());
if (!inFile.isFile())
throw new FileNotFoundException(inFile.getPath());
File outFile = new File(inFile.getPath() + ".gz");
FileInputStream in = new FileInputStream(inFile);
try {
GZIPOutputStream out =
new GZIPOutputStream(new FileOutputStream(outFile));
byte[] bytes = new byte[8192];
int count;
while ((count = in.read(bytes)) != -1)
out.write(bytes, 0, count);
out.finish();
out.close();
} finally {
in.close();
}
return outFile;
}
}