static List getCachedArtifact()

in core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ConfiguredArtifactUtils.java [67:111]


    static <T extends Serializable> List<T> getCachedArtifact(String key, Class<T> targetClass)
    {
        ClassLoader classLoader = ClassUtils.getClassLoader(null);
        if(String.class.isAssignableFrom(targetClass))
        {
            Map<String, Set<String>> cachedValueMap = configuredValueCache.get(classLoader);

            if(cachedValueMap != null)
            {
                List<String> result = new ArrayList<String>();
                Set<String> cachedValues = cachedValueMap.get(key);
                if (cachedValues != null && !cachedValues.isEmpty())
                {
                    result.addAll(cachedValues);
                }
                if(!result.isEmpty())
                {
                    return (List<T>)result;
                }
            }
            return null;
        }

        Map<ArtifactCacheKey<String>, Set<Serializable>> artifactCache = apiToImplCache.get(classLoader);

        if(artifactCache == null)
        {
            return null;
        }

        List<T> result = new ArrayList<T>();

        Set<T> cachedInstances = (Set<T>)artifactCache.get(new ArtifactCacheKey<String>(key, targetClass));

        if(cachedInstances == null)
        {
            return null;
        }
        for(T currentClass : cachedInstances)
        {
            result.add(currentClass);
        }
        Collections.sort(result, new InvocationOrderComparator<T>());
        return result;
    }