Java Code Examples for org.springframework.aop.config.AopNamespaceUtils

The following examples show how to use org.springframework.aop.config.AopNamespaceUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public BeanDefinition parse( Element element, ParserContext parserContext ) {
    AopNamespaceUtils.registerAutoProxyCreatorIfNecessary( parserContext, element );
    if( !parserContext.getRegistry().containsBeanDefinition( BEAN_NAME ) ) {
        Object eleSource = parserContext.extractSource( element );

        RootBeanDefinition stageCreator = new RootBeanDefinition( SpringStageCreator.class );
        stageCreator.setSource( eleSource );
        stageCreator.setRole( BeanDefinition.ROLE_INFRASTRUCTURE );
        String executorName = parserContext.getReaderContext().registerWithGeneratedName( stageCreator );
        logger.debug( "Registered SpringStageCreator with name " + executorName );

        RootBeanDefinition beanFactoryPostProcessor = new RootBeanDefinition( JGivenBeanFactoryPostProcessor.class );
        beanFactoryPostProcessor.setRole( BeanDefinition.ROLE_INFRASTRUCTURE );
        parserContext.getRegistry().registerBeanDefinition( BEAN_NAME, beanFactoryPostProcessor );

        CompositeComponentDefinition componentDefinition = new CompositeComponentDefinition( element.getTagName(), eleSource );
        componentDefinition.addNestedComponent( new BeanComponentDefinition( stageCreator, executorName ) );
        componentDefinition.addNestedComponent( new BeanComponentDefinition( beanFactoryPostProcessor, BEAN_NAME ) );
        parserContext.registerComponent( componentDefinition );
    }
    return null;
}
 
Example 2
@Test
public void testRegisterAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
}
 
Example 3
@Test
public void testRegisterAspectJAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 4
@Test
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("APC class not switched",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 5
@Test
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 6
private void registerCacheAdvisor(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
	SpringCachingConfigurer.registerCacheAdvisor(element, parserContext);
	if (jsr107Present && jcacheImplPresent) {
		JCacheCachingConfigurer.registerCacheAdvisor(element, parserContext);
	}
}
 
Example 7
@Test
public void testRegisterAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
}
 
Example 8
@Test
public void testRegisterAspectJAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 9
@Test
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("APC class not switched",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 10
@Test
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 11
private void registerCacheAdvisor(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
	SpringCachingConfigurer.registerCacheAdvisor(element, parserContext);
	if (jsr107Present && jcacheImplPresent) {
		JCacheCachingConfigurer.registerCacheAdvisor(element, parserContext);
	}
}
 
Example 12
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);

	String txAdvisorBeanName = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
		Object eleSource = parserContext.extractSource(element);

		// Create the TransactionAttributeSource definition.
		RootBeanDefinition sourceDef = new RootBeanDefinition(
				"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource");
		sourceDef.setSource(eleSource);
		sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);

		// Create the TransactionInterceptor definition.
		RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
		interceptorDef.setSource(eleSource);
		interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		registerTransactionManager(element, interceptorDef);
		interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

		// Create the TransactionAttributeSourceAdvisor definition.
		RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
		advisorDef.setSource(eleSource);
		advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
		if (element.hasAttribute("order")) {
			advisorDef.getPropertyValues().add("order", element.getAttribute("order"));
		}
		parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);

		CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
		compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
		parserContext.registerComponent(compositeDef);
	}
}
 
Example 13
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);

	String txAdvisorBeanName = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
		Object eleSource = parserContext.extractSource(element);

		// Create the TransactionAttributeSource definition.
		RootBeanDefinition sourceDef = new RootBeanDefinition(
				"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource");
		sourceDef.setSource(eleSource);
		sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);

		// Create the TransactionInterceptor definition.
		RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
		interceptorDef.setSource(eleSource);
		interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		registerTransactionManager(element, interceptorDef);
		interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

		// Create the TransactionAttributeSourceAdvisor definition.
		RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
		advisorDef.setSource(eleSource);
		advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
		if (element.hasAttribute("order")) {
			advisorDef.getPropertyValues().add("order", element.getAttribute("order"));
		}
		parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);

		CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
		compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
		parserContext.registerComponent(compositeDef);
	}
}
 
Example 14
private void registerCacheAdvisor(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
	SpringCachingConfigurer.registerCacheAdvisor(element, parserContext);
	if (jsr107Present && jcacheImplPresent) {
		JCacheCachingConfigurer.registerCacheAdvisor(element, parserContext);
	}
}
 
Example 15
Source Project: jetcache   Source File: CacheAnnotationParser.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized void doParse(Element element, ParserContext parserContext) {
    String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute("base-package"), ",; \t\n");
    AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
    if (!parserContext.getRegistry().containsBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME)) {
        Object eleSource = parserContext.extractSource(element);

        RootBeanDefinition configMapDef = new RootBeanDefinition(ConfigMap.class);
        configMapDef.setSource(eleSource);
        configMapDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        String configMapName = parserContext.getReaderContext().registerWithGeneratedName(configMapDef);

        RootBeanDefinition interceptorDef = new RootBeanDefinition(JetCacheInterceptor.class);
        interceptorDef.setSource(eleSource);
        interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        interceptorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

        RootBeanDefinition advisorDef = new RootBeanDefinition(CacheAdvisor.class);
        advisorDef.setSource(eleSource);
        advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("adviceBeanName", interceptorName));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("basePackages", basePackages));
        parserContext.getRegistry().registerBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME, advisorDef);

        CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(),
                eleSource);
        compositeDef.addNestedComponent(new BeanComponentDefinition(configMapDef, configMapName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, CacheAdvisor.CACHE_ADVISOR_BEAN_NAME));
        parserContext.registerComponent(compositeDef);
    }
}
 
Example 16
@Test
public void testRegisterAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
}
 
Example 17
@Test
public void testRegisterAspectJAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 18
@Test
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("APC class not switched",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 19
@Test
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
Example 20
private void registerCacheAdvisor(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
	SpringCachingConfigurer.registerCacheAdvisor(element, parserContext);
	if (jsr107Present && jCacheImplPresent) { // Register JCache advisor
		JCacheCachingConfigurer.registerCacheAdvisor(element, parserContext);
	}
}
 
Example 21
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);

	String txAdvisorBeanName = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
		Object eleSource = parserContext.extractSource(element);

		// Create the TransactionAttributeSource definition.
		RootBeanDefinition sourceDef = new RootBeanDefinition(
				"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource");
		sourceDef.setSource(eleSource);
		sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);

		// Create the TransactionInterceptor definition.
		RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
		interceptorDef.setSource(eleSource);
		interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		registerTransactionManager(element, interceptorDef);
		interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

		// Create the TransactionAttributeSourceAdvisor definition.
		RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
		advisorDef.setSource(eleSource);
		advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
		if (element.hasAttribute("order")) {
			advisorDef.getPropertyValues().add("order", element.getAttribute("order"));
		}
		parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);

		CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
		compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
		parserContext.registerComponent(compositeDef);
	}
}
 
Example 22
Source Project: cloud-config   Source File: ZkDeclarativeRoutingParser.java    License: MIT License 5 votes vote down vote up
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
    if (!parserContext.getRegistry().containsBeanDefinition(ROUTING_KEY_ASPECT_BEAN_NAME)) {
        RootBeanDefinition def = new RootBeanDefinition(DeclarativeRoutingKeyAspect.class);
        parserContext.registerBeanComponent(new BeanComponentDefinition(def, ROUTING_KEY_ASPECT_BEAN_NAME));
    }
    return null;
}
 
Example 23
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
	// 注册 InfrastructureAdvisorAutoProxyCreator 自动创建代理器
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
	// txAdvisorBeanName = org.springframework.transaction.config.internalTransactionAdvisor
	String txAdvisorBeanName = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
		Object eleSource = parserContext.extractSource(element);

		// Create the TransactionAttributeSource definition.
		// 创建 TransactionAttributeSource 的 bean
		RootBeanDefinition sourceDef = new RootBeanDefinition(
				"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource");
		sourceDef.setSource(eleSource);
		sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		// 注册 bean,并使用 Spring 中的定义规则生成 beanName
		String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);

		// Create the TransactionInterceptor definition.
		// 创建 TransactionInterceptor 的 bean
		RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
		interceptorDef.setSource(eleSource);
		interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		registerTransactionManager(element, interceptorDef);
		interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

		// Create the TransactionAttributeSourceAdvisor definition.
		// 创建 TransactionAttributeSourceAdvisor 的 bean
		RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
		advisorDef.setSource(eleSource);
		advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		// 将 sourceName 的 bean 注入 advisor 的 transactionAttributeSource 属性中
		advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		// 将 interceptorName 的 bean 注入到 advisor 的 adviceBeanName 属性中
		advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
		if (element.hasAttribute("order")) {
			// 如果配置了 order 属性,则加入到 bean 中
			advisorDef.getPropertyValues().add("order", element.getAttribute("order"));
		}
		// 以 txAdvisorBeanName 名字注册 advisorDef
		parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);

		// 创建 CompositeComponentDefinition
		CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
		compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
		parserContext.registerComponent(compositeDef);
	}
}