spring的源码研究一

@startuml
note top of SpringApplicationBuilder
end note
class SpringApplicationBuilder{
- SpringApplication application
+ SpringApplicationBuilder(Class<?>... sources)
# SpringApplication createSpringApplication(Class<?>... sources)
}
SpringApplicationBuilder +-- SpringApplication
note top of SpringApplication
1.
end note
class SpringApplication{
+ SpringApplication(Class<?>... primarySources)
+ SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources)
+ ConfigurableApplicationContext run(String... args)
+ ClassLoader getClassLoader()
- <T> Collection<T> getSpringFactoriesInstances(Class<T> type)
- <T> Collection<T> getSpringFactoriesInstances(Class<T> type, Class<?>[] parameterTypes, Object... args)
- <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] parameterTypes, ClassLoader classLoader, Object[] args, Set<String> names)
- SpringApplicationRunListeners getRunListeners(String[] args)
}
SpringApplication +-- ClassUtils
note top of ClassUtils
end note
abstract class ClassUtils{
+ Class<?> forName(String name, @Nullable ClassLoader classLoader)
}
ClassUtils +-- Class
note top of Class
核心方法:
1:forName(?) || forName(?,?,?) ===> forName0(?,?,?,?)
2:getDeclaredConstructor(?):
3:native registerNatives()方法 可以从本地加载方法的执行
end note
class Class implements Serializable,GenericDeclaration,Type,AnnotatedElement{
+ Class<?> forName(String className)
+ Class<?> forName(String name, boolean initialize, ClassLoader loader)
+ Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
- Constructor<T> getConstructor0(Class<?>[] parameterTypes, int which)
- native Class<?> forName0(String name, boolean initialize,ClassLoader loader, Class<?> caller)
- native void registerNatives()
}
interface Serializable{}
interface GenericDeclaration extends AnnotatedElement{}
interface Type{}
interface AnnotatedElement{}
note top of BeanUtils
end note
abstract class BeanUtils{
+ <T> T instantiateClass(Constructor<T> ctor, Object... args)
}
SpringApplication +-- SpringApplicationRunListeners
note top of SpringApplicationRunListeners
end note
class SpringApplicationRunListeners{
- List<SpringApplicationRunListener> listeners
# SpringApplicationRunListeners(Log log, Collection<? extends SpringApplicationRunListener> listeners)
+ void starting()
+ void started(ConfigurableApplicationContext context)
+ void running(ConfigurableApplicationContext context)
}
SpringApplicationRunListeners +-- SpringApplicationRunListener
interface SpringApplicationRunListener{
# void starting()
}
@enduml