KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > config > AopNamespaceHandler


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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>&lt;aop:config&gt;</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  * &lt;aop:pointcut id=&quot;getNameCalls&quot; expression=&quot;execution(* *..ITestBean.getName(..))&quot;/&gt;
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  * &lt;aop:advisor id=&quot;getAgeAdvisor&quot;
43  * pointcut=&quot;execution(* *..ITestBean.getAge(..))&quot;
44  * advice-ref=&quot;getAgeCounter&quot;/&gt;
45  *
46  * &lt;aop:advisor id=&quot;getNameAdvisor&quot;
47  * pointcut-ref=&quot;getNameCalls&quot;
48  * advice-ref=&quot;getNameCounter&quot;/&gt;</pre>
49  *
50  * @author Rob Harrop
51  * @author Adrian Colyer
52  * @author Rod Johnson
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         registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
64         registerBeanDefinitionParser("spring-configured", new SpringConfiguredBeanDefinitionParser());
65         registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser());
66         registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinitionDecorator());
67     }
68
69 }
70
Popular Tags