提交 981d4494 编写于 作者: J Juergen Hoeller

AspectJWeavingEnabler registered with well-defined bean name (and therefore once only)

Issue: SPR-14373
上级 0de85e3a
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,6 +19,7 @@ package org.springframework.context.config; ...@@ -19,6 +19,7 @@ package org.springframework.context.config;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition;
...@@ -36,15 +37,22 @@ import org.springframework.util.ClassUtils; ...@@ -36,15 +37,22 @@ import org.springframework.util.ClassUtils;
*/ */
class LoadTimeWeaverBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { class LoadTimeWeaverBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
private static final String WEAVER_CLASS_ATTRIBUTE = "weaver-class"; /**
* The bean name of the internally managed AspectJ weaving enabler.
* @since 4.3.1
*/
public static final String ASPECTJ_WEAVING_ENABLER_BEAN_NAME =
"org.springframework.context.config.internalAspectJWeavingEnabler";
private static final String ASPECTJ_WEAVING_ATTRIBUTE = "aspectj-weaving"; private static final String ASPECTJ_WEAVING_ENABLER_CLASS_NAME =
"org.springframework.context.weaving.AspectJWeavingEnabler";
private static final String DEFAULT_LOAD_TIME_WEAVER_CLASS_NAME = private static final String DEFAULT_LOAD_TIME_WEAVER_CLASS_NAME =
"org.springframework.context.weaving.DefaultContextLoadTimeWeaver"; "org.springframework.context.weaving.DefaultContextLoadTimeWeaver";
private static final String ASPECTJ_WEAVING_ENABLER_CLASS_NAME = private static final String WEAVER_CLASS_ATTRIBUTE = "weaver-class";
"org.springframework.context.weaving.AspectJWeavingEnabler";
private static final String ASPECTJ_WEAVING_ATTRIBUTE = "aspectj-weaving";
@Override @Override
...@@ -65,9 +73,11 @@ class LoadTimeWeaverBeanDefinitionParser extends AbstractSingleBeanDefinitionPar ...@@ -65,9 +73,11 @@ class LoadTimeWeaverBeanDefinitionParser extends AbstractSingleBeanDefinitionPar
builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
if (isAspectJWeavingEnabled(element.getAttribute(ASPECTJ_WEAVING_ATTRIBUTE), parserContext)) { if (isAspectJWeavingEnabled(element.getAttribute(ASPECTJ_WEAVING_ATTRIBUTE), parserContext)) {
RootBeanDefinition weavingEnablerDef = new RootBeanDefinition(); if (!parserContext.getRegistry().containsBeanDefinition(ASPECTJ_WEAVING_ENABLER_BEAN_NAME)) {
weavingEnablerDef.setBeanClassName(ASPECTJ_WEAVING_ENABLER_CLASS_NAME); RootBeanDefinition def = new RootBeanDefinition(ASPECTJ_WEAVING_ENABLER_CLASS_NAME);
parserContext.getReaderContext().registerWithGeneratedName(weavingEnablerDef); parserContext.registerBeanComponent(
new BeanComponentDefinition(def, ASPECTJ_WEAVING_ENABLER_BEAN_NAME));
}
if (isBeanConfigurerAspectEnabled(parserContext.getReaderContext().getBeanClassLoader())) { if (isBeanConfigurerAspectEnabled(parserContext.getReaderContext().getBeanClassLoader())) {
new SpringConfiguredBeanDefinitionParser().parse(element, parserContext); new SpringConfiguredBeanDefinitionParser().parse(element, parserContext);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册