use of org.apache.jena.sparql.service.ServiceExecution in project jena by apache.
the class QueryIterService method nextStage.
@Override
protected QueryIterator nextStage(Binding outerBinding) {
boolean silent = opService.getSilent();
ExecutionContext execCxt = getExecContext();
Context cxt = execCxt.getContext();
ServiceExecutorRegistry registry = ServiceExecutorRegistry.get(cxt);
ServiceExecution svcExec = null;
OpService substitutedOp = (OpService) QC.substitute(opService, outerBinding);
try {
// ---- Find handler
if (registry != null) {
for (ServiceExecutorFactory factory : registry.getFactories()) {
// Internal consistency check
if (factory == null) {
Log.warn(this, "SERVICE <" + opService.getService().toString() + ">: Null item in custom ServiceExecutionRegistry");
continue;
}
svcExec = factory.createExecutor(substitutedOp, opService, outerBinding, execCxt);
if (svcExec != null)
break;
}
}
// ---- Execute
if (svcExec == null)
throw new QueryExecException("No SERVICE handler");
QueryIterator qIter = svcExec.exec();
qIter = QueryIter.makeTracked(qIter, getExecContext());
// There should be no variables in common because of the OpSubstitute.substitute
return new QueryIterCommonParent(qIter, outerBinding, getExecContext());
} catch (RuntimeException ex) {
if (silent) {
Log.warn(this, "SERVICE " + NodeFmtLib.strTTL(substitutedOp.getService()) + " : " + ex.getMessage());
// Return the input
return QueryIterSingleton.create(outerBinding, getExecContext());
}
throw ex;
}
}
Aggregations