sxd-spring-aop-12启动概要
2023-03-10 14:18:50 6 举报
AI智能生成
sxd-spring启动概要
作者其他创作
大纲/内容
xml
new ConditionContextImpl
AnnotationAwareOrderComparator
ContextAnnotationAutowireCandidateResolver
ConfigurationClassPostProcessor
AutowiredAnnotationBeanPostProcessor
CommonAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor
EventListenerMethodProcessor
DefaultEventListenerFactory
registerAnnotationConfigProcessors
new AnnotatedBeanDefinitionReader
Component
ManagedBean
Named
registerDefaultFilters
new ClassPathBeanDefinitionScanner
this()
new AnnotatedGenericBeanDefinition
register(componentClasses)
ApplicationContextAwareProcessor
ApplicationListenerDetector
EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationContextAware
prepareBeanFactory
new ConfigurationClassParser
new ScannedGenericBeanDefinition
new ClassPathBeanDefinitionScanner # doScan
ComponentScanAnnotationParser#parse
ConfigurationClassParser#parse
AnnotationAwareAspectJAutoProxyCreator
AutoProxyRegistrar
ProxyTransactionManagementConfiguration
TransactionManagementConfigurationSelector
processImports
loadBeanDefinitionsForConfigurationClass
loadBeanDefinitions
# postProcessBeanDefinitionRegistry
ImportAwareBeanPostProcessor
BeanDefinitionRegistryPostProcessor
# postProcessBeanFactory
BeanFactoryPostProcessor
invokeBeanFactoryPostProcessors
refresh()
ConfigurationClassPostProcessor -》 ImportAwareBeanPostProcessor
AspectJAwareAdvisorAutoProxyCreator
InstantiationAwareBeanPostProcessor
applyBeanPostProcessorsBeforeInstantiation
applyBeanPostProcessorsAfterInitialization
resolveBeforeInstantiation
MergedBeanDefinitionPostProcessor
applyMergedBeanDefinitionPostProcessors
createBeanInstance
ConfigurationClassPostProcessor -》 ImportAwareBeanPostProcessor
postProcessAfterInstantiation
postProcessProperties
populateBean
BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
invokeAwareMethods
ImportAware
ConfigurationClassPostProcessor -》 ImportAwareBeanPostProcessor
PostProcessorRegistrationDelegate -> BeanPostProcessorChecker
InstantiationAwareBeanPostProcessorAdapter -> AutowiredAnnotationBeanPostProcessor
BeanPostProcessor
postProcessBeforeInitialization
applyBeanPostProcessorsBeforeInitialization
invokeInitMethods
InstantiationAwareBeanPostProcessorAdapter -> AutowiredAnnotationBeanPostProcessor
postProcessAfterInitialization
initializeBean
doCreateBean
getBean -> doGetBean -> createBean
finishBeanFactoryInitialization
AnnotationConfigApplicationContext
注解
configureAutoProxyCreator
aspectFactoryDef -> MethodLocatingFactoryBean
methodDefinition-> SimpleBeanFactoryAwareAspectInstanceFactory
AspectJAroundAdvice
AspectJMethodBeforeAdvice
AspectJAfterAdvice
AspectJAfterReturningAdvice
AspectJAfterThrowingAdvice
createAdviceDefinition
AspectJPointcutAdvisor
new RootBeanDefinition(AspectJPointcutAdvisor
parseAdvice aop:aroundaop: beforeaop:afteraop: returningaop: afterThrowing
AspectJExpressionPointcut
new RootBeanDefinition(AspectJExpressionPointcut.class)
parsePointcut
aspectElement.getChildNodes()
ConfigBeanDefinitionParser#parseparseAspect加载bd
# shouldSkip
resolveBeforeInstantiation创建对象前置时创建所有的advisor
ExposeInvocationInterceptor
findEligibleAdvisors # extendxxx
StaticUnadvisedInterceptor
DynamicUnadvisedInterceptor
getCallbacks
wrapIfNecessary
createBean()# 非Spring内置对象
创建bean
Object interceptorOrInterceptionAdvice = this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex)
mi.proceed();
((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this)
1: ExposeInvocationInterceptor
try { mi.proceed();
2:AspectjAfterThrowingAdvice
3: AfterRunturningAdviceInterceptor
argBinding
invokeAdviceMethodWithGivenArgs
4: AspectAfterAdvice
ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
JoinPointMatch jpm = getJoinPointMatch(pmi);
5: AspectARoundAdvice
ReflectiveMethodInvocation#proceed执行父类的方法
CglibAopProxy.DynamicAdvisedInterceptor#intercept
执行
xml 执行流程
ConfigurationClassPostProcessor#processConfigBeanDefinitions
加载bd
new AspectJExpressionPointcut
new InstantiationModelAwarePointcutAdvisorImpl
getAdvisor
for -> getAdvisorMethods(aspectClass)拿到当前类的所有方法遍历
advisorFactory.getAdvisors
AnnotationAwareAspectJAutoProxyCreator#buildAspectJAdvisors()
findEligibleAdvisors # extendxxx
注解执行流程
aop
AspectJExpressionPointcut
DefaultBeanFactoryPointcutAdvisor
parseAdvisor
parseAttributeSource
TransactionInterceptor
tx:advice
Object interceptorOrInterceptionAdvice = this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex)
((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this)
TransactionAttributeSource
getTransactionAttributeSource()
tas.getTransactionAttribute
TransactionManager
determineTransactionManager
PlatformTransactionManager
asPlatformTransactionManager
methodIdentification
TransactionDefinition def
DataSourceTransactionObject
doGetTransaction()DataSourceTransactionObject
isExistingTransaction
def.getTimeout
suspend(null)
DefaultTransactionStatus
newTransactionStatus
obtainDataSource().getConnection()# DruidDataSource 不往下看了
txObject.getConnectionHolder().setSynchronizedWithTransaction(true);
txObject.setPreviousIsolationLevel(previousIsolationLevel);
txObject.setMustRestoreAutoCommit(true);
con.setAutoCommit(false);
txObject.getConnectionHolder().setTransactionActive(true);
determineTimeout
TransactionSynchronizationManager.bindResource
doBegin
prepareSynchronization
startTransaction
tm.getTransaction(txAttr)
prepareTransactionInfo
createTransactionIfNecessary
invocation.proceedWithInvocation()
cleanupTransactionInfo(txInfo);
defStatus.isLocalRollbackOnly()
defStatus.isGlobalRollbackOnly()
processCommit(defStatus)
txInfo.getTransactionManager().commit
commitTransactionAfterReturning
invokeWithinTransaction
2. TransactionInterceptor
xml执行流程
aop:事务
Spring启动
0 条评论
回复 删除
下一页