01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.aop.config;
18:
19: import org.w3c.dom.Element;
20:
21: import org.springframework.beans.factory.config.BeanDefinition;
22: import org.springframework.beans.factory.parsing.BeanComponentDefinition;
23: import org.springframework.beans.factory.support.RootBeanDefinition;
24: import org.springframework.beans.factory.xml.BeanDefinitionParser;
25: import org.springframework.beans.factory.xml.ParserContext;
26:
27: /**
28: * {@link BeanDefinitionParser} responsible for parsing the
29: * <code><aop:spring-configured/></code> tag.
30: *
31: * <p><b>NOTE:</b> This is essentially a duplicate of Spring 2.5's
32: * {@link org.springframework.context.config.SpringConfiguredBeanDefinitionParser}
33: * for the <code><context:spring-configured/></code> tag, mirrored here
34: * for compatibility with Spring 2.0's <code><aop:spring-configured/></code>
35: * tag (avoiding a direct dependency on the context package).
36: *
37: * @author Rob Harrop
38: * @author Juergen Hoeller
39: * @since 2.0
40: */
41: class SpringConfiguredBeanDefinitionParser implements
42: BeanDefinitionParser {
43:
44: /**
45: * The bean name of the internally managed bean configurer aspect.
46: */
47: public static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME = "org.springframework.context.config.internalBeanConfigurerAspect";
48:
49: private static final String BEAN_CONFIGURER_ASPECT_CLASS_NAME = "org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
50:
51: public BeanDefinition parse(Element element,
52: ParserContext parserContext) {
53: if (!parserContext.getRegistry().containsBeanDefinition(
54: BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
55: RootBeanDefinition def = new RootBeanDefinition();
56: def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
57: def.setFactoryMethodName("aspectOf");
58: def.setSource(parserContext.extractSource(element));
59: parserContext
60: .registerBeanComponent(new BeanComponentDefinition(
61: def, BEAN_CONFIGURER_ASPECT_BEAN_NAME));
62: }
63: return null;
64: }
65:
66: }
|