}
}
private void execute(boolean isBefore, DBBroker broker, Txn transaction, QName functionName, XmldbURI ... urls) throws TriggerException {
final XmldbURI src = urls[0];
final CompiledXQuery compiledQuery = getScript(isBefore, broker, transaction, src);
if (compiledQuery == null) {return;}
ProcessMonitor pm = null;
final XQueryContext context = compiledQuery.getContext();
//execute the XQuery
try {
final UserDefinedFunction function = context.resolveFunction(functionName, urls.length);
if (function != null) {
final List<Expression> args = new ArrayList<Expression>(urls.length);
for (int i = 0; i < urls.length; i++)
args.add(new LiteralValue(context, new AnyURIValue(urls[i])));
pm = broker.getBrokerPool().getProcessMonitor();
context.getProfiler().traceQueryStart();
pm.queryStarted(context.getWatchDog());
final FunctionCall call = new FunctionCall(context, function);
call.setArguments(args);
call.analyze(new AnalyzeContextInfo());
call.eval(NodeSet.EMPTY_SET);
}
} catch(final XPathException e) {
TriggerStatePerThread.setTriggerRunningState(TriggerStatePerThread.NO_TRIGGER_RUNNING, this, null);
TriggerStatePerThread.setTransaction(null);
throw new TriggerException(PEPARE_EXCEIPTION_MESSAGE, e);
} finally {
if (pm != null) {
context.getProfiler().traceQueryEnd(context);
pm.queryCompleted(context.getWatchDog());
}
compiledQuery.reset();
context.reset();
}
if (!isBefore) {
TriggerStatePerThread.setTriggerRunningState(TriggerStatePerThread.NO_TRIGGER_RUNNING, this, null);