All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.taketoday.aop.config.AopNamespaceHandler Maven / Gradle / Ivy

/*
 * Original Author -> Harry Yang ([email protected]) https://taketoday.cn
 * Copyright © TODAY & 2017 - 2022 All Rights Reserved.
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see [http://www.gnu.org/licenses/]
 */

package cn.taketoday.aop.config;

import cn.taketoday.aop.aspectj.AspectJExpressionPointcut;
import cn.taketoday.beans.factory.xml.BeanDefinitionParser;
import cn.taketoday.beans.factory.xml.NamespaceHandlerSupport;

/**
 * {@code NamespaceHandler} for the {@code aop} namespace.
 *
 * 

Provides a {@link cn.taketoday.beans.factory.xml.BeanDefinitionParser} for the * {@code } tag. A {@code config} tag can include nested * {@code pointcut}, {@code advisor} and {@code aspect} tags. * *

The {@code pointcut} tag allows for creation of named * {@link AspectJExpressionPointcut} beans using a simple syntax: *

 * <aop:pointcut id="getNameCalls" expression="execution(* *..ITestBean.getName(..))"/>
 * 
* *

Using the {@code advisor} tag you can configure an {@link cn.taketoday.aop.Advisor} * and have it applied to all relevant beans in you {@link cn.taketoday.beans.factory.BeanFactory} * automatically. The {@code advisor} tag supports both in-line and referenced * {@link cn.taketoday.aop.Pointcut Pointcuts}: * *

 * <aop:advisor id="getAgeAdvisor"
 *     pointcut="execution(* *..ITestBean.getAge(..))"
 *     advice-ref="getAgeCounter"/>
 *
 * <aop:advisor id="getNameAdvisor"
 *     pointcut-ref="getNameCalls"
 *     advice-ref="getNameCounter"/>
* * @author Rob Harrop * @author Adrian Colyer * @author Juergen Hoeller * @author Harry Yang * @since 4.0 2022/3/7 21:46 */ public class AopNamespaceHandler extends NamespaceHandlerSupport { /** * Register the {@link BeanDefinitionParser BeanDefinitionParsers} for the * '{@code config}', '{@code configured}', '{@code aspectj-autoproxy}' * and '{@code scoped-proxy}' tags. */ @Override public void init() { // In 2.0 XSD as well as in 2.5+ XSDs registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser()); registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser()); registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinitionDecorator()); // Only in 2.0 XSD: moved to context namespace in 2.5+ // registerBeanDefinitionParser("spring-configured", new SpringConfiguredBeanDefinitionParser()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy