|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2016 the original author or authors.
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -22,9 +22,10 @@ import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.BeanFactory;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.BeanFactoryAware;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.ListableBeanFactory;
|
|
|
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
|
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
|
|
|
|
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
|
|
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -32,19 +33,19 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
|
|
|
* factory to {@link ErrorPageRegistry} beans.
|
|
|
|
* factory to {@link ErrorPageRegistry} beans.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @author Phillip Webb
|
|
|
|
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @since 1.4.0
|
|
|
|
* @since 1.4.0
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ErrorPageRegistrarBeanPostProcessor
|
|
|
|
public class ErrorPageRegistrarBeanPostProcessor
|
|
|
|
implements BeanPostProcessor, ApplicationContextAware {
|
|
|
|
implements BeanPostProcessor, BeanFactoryAware {
|
|
|
|
|
|
|
|
|
|
|
|
private ApplicationContext applicationContext;
|
|
|
|
private ListableBeanFactory beanFactory;
|
|
|
|
|
|
|
|
|
|
|
|
private List<ErrorPageRegistrar> registrars;
|
|
|
|
private List<ErrorPageRegistrar> registrars;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext)
|
|
|
|
public void setBeanFactory(BeanFactory beanFactory) {
|
|
|
|
throws BeansException {
|
|
|
|
this.beanFactory = (ListableBeanFactory) beanFactory;
|
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -71,7 +72,7 @@ public class ErrorPageRegistrarBeanPostProcessor
|
|
|
|
private Collection<ErrorPageRegistrar> getRegistrars() {
|
|
|
|
private Collection<ErrorPageRegistrar> getRegistrars() {
|
|
|
|
if (this.registrars == null) {
|
|
|
|
if (this.registrars == null) {
|
|
|
|
// Look up does not include the parent context
|
|
|
|
// Look up does not include the parent context
|
|
|
|
this.registrars = new ArrayList<ErrorPageRegistrar>(this.applicationContext
|
|
|
|
this.registrars = new ArrayList<ErrorPageRegistrar>(this.beanFactory
|
|
|
|
.getBeansOfType(ErrorPageRegistrar.class, false, false).values());
|
|
|
|
.getBeansOfType(ErrorPageRegistrar.class, false, false).values());
|
|
|
|
Collections.sort(this.registrars, AnnotationAwareOrderComparator.INSTANCE);
|
|
|
|
Collections.sort(this.registrars, AnnotationAwareOrderComparator.INSTANCE);
|
|
|
|
this.registrars = Collections.unmodifiableList(this.registrars);
|
|
|
|
this.registrars = Collections.unmodifiableList(this.registrars);
|
|
|
|