question: private List < Entitlement > evaluate ( String realm ) throws EntitlementException { final Debug debug = PolicyConstants . DEBUG ; final SubjectAttributesManager sam = SubjectAttributesManager . getInstance ( adminSubject , realm ) ; final Set < String > subjectIndexes = sam . getSubjectSearchFilter ( subject , applicationName ) ; final PrivilegeIndexStore indexStore = PrivilegeIndexStore . getInstance ( adminSubject , realm ) ; final Iterator < IPrivilege > policyIterator = indexStore . search ( realm , indexes , subjectIndexes , recursive ) ; int totalCount = 0 ; IPrivilege policy ; final Set < IPrivilege > localBatch = new HashSet < IPrivilege > ( 2 * TASKS_PER_THREAD ) ; while ( totalCount < TASKS_PER_THREAD && policyIterator . hasNext ( ) ) { policy = policyIterator . next ( ) ; if ( policy instanceof ReferralPrivilege ) { continue ; } if ( debug . messageEnabled ( ) ) { debug . message ( "[PolicyEval] PolicyEvaluator.evaluate" ) ; debug . message ( "[PolicyEval] search result: privilege=" + policy . getName ( ) ) ; } localBatch . add ( policy ) ; totalCount ++ ; } final PrivilegeEvaluatorContext context = new PrivilegeEvaluatorContext ( realm , normalisedResourceName , applicationName ) ; final Object appToken = AppTokenHandler . getAndClear ( ) ; final Set < IPrivilege > threadBatch = new HashSet < IPrivilege > ( 2 * TASKS_PER_THREAD ) ; boolean tasksSubmitted = false ; while ( policyIterator . hasNext ( ) ) { tasksSubmitted = true ; policy = policyIterator . next ( ) ; if ( policy instanceof ReferralPrivilege ) { continue ; } if ( debug . messageEnabled ( ) ) { debug . message ( "[PolicyEval] PolicyEvaluator.evaluate" ) ; debug . message ( "[PolicyEval] search result: privilege=" + policy . getName ( ) ) ; } threadBatch . add ( policy ) ; totalCount ++ ; if ( threadBatch . size ( ) == TASKS_PER_THREAD ) { final Set < IPrivilege > copiedBatch = new HashSet < IPrivilege > ( threadBatch ) ; threadPool . submit ( new PrivilegeTask ( this , copiedBatch , isMultiThreaded , appToken , context ) ) ; threadBatch . clear ( ) ; } } if ( ! threadBatch . isEmpty ( ) ) { threadPool . submit ( new PrivilegeTask ( this , threadBatch , isMultiThreaded , appToken , context ) ) ; } final Runnable localTask = new PrivilegeTask ( this , localBatch , tasksSubmitted , appToken , context ) ; localTask . run ( ) ; if ( tasksSubmitted ) { if ( isMultiThreaded ) { receiveEvalResults ( totalCount ) ; } else { boolean isDone = false ; while ( ! resultQ . isEmpty ( ) && ! isDone ) { entitlementCombiner . add ( resultQ . remove ( 0 ) ) ; isDone = entitlementCombiner . isDone ( ) ; } } } else if ( eException == null ) { boolean isDone = false ; while ( ! resultQ . isEmpty ( ) && ! isDone ) { entitlementCombiner . add ( resultQ . remove ( 0 ) ) ; isDone = entitlementCombiner . isDone ( ) ; } } if ( eException != null ) { throw eException ; } return entitlementCombiner . getResults ( ) ; }
target:  Responsible for the core evaluation of policies associated with the request resource.