LinkedList<ErrorService> currentErrorHandlers = null;
ImmediateResults immediate = null;
if (!useCache) {
final Filter filter = new UnqualifiedIndexedFilter(rawClass.getName(), name, unqualified);
rLock.lock();
try {
List<SystemDescriptor<?>> candidates = getDescriptors(filter, onBehalfOf, true, false, true);
immediate = narrow(this,
candidates,
contractOrImpl,
name,
onBehalfOf,
true,
true,
null,
filter,
qualifiers);
results = immediate.getTimelessResults();
if (!results.getErrors().isEmpty()) {
currentErrorHandlers = new LinkedList<ErrorService>(errorHandlers);
// was outside of the lock:
Utilities.handleErrors(results, currentErrorHandlers);
}
} finally {
rLock.unlock();
}
// Must do validation here in order to allow for caching
ActiveDescriptor<T> postValidateResult = immediate.getImmediateResults().isEmpty() ? null
: (ActiveDescriptor<T>) immediate.getImmediateResults().get(0);
return postValidateResult;
} else { // USE CACHE!
final CacheKey cacheKey = new CacheKey(contractOrImpl, name, qualifiers);
final Filter filter = BuilderHelper.createNameAndContractFilter(rawClass.getName(), name);
final IgdCacheKey igdCacheKey = new IgdCacheKey(cacheKey, name, onBehalfOf, contractOrImpl, rawClass, qualifiers, filter);
rLock.lock();
try {
final HybridCacheEntry<IgdValue> entry = igdCache.compute(igdCacheKey);