this.lock.lock();
this.ruleBase.executeQueuedActions();
executeQueuedActions();
DroolsQuery queryObject = new DroolsQuery( queryName,
arguments,
getQueryListenerInstance(),
false );
InternalFactHandle handle = this.handleFactory.newFactHandle( queryObject,
null,
this,
this );
final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
PropagationContext.ASSERTION,
null,
null,
handle,
agenda.getActiveActivations(),
agenda.getDormantActivations(),
getEntryPoint() );
getEntryPointNode().assertQuery( handle,
propagationContext,
this );
propagationContext.evaluateActionQueue( this );
this.handleFactory.destroyFactHandle( handle );
BaseNode[] nodes = this.ruleBase.getReteooBuilder().getTerminalNodes( queryObject.getQuery() );
List<Map<String, Declaration>> decls = new ArrayList<Map<String, Declaration>>();
if ( nodes != null ) {
for ( BaseNode node : nodes ) {
decls.add( ((QueryTerminalNode) node).getSubrule().getOuterDeclarations() );
}
}
executeQueuedActions();
return new QueryResults( (List<QueryRowWithSubruleIndex>) queryObject.getQueryResultCollector().getResults(),
decls.toArray( new Map[decls.size()] ),
this,
( queryObject.getQuery() != null ) ? queryObject.getQuery().getParameters() : new Declaration[0] );
} finally {
this.lock.unlock();
this.ruleBase.readUnlock();
endOperation();
}