1
1
/*
2
- * Copyright 2002-2016 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
20
20
import org .springframework .lang .Nullable ;
21
21
22
22
/**
23
- * Factory hook that allows for custom modification of new bean instances,
24
- * e.g. checking for marker interfaces or wrapping them with proxies.
25
- *
26
- * <p>ApplicationContexts can autodetect BeanPostProcessor beans in their
27
- * bean definitions and apply them to any beans subsequently created.
28
- * Plain bean factories allow for programmatic registration of post-processors,
29
- * applying to all beans created through this factory.
23
+ * Factory hook that allows for custom modification of new bean instances —
24
+ * for example, checking for marker interfaces or wrapping beans with proxies.
30
25
*
31
26
* <p>Typically, post-processors that populate beans via marker interfaces
32
27
* or the like will implement {@link #postProcessBeforeInitialization},
33
28
* while post-processors that wrap beans with proxies will normally
34
29
* implement {@link #postProcessAfterInitialization}.
35
30
*
31
+ * <h3>Registration</h3>
32
+ * <p>An {@code ApplicationContext} can autodetect {@code BeanPostProcessor} beans
33
+ * in its bean definitions and apply those post-processors to any beans subsequently
34
+ * created. A plain {@code BeanFactory} allows for programmatic registration of
35
+ * post-processors, applying them to all beans created through the bean factory.
36
+ *
37
+ * <h3>Ordering</h3>
38
+ * <p>{@code BeanPostProcessor} beans that are autodetected in an
39
+ * {@code ApplicationContext} will be ordered according to
40
+ * {@link org.springframework.core.PriorityOrdered} and
41
+ * {@link org.springframework.core.Ordered} semantics. In contrast,
42
+ * {@code BeanPostProcessor} beans that are registered programmatically with a
43
+ * {@code BeanFactory} will be applied in the order of registration; any ordering
44
+ * semantics expressed through implementing the
45
+ * {@code PriorityOrdered} or {@code Ordered} interface will be ignored for
46
+ * programmatically registered post-processors. Furthermore, the
47
+ * {@link org.springframework.core.annotation.Order @Order} annotation is not
48
+ * taken into account for {@code BeanPostProcessor} beans.
49
+ *
36
50
* @author Juergen Hoeller
51
+ * @author Sam Brannen
37
52
* @since 10.10.2003
38
53
* @see InstantiationAwareBeanPostProcessor
39
54
* @see DestructionAwareBeanPostProcessor
43
58
public interface BeanPostProcessor {
44
59
45
60
/**
46
- * Apply this BeanPostProcessor to the given new bean instance <i>before</i> any bean
61
+ * Apply this {@code BeanPostProcessor} to the given new bean instance <i>before</i> any bean
47
62
* initialization callbacks (like InitializingBean's {@code afterPropertiesSet}
48
63
* or a custom init-method). The bean will already be populated with property values.
49
64
* The returned bean instance may be a wrapper around the original.
@@ -61,7 +76,7 @@ default Object postProcessBeforeInitialization(Object bean, String beanName) thr
61
76
}
62
77
63
78
/**
64
- * Apply this BeanPostProcessor to the given new bean instance <i>after</i> any bean
79
+ * Apply this {@code BeanPostProcessor} to the given new bean instance <i>after</i> any bean
65
80
* initialization callbacks (like InitializingBean's {@code afterPropertiesSet}
66
81
* or a custom init-method). The bean will already be populated with property values.
67
82
* The returned bean instance may be a wrapper around the original.
@@ -71,7 +86,7 @@ default Object postProcessBeforeInitialization(Object bean, String beanName) thr
71
86
* objects or both through corresponding {@code bean instanceof FactoryBean} checks.
72
87
* <p>This callback will also be invoked after a short-circuiting triggered by a
73
88
* {@link InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation} method,
74
- * in contrast to all other BeanPostProcessor callbacks.
89
+ * in contrast to all other {@code BeanPostProcessor} callbacks.
75
90
* <p>The default implementation returns the given {@code bean} as-is.
76
91
* @param bean the new bean instance
77
92
* @param beanName the name of the bean
0 commit comments