Home > Back-end >  Questions about the spring source code
Questions about the spring source code

Time:02-22

Org. Springframework. Beans. Factory. Support. DefaultListableBeanFactory. PreInstantiateSingletons () what's the use of variable isEagerInit inside? A mystery
 
//the Trigger initialization of all non - lazy singleton beans...
For (String beanName: beanNames) {
RootBeanDefinition bd=getMergedLocalBeanDefinition (beanName);
if (! Bd. IsAbstract () & amp; & Bd. IsSingleton () & amp; & ! Bd. IsLazyInit ()) {
If (isFactoryBean (beanName)) {
The Object bean=getBean (FACTORY_BEAN_PREFIX + beanName);
If (bean instanceof FactoryBean) {
Final FactoryBean<?> The factory=(FactoryBean<?>) Bean;
Boolean isEagerInit;
If (System. GetSecurityManager ()!=null & amp; & The factory instanceof SmartFactoryBean) {
IsEagerInit=the AccessController. DoPrivileged ((PrivilegedAction)
((SmartFactoryBean<?>) Factory) : : isEagerInit,
GetAccessControlContext ());
}
The else {
IsEagerInit=(factory instanceof SmartFactoryBean & amp; &
((SmartFactoryBean<?>) The factory). IsEagerInit ());
}
If (isEagerInit) {
GetBean (beanName);
}
}
}
The else {
GetBean (beanName);
}
}
}

If (System. GetSecurityManager ()!=null & amp; & The factory instanceof SmartFactoryBean) {}
Has the authority to the JVM is to determine whether a Java application and strong turned into the beanFactory whether belong to SmartFactoryBean type, regardless of whether a SmartFactoryBean type, whether to have the JVM permissions, isEagerInit will execute method, and isEagerInit in the case of default (spring write die) will return false, then isEagerInit always can only be false,
This variable is whether or not by judging will only be false, but my question is, isEagerInit variable is?

CodePudding user response:

That a don't need to care about, SmartFactoryBean proved to the interface above, translate the class notes,
Helping to find the relationship between the implementation under, found no implementation class
  • Related