@Override
    public CachedMetadataResolverResult load(final SamlRegisteredServiceCacheKey cacheKey) {
        val metadataResolvers = loadMetadataResolvers(cacheKey);
        if (metadataResolvers.isEmpty()) {
            val registeredService = cacheKey.getRegisteredService();
            val metadataLocation = SpringExpressionLanguageValueResolver.getInstance().resolve(registeredService.getMetadataLocation());
            throw new SamlException("No metadata resolvers could be configured for service " + registeredService.getName()
                + " with metadata location " + metadataLocation);
        }

        val metadataResolver = initializeChainingMetadataResolver(metadataResolvers);
        LOGGER.debug("Metadata resolvers active for this request are [{}]", Objects.requireNonNull(metadataResolvers));
        return CachedMetadataResolverResult
            .builder()
            .cachedInstant(Instant.now(Clock.systemUTC()))
            .metadataResolver(metadataResolver)
            .build();
    }
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