001/* 002 * Copyright 2012-2016 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 * http://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.boot.autoconfigure.aop; 018 019import org.aspectj.lang.annotation.Aspect; 020import org.aspectj.lang.reflect.Advice; 021 022import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 023import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 024import org.springframework.context.annotation.Configuration; 025import org.springframework.context.annotation.EnableAspectJAutoProxy; 026 027/** 028 * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration 029 * Auto-configuration} for Spring's AOP support. Equivalent to enabling 030 * {@link org.springframework.context.annotation.EnableAspectJAutoProxy} in your 031 * configuration. 032 * <p> 033 * The configuration will not be activated if {@literal spring.aop.auto=false}. The 034 * {@literal proxyTargetClass} attribute will be {@literal false}, by default, but can be 035 * overridden by specifying {@literal spring.aop.proxyTargetClass=true}. 036 * 037 * @author Dave Syer 038 * @author Josh Long 039 * @see EnableAspectJAutoProxy 040 */ 041@Configuration 042@ConditionalOnClass({ EnableAspectJAutoProxy.class, Aspect.class, Advice.class }) 043@ConditionalOnProperty(prefix = "spring.aop", name = "auto", havingValue = "true", matchIfMissing = true) 044public class AopAutoConfiguration { 045 046 @Configuration 047 @EnableAspectJAutoProxy(proxyTargetClass = false) 048 @ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "false", matchIfMissing = true) 049 public static class JdkDynamicAutoProxyConfiguration { 050 051 } 052 053 @Configuration 054 @EnableAspectJAutoProxy(proxyTargetClass = true) 055 @ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "true", matchIfMissing = false) 056 public static class CglibAutoProxyConfiguration { 057 058 } 059 060}