KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > support > DefaultBeanFactoryPointcutAdvisor


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.support;
18
19 import org.springframework.aop.Pointcut;
20
21 /**
22  * Concrete BeanFactory-based PointcutAdvisor that allows for any Advice
23  * to be configured as reference to an Advice bean in the BeanFactory,
24  * as well as the Pointcut to be configured through a bean property.
25  *
26  * <p>Specifying the name of an advice bean instead of the advice object itself
27  * (if running within a BeanFactory) increases loose coupling at initialization time,
28  * in order to not initialize the advice object until the pointcut actually matches.
29  *
30  * @author Juergen Hoeller
31  * @since 2.0.2
32  * @see #setPointcut
33  * @see #setAdviceBeanName
34  */

35 public class DefaultBeanFactoryPointcutAdvisor extends AbstractBeanFactoryPointcutAdvisor {
36
37     private Pointcut pointcut = Pointcut.TRUE;
38
39
40     /**
41      * Specify the pointcut targeting the advice.
42      * <p>Default is <code>Pointcut.TRUE</code>.
43      * @see #setAdviceBeanName
44      */

45     public void setPointcut(Pointcut pointcut) {
46         this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE);
47     }
48
49     public Pointcut getPointcut() {
50         return this.pointcut;
51     }
52
53
54     public String JavaDoc toString() {
55         return getClass().getName() + ": pointcut [" + getPointcut() + "]; advice bean '" + getAdviceBeanName() + "'";
56     }
57
58 }
59
Popular Tags