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.context.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><context:spring-configured/></code> tag.
30: *
31: * @author Juergen Hoeller
32: * @since 2.5
33: */
34: class SpringConfiguredBeanDefinitionParser implements
35: BeanDefinitionParser {
36:
37: /**
38: * The bean name of the internally managed bean configurer aspect.
39: */
40: public static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME = "org.springframework.context.config.internalBeanConfigurerAspect";
41:
42: static final String BEAN_CONFIGURER_ASPECT_CLASS_NAME = "org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
43:
44: public BeanDefinition parse(Element element,
45: ParserContext parserContext) {
46: if (!parserContext.getRegistry().containsBeanDefinition(
47: BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
48: RootBeanDefinition def = new RootBeanDefinition();
49: def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
50: def.setFactoryMethodName("aspectOf");
51: def.setSource(parserContext.extractSource(element));
52: parserContext
53: .registerBeanComponent(new BeanComponentDefinition(
54: def, BEAN_CONFIGURER_ASPECT_BEAN_NAME));
55: }
56: return null;
57: }
58:
59: }
|