*/
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public Iterator getExecutableContexts(int maxResults)
{
LogUtil.debug(getClass(), "Performing query for executable tokens.");
PersistenceContext pc = getPersistenceContext();
// Construct search search criterion for executable token contexts;
// don't cache this, depends on current session.
PersistenceQuery query = pc.createQuery(TokenContext.class);
query.eq("lifecycleRequest", new Integer(LifecycleRequest.RESUME));
query.neq("lifecycleState", new Integer(LifecycleState.SELECTED));
query.addOrdering("priority");
int max = maxResults;
if (getIsolationLevel() == ISOLATION_LEVEL_SINGLE)
{
max = 1;
}
if (max > 0)
{
query.setMaxResults(max);
}
// TODO Fix 2 A 'select for update' might be advisable; we won't need to refresh the context then...
Iterator it = pc.runQuery(query);
return new ExecutableContextIterator(it);
}