001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.aop.support; 018 019import org.springframework.aop.Pointcut; 020 021/** 022 * Concrete BeanFactory-based PointcutAdvisor that allows for any Advice 023 * to be configured as reference to an Advice bean in the BeanFactory, 024 * as well as the Pointcut to be configured through a bean property. 025 * 026 * <p>Specifying the name of an advice bean instead of the advice object itself 027 * (if running within a BeanFactory) increases loose coupling at initialization time, 028 * in order to not initialize the advice object until the pointcut actually matches. 029 * 030 * @author Juergen Hoeller 031 * @since 2.0.2 032 * @see #setPointcut 033 * @see #setAdviceBeanName 034 */ 035@SuppressWarnings("serial") 036public class DefaultBeanFactoryPointcutAdvisor extends AbstractBeanFactoryPointcutAdvisor { 037 038 private Pointcut pointcut = Pointcut.TRUE; 039 040 041 /** 042 * Specify the pointcut targeting the advice. 043 * <p>Default is {@code Pointcut.TRUE}. 044 * @see #setAdviceBeanName 045 */ 046 public void setPointcut(Pointcut pointcut) { 047 this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); 048 } 049 050 @Override 051 public Pointcut getPointcut() { 052 return this.pointcut; 053 } 054 055 056 @Override 057 public String toString() { 058 return getClass().getName() + ": pointcut [" + getPointcut() + "]; advice bean '" + getAdviceBeanName() + "'"; 059 } 060 061}