if (commandClass == null) {
throw new IllegalArgumentException("\"" + action + "\" not recognized.");
}
Command command;
try {
command = (Command) Class.forName(commandClass).newInstance();
if (config.getBoolean(HELP)) {
// show command help
command.usage();
} else {
// Register Xindice Database with XML:DB
DatabaseImpl db = new DatabaseImpl();
DatabaseManager.registerDatabase(db);
// Execute command class
command.execute(config);
}
return true;
} catch (XMLDBException e) {
System.err.println("XMLDB Exception " + e.errorCode + ": " + e.getMessage());
if (config.getBoolean(VERBOSE)) {
e.printStackTrace(System.err);
}
return false;
} catch (Exception e) {
System.err.println("ERROR : " + e.getMessage());
if (config.getBoolean(VERBOSE)) {
e.printStackTrace(System.err);
}
return false;
} finally {
// Close Database
if (config.getBoolean(LOCAL)) {
command = new org.apache.xindice.tools.command.Shutdown();
command.execute(config);
}
}
}