@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { List<TemplateAvailabilityProvider> availabilityProviders = SpringFactoriesLoader .loadFactories(TemplateAvailabilityProvider.class, context.getClassLoader()); for (TemplateAvailabilityProvider availabilityProvider : availabilityProviders) { if (availabilityProvider.isTemplateAvailable("error", context.getEnvironment(), context.getClassLoader(), context.getResourceLoader())) { return ConditionOutcome.noMatch("Template from " + availabilityProvider + " found for error view"); } } return ConditionOutcome.match("No error template view detected"); }
private ModelAndView resolve(String viewName, Map<String, Object> model) { String errorViewName = "error/" + viewName; TemplateAvailabilityProvider provider = this.templateAvailabilityProviders .getProvider(errorViewName, this.applicationContext); if (provider != null) { return new ModelAndView(errorViewName, model); } return resolveResource(errorViewName, model); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { TemplateAvailabilityProviders providers = new TemplateAvailabilityProviders( context.getClassLoader()); TemplateAvailabilityProvider provider = providers.getProvider("error", context.getEnvironment(), context.getClassLoader(), context.getResourceLoader()); if (provider != null) { return ConditionOutcome .noMatch("Template from " + provider + " found for error view"); } return ConditionOutcome.match("No error template view detected"); }
TestTemplateAvailabilityProviders(TemplateAvailabilityProvider provider) { super(Collections.singletonList(provider)); }