21
21
import java .io .ObjectInputStream ;
22
22
import java .io .ObjectStreamException ;
23
23
import java .io .Serializable ;
24
+
24
25
import java .lang .annotation .Annotation ;
25
26
import java .lang .ref .Reference ;
26
27
import java .lang .ref .WeakReference ;
27
- import java .lang .reflect .ParameterizedType ;
28
- import java .lang .reflect .Type ;
28
+
29
29
import java .security .AccessController ;
30
30
import java .security .PrivilegedAction ;
31
+
31
32
import java .util .ArrayList ;
32
33
import java .util .Arrays ;
33
34
import java .util .Collection ;
38
39
import java .util .Map ;
39
40
import java .util .Set ;
40
41
import java .util .concurrent .ConcurrentHashMap ;
42
+
41
43
import javax .inject .Provider ;
42
44
43
45
import org .springframework .beans .BeansException ;
98
100
public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory
99
101
implements ConfigurableListableBeanFactory , BeanDefinitionRegistry , Serializable {
100
102
101
- private static Class javaxInjectProviderClass = null ;
103
+ private static Class <?> javaxInjectProviderClass = null ;
102
104
103
105
static {
104
106
ClassLoader cl = DefaultListableBeanFactory .class .getClassLoader ();
@@ -128,7 +130,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
128
130
private AutowireCandidateResolver autowireCandidateResolver = new SimpleAutowireCandidateResolver ();
129
131
130
132
/** Map from dependency type to corresponding autowired value */
131
- private final Map <Class , Object > resolvableDependencies = new HashMap <Class , Object >();
133
+ private final Map <Class <?> , Object > resolvableDependencies = new HashMap <Class <?> , Object >();
132
134
133
135
/** Map of bean definition objects, keyed by bean name */
134
136
private final Map <String , BeanDefinition > beanDefinitionMap = new ConcurrentHashMap <String , BeanDefinition >();
@@ -294,11 +296,11 @@ public String[] getBeanDefinitionNames() {
294
296
}
295
297
}
296
298
297
- public String [] getBeanNamesForType (Class type ) {
299
+ public String [] getBeanNamesForType (Class <?> type ) {
298
300
return getBeanNamesForType (type , true , true );
299
301
}
300
302
301
- public String [] getBeanNamesForType (Class type , boolean includeNonSingletons , boolean allowEagerInit ) {
303
+ public String [] getBeanNamesForType (Class <?> type , boolean includeNonSingletons , boolean allowEagerInit ) {
302
304
List <String > result = new ArrayList <String >();
303
305
304
306
// Check all bean definitions.
@@ -441,7 +443,7 @@ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> an
441
443
*/
442
444
public <A extends Annotation > A findAnnotationOnBean (String beanName , Class <A > annotationType ) {
443
445
A ann = null ;
444
- Class beanType = getType (beanName );
446
+ Class <?> beanType = getType (beanName );
445
447
if (beanType != null ) {
446
448
ann = AnnotationUtils .findAnnotation (beanType , annotationType );
447
449
}
@@ -564,18 +566,18 @@ public void preInstantiateSingletons() throws BeansException {
564
566
RootBeanDefinition bd = getMergedLocalBeanDefinition (beanName );
565
567
if (!bd .isAbstract () && bd .isSingleton () && !bd .isLazyInit ()) {
566
568
if (isFactoryBean (beanName )) {
567
- final FactoryBean factory = (FactoryBean ) getBean (FACTORY_BEAN_PREFIX + beanName );
569
+ final FactoryBean <?> factory = (FactoryBean <?> ) getBean (FACTORY_BEAN_PREFIX + beanName );
568
570
boolean isEagerInit ;
569
571
if (System .getSecurityManager () != null && factory instanceof SmartFactoryBean ) {
570
572
isEagerInit = AccessController .doPrivileged (new PrivilegedAction <Boolean >() {
571
573
public Boolean run () {
572
- return ((SmartFactoryBean ) factory ).isEagerInit ();
574
+ return ((SmartFactoryBean <?> ) factory ).isEagerInit ();
573
575
}
574
576
}, getAccessControlContext ());
575
577
}
576
578
else {
577
579
isEagerInit = (factory instanceof SmartFactoryBean &&
578
- ((SmartFactoryBean ) factory ).isEagerInit ());
580
+ ((SmartFactoryBean <?> ) factory ).isEagerInit ());
579
581
}
580
582
if (isEagerInit ) {
581
583
getBean (beanName );
@@ -723,7 +725,7 @@ protected Object doResolveDependency(DependencyDescriptor descriptor, Class<?> t
723
725
}
724
726
725
727
if (type .isArray ()) {
726
- Class componentType = type .getComponentType ();
728
+ Class <?> componentType = type .getComponentType ();
727
729
Map <String , Object > matchingBeans = findAutowireCandidates (beanName , componentType , descriptor );
728
730
if (matchingBeans .isEmpty ()) {
729
731
if (descriptor .isRequired ()) {
@@ -738,7 +740,7 @@ protected Object doResolveDependency(DependencyDescriptor descriptor, Class<?> t
738
740
return converter .convertIfNecessary (matchingBeans .values (), type );
739
741
}
740
742
else if (Collection .class .isAssignableFrom (type ) && type .isInterface ()) {
741
- Class elementType = descriptor .getCollectionType ();
743
+ Class <?> elementType = descriptor .getCollectionType ();
742
744
if (elementType == null ) {
743
745
if (descriptor .isRequired ()) {
744
746
throw new FatalBeanException ("No element type declared for collection [" + type .getName () + "]" );
@@ -759,15 +761,15 @@ else if (Collection.class.isAssignableFrom(type) && type.isInterface()) {
759
761
return converter .convertIfNecessary (matchingBeans .values (), type );
760
762
}
761
763
else if (Map .class .isAssignableFrom (type ) && type .isInterface ()) {
762
- Class keyType = descriptor .getMapKeyType ();
764
+ Class <?> keyType = descriptor .getMapKeyType ();
763
765
if (keyType == null || !String .class .isAssignableFrom (keyType )) {
764
766
if (descriptor .isRequired ()) {
765
767
throw new FatalBeanException ("Key type [" + keyType + "] of map [" + type .getName () +
766
768
"] must be assignable to [java.lang.String]" );
767
769
}
768
770
return null ;
769
771
}
770
- Class valueType = descriptor .getMapValueType ();
772
+ Class <?> valueType = descriptor .getMapValueType ();
771
773
if (valueType == null ) {
772
774
if (descriptor .isRequired ()) {
773
775
throw new FatalBeanException ("No value type declared for map [" + type .getName () + "]" );
@@ -828,12 +830,12 @@ else if (Map.class.isAssignableFrom(type) && type.isInterface()) {
828
830
* @see #autowireConstructor
829
831
*/
830
832
protected Map <String , Object > findAutowireCandidates (
831
- String beanName , Class requiredType , DependencyDescriptor descriptor ) {
833
+ String beanName , Class <?> requiredType , DependencyDescriptor descriptor ) {
832
834
833
835
String [] candidateNames = BeanFactoryUtils .beanNamesForTypeIncludingAncestors (
834
836
this , requiredType , true , descriptor .isEager ());
835
837
Map <String , Object > result = new LinkedHashMap <String , Object >(candidateNames .length );
836
- for (Class autowiringType : this .resolvableDependencies .keySet ()) {
838
+ for (Class <?> autowiringType : this .resolvableDependencies .keySet ()) {
837
839
if (autowiringType .isAssignableFrom (requiredType )) {
838
840
Object autowiringValue = this .resolvableDependencies .get (autowiringType );
839
841
autowiringValue = AutowireUtils .resolveAutowiringValue (autowiringValue , requiredType );
@@ -918,7 +920,7 @@ protected boolean matchesBeanName(String beanName, String candidateName) {
918
920
* Raise a NoSuchBeanDefinitionException for an unresolvable dependency.
919
921
*/
920
922
private void raiseNoSuchBeanDefinitionException (
921
- Class type , String dependencyDescription , DependencyDescriptor descriptor )
923
+ Class <?> type , String dependencyDescription , DependencyDescriptor descriptor )
922
924
throws NoSuchBeanDefinitionException {
923
925
924
926
throw new NoSuchBeanDefinitionException (type , dependencyDescription ,
@@ -967,6 +969,7 @@ protected Object writeReplace() throws ObjectStreamException {
967
969
* Minimal id reference to the factory.
968
970
* Resolved to the actual factory instance on deserialization.
969
971
*/
972
+ @ SuppressWarnings ("serial" )
970
973
private static class SerializedBeanFactoryReference implements Serializable {
971
974
972
975
private final String id ;
@@ -976,7 +979,7 @@ public SerializedBeanFactoryReference(String id) {
976
979
}
977
980
978
981
private Object readResolve () {
979
- Reference ref = serializableFactories .get (this .id );
982
+ Reference <?> ref = serializableFactories .get (this .id );
980
983
if (ref == null ) {
981
984
throw new IllegalStateException (
982
985
"Cannot deserialize BeanFactory with id " + this .id + ": no factory registered for this id" );
@@ -994,7 +997,8 @@ private Object readResolve() {
994
997
/**
995
998
* Serializable ObjectFactory for lazy resolution of a dependency.
996
999
*/
997
- private class DependencyObjectFactory implements ObjectFactory , Serializable {
1000
+ @ SuppressWarnings ("serial" )
1001
+ private class DependencyObjectFactory implements ObjectFactory <Object >, Serializable {
998
1002
999
1003
private final DependencyDescriptor descriptor ;
1000
1004
@@ -1015,7 +1019,8 @@ public Object getObject() throws BeansException {
1015
1019
/**
1016
1020
* Serializable ObjectFactory for lazy resolution of a dependency.
1017
1021
*/
1018
- private class DependencyProvider extends DependencyObjectFactory implements Provider {
1022
+ @ SuppressWarnings ("serial" )
1023
+ private class DependencyProvider extends DependencyObjectFactory implements Provider <Object > {
1019
1024
1020
1025
public DependencyProvider (DependencyDescriptor descriptor , String beanName ) {
1021
1026
super (descriptor , beanName );
0 commit comments