try {
startOperation();
this.ruleBase.readLock();
this.lock.lock();
DroolsQuery queryObject = new DroolsQuery( query,
arguments,
getQueryListenerInstance(),
false );
ObjectTypeConf objectTypeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
queryObject );
InternalFactHandle handle = this.handleFactory.newFactHandle( queryObject,
objectTypeConf,
this,
this );
insert( handle,
queryObject,
null,
null,
objectTypeConf );
this.handleFactory.destroyFactHandle( handle );
Declaration[] declarations = new Declaration[0];
if ( queryObject.getQuery() != null ) {
// this is null when there are no query results, thus the query object is never set
declarations = queryObject.getQuery().getDeclarations();
}
return new QueryResults( (List<FactHandle[]>) queryObject.getQueryResultCollector().getResults(),
declarations,
this );
} finally {
this.lock.unlock();
this.ruleBase.readUnlock();