protected List<MetadataResolver> loadMetadataResolvers(final SamlRegisteredServiceCacheKey cacheKey) {
        val availableResolvers = metadataResolutionPlan.getRegisteredMetadataResolvers();
        LOGGER.debug("There are [{}] metadata resolver(s) available in the chain", availableResolvers.size());
        val registeredService = cacheKey.getRegisteredService();
        return availableResolvers
            .stream()
            .filter(Objects::nonNull)
            .filter(resolver -> {
                LOGGER.trace("Evaluating whether metadata resolver [{}] can support service [{}]", resolver.getName(), registeredService.getName());
                return resolver.supports(registeredService);
            })
            .map(Unchecked.function(resolver -> {
                LOGGER.trace("Metadata resolver [{}] has started to process metadata for [{}]", resolver.getName(), registeredService.getName());
                return resolver.resolve(registeredService, cacheKey.getCriteriaSet());
            }))
            .flatMap(Collection::stream)
            .filter(Objects::nonNull)
            .peek(Unchecked.consumer(givenResolver -> {
                if (givenResolver instanceof final AbstractIdentifiableInitializableComponent metadataResolver && !metadataResolver.isInitialized()) {
                    FunctionUtils.doIfBlank(metadataResolver.getId(), __ -> metadataResolver.setId(registeredService.getName() + '-' + RandomUtils.generateSecureRandomId()));
                    LOGGER.trace("Metadata resolver [{}] will be forcefully initialized", metadataResolver.getId());
                    metadataResolver.initialize();
                }
            }))
            .collect(Collectors.toList());
    }
This is {@link SamlRegisteredServiceMetadataResolverCacheLoader} that uses Guava's cache loading strategy
to keep track of metadata resources and resolvers. The cache loader here supports loading
metadata resources from SAML services, supports dynamic metadata queries and is able
to run various validation filters on the metadata before finally caching the resolver.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-saml-idp-metadata/src/main/java/org/apereo/cas/support/saml/services/idp/metadata/cache/SamlRegisteredServiceMetadataResolverCacheLoader.java