Skip to content

Commit

Permalink
Added runMethod() to Main to allow other applications running pipelin…
Browse files Browse the repository at this point in the history
…es to catch exceptions
  • Loading branch information
ndw committed Sep 22, 2015
1 parent 60fecce commit c061bd3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/com/xmlcalabash/drivers/Main.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@ public void run(String[] args) throws IOException {
} }
} }


// This method runs the pipeline but doesn't catch any exceptions.
// The idea is you could call this from some other object and catch (or not) the
// exceptions yourself.
public void runMethod(String[] args) throws IOException, SaxonApiException, URISyntaxException {
UserArgs userArgs = new ParseArgs().parse(args);

XProcConfiguration config = userArgs.createConfiguration();
runtime = new XProcRuntime(config);
debug = config.debug;

try {
run(userArgs, config);
} finally {
// Here all memory should be freed by the next gc, right?
if (runtime != null) {
runtime.close();
}
}
}

boolean run(UserArgs userArgs, XProcConfiguration config) throws SaxonApiException, IOException, URISyntaxException { boolean run(UserArgs userArgs, XProcConfiguration config) throws SaxonApiException, IOException, URISyntaxException {
if (userArgs.isShowVersion()) { if (userArgs.isShowVersion()) {
XProcConfiguration.showVersion(runtime); XProcConfiguration.showVersion(runtime);
Expand Down

0 comments on commit c061bd3

Please sign in to comment.