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.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
36: AbstractBeanFactoryPointcutAdvisor {
37:
38: private Pointcut pointcut = Pointcut.TRUE;
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: public String toString() {
54: return getClass().getName() + ": pointcut [" + getPointcut()
55: + "]; advice bean '" + getAdviceBeanName() + "'";
56: }
57:
58: }
|