先上代码
package com.dzeay.aop;
public interface IBusiness {
public void excute();
}
package com.dzeay.aop;
public class BusinessImpl implements IBusiness {
public void excute() {
System.out.println("BusinessImpl.excute");
}
}
package com.dzeay.aop;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
public class LogHandler implements InvocationHandler {
private Object delegate;
public LogHandler(Object delegate) {
this.delegate = delegate;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object obj = null;
try {
System.out.println(method + "\tbegin");
obj = method.invoke(delegate, args);
System.out.println(method + "\tend");
} catch (Exception e) {
}
return obj;
}
}
package com.dzeay.aop;
import java.lang.reflect.Proxy;
public class TestClass {
/**
* @param args
*/
public static void main(String[] args) {
IBusiness businessImp = new BusinessImpl();
IBusiness proxy = (IBusiness) Proxy.newProxyInstance(businessImp.getClass().getClassLoader(), businessImp.getClass().getInterfaces(), new LogHandler(businessImp));
proxy.excute();
}
}
分享到:
相关推荐
Spring,面向切面编程AOP例子!AOP(Aspect Oriented Programming)!
aop,面向切面编程
关于Spring框架的aop简介
Spring-aop面向切面编程实例 日志系统,权限控制等.
AOP相关原理整理总结
AOP面向切面编程.ppt
2.1 面向切面编程AOP入门 软件系统中的一些功能需要用到应用程序的多个地方,但是我们又不想在每个点都明确调用它们。日志、安全和事务管理的确都很重要,但它们是否为应该被应用对象主动调用呢?如果让应用对象只...
spect Oriented Programming(AOP),面向切面编程,是一个比较热门的话题。AOP主要实现的目的是针对业务处理过程中的切面进行提取,它所面对的是处理过程中的某个步骤或阶段,以获得逻辑过程中各部分之间低耦合性的...
近日, 学习.NET平台下的依赖注入(IOC)和 面向切面(AOP)。 力求获得一种简洁实用的方法实现IOC和AOP相结合的使用方式。 查阅了多个技术资料。经过多次测试,基本达到目的。 IOC使用微软的 Microsoft.Practices....
一直对AOP面向切面编程的理解很模糊的同学可以看看。
把我们某个方面的功能提取出来与一批对象进行隔离,这样与一批对象之间降低耦合性,对某个功能进行编程
AOP面向切面编程实例,可当作业提交。.net代码亲测,完全正确运行。
aop 面向切面编程 demo,通过一个小案例来讲解,aop在andriod开发中运用
AOP面向切面架构设计Demo
NULL 博文链接:https://zyssnh.iteye.com/blog/1866867
AOP为Aspect Oriented Programming的缩写,意为:面向切面编程(也叫面向方面),可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种技术。AOP实际是GoF设计模式的延续,...
面向切面编程(AOP)提供另外一种角度来思考程序结构,通过这种方式弥补了面向对象编程(OOP)的不足。 除了类(classes)以外,AOP提供了 切面。切面对关注点进行模块化,例如横切多个类型和对象的事务管理。
Aop面向切面
spring-aop面向切面系统日志案例
C# 面向切面编程实例,有兴趣的朋友可以下载研究!