1
1
/*
2
- * Copyright 2002-2014 the original author or authors.
2
+ * Copyright 2002-2016 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.
@@ -425,9 +425,7 @@ public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, St
425
425
* @see #doCreateBean
426
426
*/
427
427
@ Override
428
- protected Object createBean (final String beanName , final RootBeanDefinition mbd , final Object [] args )
429
- throws BeanCreationException {
430
-
428
+ protected Object createBean (String beanName , RootBeanDefinition mbd , Object [] args ) throws BeanCreationException {
431
429
if (logger .isDebugEnabled ()) {
432
430
logger .debug ("Creating instance of bean '" + beanName + "'" );
433
431
}
@@ -596,7 +594,7 @@ protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Clas
596
594
}
597
595
598
596
/**
599
- * Determine the bean type for the given bean definition which is based on
597
+ * Determine the target type for the given bean definition which is based on
600
598
* a factory method. Only called if there is no singleton instance registered
601
599
* for the target bean already.
602
600
* <p>This implementation determines the type matching {@link #createBean}'s
@@ -606,7 +604,7 @@ protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Clas
606
604
* @param mbd the merged bean definition for the bean
607
605
* @param typesToMatch the types to match in case of internal type matching purposes
608
606
* (also signals that the returned {@code Class} will never be exposed to application code)
609
- * @return the type for the bean if determinable, or {@code null} else
607
+ * @return the type for the bean if determinable, or {@code null} otherwise
610
608
* @see #createBean
611
609
*/
612
610
protected Class <?> getTypeForFactoryMethod (String beanName , RootBeanDefinition mbd , Class [] typesToMatch ) {
@@ -745,10 +743,14 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
745
743
if (objectType .value != null ) {
746
744
return objectType .value ;
747
745
}
746
+ else {
747
+ // No type found for shortcut FactoryBean instance:
748
+ // fall back to full creation of the FactoryBean instance.
749
+ return super .getTypeForFactoryBean (beanName , mbd );
750
+ }
748
751
}
749
752
750
- // No type found - fall back to full creation of the FactoryBean instance.
751
- return super .getTypeForFactoryBean (beanName , mbd );
753
+ return null ;
752
754
}
753
755
754
756
/**
@@ -767,7 +769,7 @@ protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd,
767
769
SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor ) bp ;
768
770
exposedObject = ibp .getEarlyBeanReference (exposedObject , beanName );
769
771
if (exposedObject == null ) {
770
- return exposedObject ;
772
+ return null ;
771
773
}
772
774
}
773
775
}
@@ -782,8 +784,7 @@ protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd,
782
784
783
785
/**
784
786
* Obtain a "shortcut" singleton FactoryBean instance to use for a
785
- * {@code getObjectType()} call, without full initialization
786
- * of the FactoryBean.
787
+ * {@code getObjectType()} call, without full initialization of the FactoryBean.
787
788
* @param beanName the name of the bean
788
789
* @param mbd the bean definition for the bean
789
790
* @return the FactoryBean instance, or {@code null} to indicate
@@ -824,8 +825,7 @@ private FactoryBean<?> getSingletonFactoryBeanForTypeCheck(String beanName, Root
824
825
825
826
/**
826
827
* Obtain a "shortcut" non-singleton FactoryBean instance to use for a
827
- * {@code getObjectType()} call, without full initialization
828
- * of the FactoryBean.
828
+ * {@code getObjectType()} call, without full initialization of the FactoryBean.
829
829
* @param beanName the name of the bean
830
830
* @param mbd the bean definition for the bean
831
831
* @return the FactoryBean instance, or {@code null} to indicate
0 commit comments