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.springframework.aop.aspectj.AspectJExpressionPointcut;
20: import org.springframework.beans.factory.xml.BeanDefinitionParser;
21: import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
22:
23: /**
24: * <code>NamespaceHandler</code> for the <code>aop</code> namespace.
25: *
26: * <p>Provides a {@link org.springframework.beans.factory.xml.BeanDefinitionParser} for the
27: * <code><aop:config></code> tag. A <code>config</code> tag can include nested
28: * <code>pointcut</code>, <code>advisor</code> and <code>aspect</code> tags.
29: *
30: * <p>The <code>pointcut</code> tag allows for creation of named
31: * {@link AspectJExpressionPointcut} beans using a simple syntax:
32: * <pre class="code">
33: * <aop:pointcut id="getNameCalls" expression="execution(* *..ITestBean.getName(..))"/>
34: * </pre>
35: *
36: * <p>Using the <code>advisor</code> tag you can configure an {@link org.springframework.aop.Advisor}
37: * and have it applied to all relevant beans in you {@link org.springframework.beans.factory.BeanFactory}
38: * automatically. The <code>advisor</code> tag supports both in-line and referenced
39: * {@link org.springframework.aop.Pointcut Pointcuts}:
40: *
41: * <pre class="code">
42: * <aop:advisor id="getAgeAdvisor"
43: * pointcut="execution(* *..ITestBean.getAge(..))"
44: * advice-ref="getAgeCounter"/>
45: *
46: * <aop:advisor id="getNameAdvisor"
47: * pointcut-ref="getNameCalls"
48: * advice-ref="getNameCounter"/></pre>
49: *
50: * @author Rob Harrop
51: * @author Adrian Colyer
52: * @author Juergen Hoeller
53: * @since 2.0
54: */
55: public class AopNamespaceHandler extends NamespaceHandlerSupport {
56:
57: /**
58: * Register the {@link BeanDefinitionParser BeanDefinitionParsers} for the
59: * '<code>config</code>', '<code>spring-configured</code>', '<code>aspectj-autoproxy</code>'
60: * and '<code>scoped-proxy</code>' tags.
61: */
62: public void init() {
63: // In 2.0 XSD as well as in 2.1 XSD.
64: registerBeanDefinitionParser("config",
65: new ConfigBeanDefinitionParser());
66: registerBeanDefinitionParser("aspectj-autoproxy",
67: new AspectJAutoProxyBeanDefinitionParser());
68: registerBeanDefinitionDecorator("scoped-proxy",
69: new ScopedProxyBeanDefinitionDecorator());
70:
71: // Only in 2.0 XSD: moved to context namespace as of 2.1
72: registerBeanDefinitionParser("spring-configured",
73: new SpringConfiguredBeanDefinitionParser());
74: }
75:
76: }
|