|
65 | 65 | />.</para> |
66 | 66 | </note> |
67 | 67 |
|
68 | | - <para>The |
69 | | - <interfacename>org.springframework.beans.factory.config.BeanPostProcessor</interfacename> |
| 68 | + <para>The <interfacename>org.springframework.beans.factory.config.BeanPostProcessor</interfacename> |
70 | 69 | interface consists of exactly two callback methods. When such a class is |
71 | 70 | registered as a post-processor with the container, for each bean instance |
72 | 71 | that is created by the container, the post-processor gets a callback from |
|
93 | 92 | <note> |
94 | 93 | <title>Programmatically registering <interfacename>BeanPostProcessors |
95 | 94 | </interfacename></title> |
96 | | - <para> |
97 | | - While the recommended approach for <interfacename>BeanPostProcessor |
| 95 | + <para>While the recommended approach for <interfacename>BeanPostProcessor |
98 | 96 | </interfacename> registration is through <interfacename>ApplicationContext |
99 | 97 | </interfacename> auto-detection (as described above), it is also |
100 | 98 | possible to register them <emphasis>programmatically</emphasis> |
|
108 | 106 | registration</emphasis> that dictates the order of execution. Note also |
109 | 107 | that <interfacename>BeanPostProcessors</interfacename> registered |
110 | 108 | programmatically are always processed before those registered through |
111 | | - auto-detection, regardless of any explicit ordering. |
112 | | - </para> |
| 109 | + auto-detection, regardless of any explicit ordering.</para> |
113 | 110 | </note> |
114 | 111 |
|
115 | 112 | <note> |
|
135 | 132 | <quote><emphasis>Bean foo is not eligible for getting processed by all |
136 | 133 | BeanPostProcessor interfaces (for example: not eligible for |
137 | 134 | auto-proxying)</emphasis></quote>.</para> |
| 135 | + |
| 136 | + <para>Note that if you have beans wired into your <interfacename>BeanPostProcessor</interfacename> |
| 137 | + using autowiring or <interfacename>@Resource</interfacename> (which may fall back to autowiring), |
| 138 | + Spring might access unexpected beans when searching for type-matching dependency candidates, |
| 139 | + and therefore make them ineligible for auto-proxying or other kinds of bean post-processing. |
| 140 | + For example, if you have a dependency annotated with <interfacename>@Resource</interfacename> |
| 141 | + where the field/setter name does not directly correspond to the declared name of a bean and |
| 142 | + no name attribute is used, then Spring will access other beans for matching them by type.</para> |
138 | 143 | </note> |
139 | 144 |
|
140 | 145 | <para>The following examples show how to write, register, and use |
|
0 commit comments