http://www.blogjava.net/DoubleJ/archive/2009/08/14/183796.html

这是篇很好的介绍文章。

http://tonyaction.blog.51cto.com/227462/42039

这篇简单的说了spring和aop的实现。

 

先说下背景:spring发展自2002年;而.net发布时间是2003、4、3.应该是接近。从时间上,很难说谁抄袭了谁。个人感觉,spring抄袭了.net更加有可能。

 

基本上看,spring实现aop使用了java的反射和代理技术,这点和.net的realproxy一致了。

36    public Object invoke(Object proxy, Method method, Object[] args)
37            throws Throwable {
38        Object result = null;
39        try {
40            //反射得到操作者的实例
41            Class clazz = this.proxy.getClass();
42            //反射得到操作者的Start方法
43            Method start = clazz.getDeclaredMethod("start",
44                    new Class[] { Method.class });
45            //反射执行start方法
46            start.invoke(this.proxy, new Object[] { method });
47            //执行要处理对象的原本方法
48            result = method.invoke(this.delegate, args);
49//            反射得到操作者的end方法
50            Method end = clazz.getDeclaredMethod("end",
51                    new Class[] { Method.class });
52//            反射执行end方法
53            end.invoke(this.proxy, new Object[] { method });
54
55        } catch (Exception e) {
56            e.printStackTrace();
57        }
58        return result;
59    }

相关文章:

  • 2021-06-01
  • 2021-08-05
  • 2022-01-14
  • 2021-10-29
  • 2021-10-14
  • 2021-12-16
  • 2021-12-09
  • 2022-02-11
猜你喜欢
  • 2021-04-04
  • 2021-05-14
  • 2021-12-21
  • 2021-11-20
  • 2021-09-27
  • 2021-12-08
  • 2021-06-22
相关资源
相似解决方案