zoukankan      html  css  js  c++  java
  • Spring AOP

    类关系图

    image-20210923070023607

    • AopProxyFactory
    public interface AopProxyFactory {
    
    	/**
    	 * Create an {@link AopProxy} for the given AOP configuration.
    	 * @param config the AOP configuration in the form of an
    	 * AdvisedSupport object
    	 * @return the corresponding AOP proxy
    	 * @throws AopConfigException if the configuration is invalid
    	 */
    	AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException;
    
    }
    
    • DefaultAopProxyFactory
    public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
    
    	@Override
    	public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
    		if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
    			Class<?> targetClass = config.getTargetClass();
    			if (targetClass == null) {
    				throw new AopConfigException("TargetSource cannot determine target class: " +
    						"Either an interface or a target is required for proxy creation.");
    			}
          // 代理对象是接口 或者是 JDK Proxy 代理后的对象,则使用动态代理
    			if (targetClass.isInterface() || Proxy.isProxyClass(targetClass)) {
    				return new JdkDynamicAopProxy(config);
    			}
          // 否则使用 Cglib(代码生成库)
    			return new ObjenesisCglibAopProxy(config);
    		}
    		else {
    			return new JdkDynamicAopProxy(config);
    		}
    	}
    }
    
  • 相关阅读:
    爬虫简介
    MongoDb安装pymongo和mongoengine使用
    简单使用WebSocket实现聊天室
    DBUtils
    FLASK 的Session和MoudelForm插件
    第十一篇 CBV和闪现
    HDOJ 4699 Editor 对顶栈
    [NOI1999]内存分配
    横截面图
    STL List Set
  • 原文地址:https://www.cnblogs.com/sethxiong/p/15329873.html
Copyright © 2011-2022 走看看