# DesignPatterns **Repository Path**: wfg_admin/DesignPatterns ## Basic Information - **Project Name**: DesignPatterns - **Description**: 设计模式学习 - **Primary Language**: Java - **License**: AFL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-03-22 - **Last Updated**: 2024-11-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: 设计模式 ## README # DesignPatterns #### 介绍 # 代理 ## 静态代理 ![输入图片说明](https://images.gitee.com/uploads/images/2020/0322/182744_f08cab50_349846.png "屏幕截图.png") ## 动态代理(jdk代理) ![输入图片说明](https://images.gitee.com/uploads/images/2020/0322/182728_092fe3f0_349846.png "屏幕截图.png") ``` public Object getProxyFactoryInstatince(){ return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("代理方法执行开始"); Object returnObj = method.invoke(target,args); System.out.println("代理对象执行结束"); return returnObj; } }); } ```