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