@@ -18,7 +18,6 @@ package org.springframework.context.support
18
18
19
19
import org.springframework.beans.factory.config.BeanDefinition
20
20
import org.springframework.beans.factory.config.BeanDefinitionCustomizer
21
- import org.springframework.beans.factory.support.AbstractBeanDefinition
22
21
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils
23
22
import org.springframework.context.ApplicationContextInitializer
24
23
import org.springframework.core.env.ConfigurableEnvironment
@@ -112,38 +111,6 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
112
111
PROTOTYPE
113
112
}
114
113
115
- /* *
116
- * Autowire enum constants.
117
- */
118
- enum class Autowire {
119
-
120
- /* *
121
- * Autowire constant that indicates no externally defined autowiring
122
- * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory.AUTOWIRE_NO
123
- */
124
- NO ,
125
-
126
- /* *
127
- * Autowire constant that indicates autowiring bean properties by name
128
- * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory.AUTOWIRE_BY_NAME
129
- */
130
- BY_NAME ,
131
-
132
- /* *
133
- * Autowire constant that indicates autowiring bean properties by type
134
- * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE
135
- */
136
- BY_TYPE ,
137
-
138
- /* *
139
- * Autowire constant that indicates autowiring the greediest constructor that can be satisfied
140
- * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR
141
- */
142
- CONSTRUCTOR
143
-
144
- }
145
-
146
-
147
114
/* *
148
115
* Role enum constants.
149
116
*/
@@ -181,11 +148,13 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
181
148
/* *
182
149
* Declare a bean definition from the given bean class which can be inferred when possible.
183
150
*
151
+ * <p>The preferred constructor (Kotlin primary constructor and standard public constructors)
152
+ * are evaluated for autowiring before falling back to default instantiation.
153
+ *
184
154
* @param name the name of the bean
185
155
* @param scope Override the target scope of this bean, specifying a new scope name.
186
156
* @param isLazyInit Set whether this bean should be lazily initialized.
187
157
* @param isPrimary Set whether this bean is a primary autowire candidate.
188
- * @param autowireMode Set the autowire mode, `Autowire.CONSTRUCTOR` by default
189
158
* @param isAutowireCandidate Set whether this bean is a candidate for getting
190
159
* autowired into some other bean.
191
160
* @param initMethodName Set the name of the initializer method
@@ -199,7 +168,6 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
199
168
scope : Scope ? = null,
200
169
isLazyInit : Boolean? = null,
201
170
isPrimary : Boolean? = null,
202
- autowireMode : Autowire = Autowire .CONSTRUCTOR ,
203
171
isAutowireCandidate : Boolean? = null,
204
172
initMethodName : String? = null,
205
173
destroyMethodName : String? = null,
@@ -215,9 +183,6 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
215
183
destroyMethodName?.let { bd.destroyMethodName = destroyMethodName }
216
184
description?.let { bd.description = description }
217
185
bd.role = role.ordinal
218
- if (bd is AbstractBeanDefinition ) {
219
- bd.autowireMode = autowireMode.ordinal
220
- }
221
186
}
222
187
223
188
val beanName = name ? : BeanDefinitionReaderUtils .uniqueBeanName(T ::class .java.name, context);
@@ -231,7 +196,6 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
231
196
* @param scope Override the target scope of this bean, specifying a new scope name.
232
197
* @param isLazyInit Set whether this bean should be lazily initialized.
233
198
* @param isPrimary Set whether this bean is a primary autowire candidate.
234
- * @param autowireMode Set the autowire mode, `Autowire.NO` by default
235
199
* @param isAutowireCandidate Set whether this bean is a candidate for getting
236
200
* autowired into some other bean.
237
201
* @param initMethodName Set the name of the initializer method
@@ -246,7 +210,6 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
246
210
scope : Scope ? = null,
247
211
isLazyInit : Boolean? = null,
248
212
isPrimary : Boolean? = null,
249
- autowireMode : Autowire = Autowire .NO ,
250
213
isAutowireCandidate : Boolean? = null,
251
214
initMethodName : String? = null,
252
215
destroyMethodName : String? = null,
@@ -263,9 +226,6 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
263
226
destroyMethodName?.let { bd.destroyMethodName = destroyMethodName }
264
227
description?.let { bd.description = description }
265
228
bd.role = role.ordinal
266
- if (bd is AbstractBeanDefinition ) {
267
- bd.autowireMode = autowireMode.ordinal
268
- }
269
229
}
270
230
271
231
0 commit comments