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.config; 018 019import org.springframework.beans.factory.config.BeanDefinition; 020import org.springframework.beans.factory.parsing.AbstractComponentDefinition; 021import org.springframework.lang.Nullable; 022import org.springframework.util.Assert; 023 024/** 025 * {@link org.springframework.beans.factory.parsing.ComponentDefinition} 026 * implementation that holds a pointcut definition. 027 * 028 * @author Rob Harrop 029 * @since 2.0 030 */ 031public class PointcutComponentDefinition extends AbstractComponentDefinition { 032 033 private final String pointcutBeanName; 034 035 private final BeanDefinition pointcutDefinition; 036 037 private final String description; 038 039 040 public PointcutComponentDefinition(String pointcutBeanName, BeanDefinition pointcutDefinition, String expression) { 041 Assert.notNull(pointcutBeanName, "Bean name must not be null"); 042 Assert.notNull(pointcutDefinition, "Pointcut definition must not be null"); 043 Assert.notNull(expression, "Expression must not be null"); 044 this.pointcutBeanName = pointcutBeanName; 045 this.pointcutDefinition = pointcutDefinition; 046 this.description = "Pointcut <name='" + pointcutBeanName + "', expression=[" + expression + "]>"; 047 } 048 049 050 @Override 051 public String getName() { 052 return this.pointcutBeanName; 053 } 054 055 @Override 056 public String getDescription() { 057 return this.description; 058 } 059 060 @Override 061 public BeanDefinition[] getBeanDefinitions() { 062 return new BeanDefinition[] {this.pointcutDefinition}; 063 } 064 065 @Override 066 @Nullable 067 public Object getSource() { 068 return this.pointcutDefinition.getSource(); 069 } 070 071}