摘要
动态代理的基本思想就是建立一个可以返回动态代理对象的代理工厂,该代理工厂提供一个静态方法,用户自己的业务处理对象和系统服务对象传递给该代理工厂,在代理工厂的内部,通过反射技术,获得该业务逻辑对象的类对象,从而自动的拼装一个业务逻辑类的子类,在该子类中,代理工厂自己完成我们业务逻辑和系统服务的动态拼装,然后代理工厂动态编译该类,动态生成该代理类的对象,返回代理对象给客户,从而实现了真正意义上的业务逻辑和系统服务逻辑之间的动态组装。
A dynamic proxy class is a class that implements a list of interfaces specified at runtime such that a method invocation through one of the interfaces on an instance of the class will be encoded and dispatched to another object through a uniform interface.Thus,a dynamic proxy class can be used to create a type-safe proxy object for a list of interfaces without requiring pre-generation of the proxy class,such as with compile-time tools.Method invocations on an instance of a dynamic proxy class are dispatched to a single method in the instance's invocation handler,and they are encoded with a java.lang reflect.Method object identifying the method that was invoked and an array of type Object containing the arguments.
作者
刘庆杰
孙旭光
白灵
LIU Qing-jie,SUN Xu-guang,BAI Ling(Science And Technology Department,Institute Of Disaster Prevention,Sanhe 065201,China)
出处
《电脑知识与技术》
2009年第12X期10427-10429,共3页
Computer Knowledge and Technology