11/*
2- * Copyright 2002-2014 the original author or authors.
2+ * Copyright 2002-2015 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
3131 * Encapsulates information about an {@linkplain ControllerAdvice @ControllerAdvice}
3232 * Spring-managed bean without necessarily requiring it to be instantiated.
3333 *
34- * <p>The {@link #findAnnotatedBeans(ApplicationContext)} method can be used to discover
35- * such beans. However, an {@code ControllerAdviceBean} may be created from
36- * any object, including ones without an {@code @ControllerAdvice}.
34+ * <p>The {@link #findAnnotatedBeans(ApplicationContext)} method can be used to
35+ * discover such beans. However, a {@code ControllerAdviceBean} may be created
36+ * from any object, including ones without an {@code @ControllerAdvice}.
3737 *
3838 * @author Rossen Stoyanchev
3939 * @since 3.2
@@ -42,13 +42,24 @@ public class ControllerAdviceBean implements Ordered {
4242
4343 private final Object bean ;
4444
45+ private final BeanFactory beanFactory ;
46+
4547 private final int order ;
4648
47- private final BeanFactory beanFactory ;
4849
50+ /**
51+ * Create a {@code ControllerAdviceBean} using the given bean instance.
52+ * @param bean the bean instance
53+ */
54+ public ControllerAdviceBean (Object bean ) {
55+ Assert .notNull (bean , "Bean must not be null" );
56+ this .bean = bean ;
57+ this .order = initOrderFromBean (bean );
58+ this .beanFactory = null ;
59+ }
4960
5061 /**
51- * Create an instance using the given bean name.
62+ * Create a {@code ControllerAdviceBean} using the given bean name.
5263 * @param beanName the name of the bean
5364 * @param beanFactory a BeanFactory that can be used later to resolve the bean
5465 */
@@ -66,29 +77,19 @@ public ControllerAdviceBean(String beanName, BeanFactory beanFactory) {
6677 this .order = initOrderFromBeanType (this .beanFactory .getType (beanName ));
6778 }
6879
69- /**
70- * Create an instance using the given bean instance.
71- * @param bean the bean
72- */
73- public ControllerAdviceBean (Object bean ) {
74- Assert .notNull (bean , "Bean must not be null" );
75- this .bean = bean ;
76- this .order = initOrderFromBean (bean );
77- this .beanFactory = null ;
78- }
79-
8080
8181 /**
8282 * Returns the order value extracted from the {@link ControllerAdvice}
83- * annotation or {@link Ordered#LOWEST_PRECEDENCE} otherwise.
83+ * annotation, or {@link Ordered#LOWEST_PRECEDENCE} otherwise.
8484 */
8585 public int getOrder () {
8686 return this .order ;
8787 }
8888
8989 /**
90- * Returns the type of the contained bean.
91- * If the bean type is a CGLIB-generated class, the original, user-defined class is returned.
90+ * Return the type of the contained bean.
91+ * <p>If the bean type is a CGLIB-generated class, the original
92+ * user-defined class is returned.
9293 */
9394 public Class <?> getBeanType () {
9495 Class <?> clazz = (this .bean instanceof String ?
0 commit comments