http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-proxy.html
- Interestingly, you can have a proxy class that implements multiple interfaces. However, there are a few restrictions on the interfaces you implement. It is important to keep those restrictions in mind when creating your dynamic proxy:
- The proxy interface must be an interface. In other words, it cannot be a class (or an abstract class) or a primitive.
- The array of interfaces passed to the proxy constructor must not contain duplicates of the same interface. Sun specifies that, and it makes sense that you wouldn't be trying to implement the same interface twice at the same time. For example, an array
{ IPerson.class, IPerson.class }
would be illegal, but the code { IPerson.class, IEmployee.class }
would not. The code calling the constructor should check for that case and filter out duplicates.
- All the interfaces must be visible to the
ClassLoader
specified during the construction call. Again, that makes sense. The ClassLoader
must be able to load the interfaces for the proxy.
- All the nonpublic interfaces must be from the same package. You cannot have a private interface from package
com.xyz
and the proxy class in package com.abc
. If you think about it, it is the same way when programming a regular Java class. You couldn't implement a nonpublic interface from another package with a regular class either.
- The proxy interfaces cannot have a conflict of methods. You can't have two methods that take the same parameters but return different types. For example, the methods
public void foo()
and public String foo()
cannot be defined in the same class because they have the same signature, but return different types (see The Java Language Specification). Again, that is the same for a regular class.
- The resulting proxy class cannot exceed the limits of the VM, such as the limitation on the number of interfaces that can be implemented.
分享到:
相关推荐
package cn.sxt.dynamicproxy; import java.util.ArrayList; import java.util.List; import cn.sxt.service.UserService; import cn.sxt.service.UserServiceImpl; public class Client { public ...
SpringIOC,DI+dynamic proxy 实现盗版AOP的源代码
Castle框架注入依赖所需dll Version:2.1.0.0
这是动态代理的简单实例,方便学,入手.这个例子非常的简单哦!
Castle Dynamic Proxy代理使用
DynamicProxy.zip
java 反射与动态代理Reflection&DynamicProxy,源码展示
解决VS报错:未能加载文件或程序集“LinFu.DynamicProxy, Version=1.0.3.14911, Culture=neutral, PublicKeyToken=62a6874124340d6e”或它的某一个依赖项。系统找不到指定的文件。 把该文件放到bin文件夹就好了。
DynamicProxy,源码DynamicProxy,源码DynamicProxy,源码
主要写了静态代理、动态代理、还写了URL的使用,其实就是下载的原理了。 动态代理动态代理动态代理动态代理
动态代理一个简单实用的JDK动态代理演示
一个简单的动态调用wcf类,在公司的服务器上使用稳定。
解决了IBatisNET v1.x 应用.NET4.0后出现的'Ambiguous match found'问题,替换原有的dll即可。
WPF下MEF+Caliburn.Micro+MVVMValidation+Castle.Dynamicproxy AOP
动态代理框架源码 /// 说明: /// 在第一次需要用到代理时动态生成代理类,之后的使用均调用已经生成的代理类 /// 规则: /// 1.不能为接口创建代理类代理类 ... /// 2.... /// 3.... /// 1.... /// 2....
NULL 博文链接:https://xxp3369-126-com.iteye.com/blog/301133