@@ -207,8 +207,8 @@ public Object getBean(String name, Object... args) throws BeansException {
207
207
* Return an instance, which may be shared or independent, of the specified bean.
208
208
* @param name the name of the bean to retrieve
209
209
* @param requiredType the required type of the bean to retrieve
210
- * @param args arguments to use if creating a prototype using explicit arguments to a
211
- * static factory method. It is invalid to use a non-null args value in any other case.
210
+ * @param args arguments to use when creating a bean instance using explicit arguments
211
+ * (only applied when creating a new instance as opposed to retrieving an existing one)
212
212
* @return an instance of the bean
213
213
* @throws BeansException if the bean could not be created
214
214
*/
@@ -220,8 +220,8 @@ public <T> T getBean(String name, Class<T> requiredType, Object... args) throws
220
220
* Return an instance, which may be shared or independent, of the specified bean.
221
221
* @param name the name of the bean to retrieve
222
222
* @param requiredType the required type of the bean to retrieve
223
- * @param args arguments to use if creating a prototype using explicit arguments to a
224
- * static factory method. It is invalid to use a non-null args value in any other case.
223
+ * @param args arguments to use when creating a bean instance using explicit arguments
224
+ * (only applied when creating a new instance as opposed to retrieving an existing one)
225
225
* @param typeCheckOnly whether the instance is obtained for a type check,
226
226
* not for actual use
227
227
* @return an instance of the bean
@@ -1266,17 +1266,9 @@ protected RootBeanDefinition getMergedBeanDefinition(
1266
1266
protected void checkMergedBeanDefinition (RootBeanDefinition mbd , String beanName , Object [] args )
1267
1267
throws BeanDefinitionStoreException {
1268
1268
1269
- // check if bean definition is not abstract
1270
1269
if (mbd .isAbstract ()) {
1271
1270
throw new BeanIsAbstractException (beanName );
1272
1271
}
1273
-
1274
- // Check validity of the usage of the args parameter. This can
1275
- // only be used for prototypes constructed via a factory method.
1276
- if (args != null && !mbd .isPrototype ()) {
1277
- throw new BeanDefinitionStoreException (mbd .getResourceDescription (), beanName ,
1278
- "Can only specify arguments for the getBean method when referring to a prototype bean definition" );
1279
- }
1280
1272
}
1281
1273
1282
1274
/**
@@ -1619,15 +1611,13 @@ protected void registerDisposableBeanIfNecessary(String beanName, Object bean, R
1619
1611
protected abstract BeanDefinition getBeanDefinition (String beanName ) throws BeansException ;
1620
1612
1621
1613
/**
1622
- * Create a bean instance for the given bean definition.
1623
- * The bean definition will already have been merged with the parent
1624
- * definition in case of a child definition.
1625
- * <p>All the other methods in this class invoke this method, although
1626
- * beans may be cached after being instantiated by this method. All bean
1627
- * instantiation within this class is performed by this method.
1614
+ * Create a bean instance for the given merged bean definition (and arguments).
1615
+ * The bean definition will already have been merged with the parent definition
1616
+ * in case of a child definition.
1617
+ * <p>All bean retrieval methods delegate to this method for actual bean creation.
1628
1618
* @param beanName the name of the bean
1629
1619
* @param mbd the merged bean definition for the bean
1630
- * @param args arguments to use if creating a prototype using explicit arguments
1620
+ * @param args explicit arguments to use for constructor or factory method invocation
1631
1621
* @return a new instance of the bean
1632
1622
* @throws BeanCreationException if the bean could not be created
1633
1623
*/
0 commit comments