1、IA1.java
package com.ast.cglib.test; public interface IA1 { void methodA1(); }
2、IA2.java
package com.ast.cglib.test; public interface IA2 { void methodA2(); }
3、A1Impl.java
package com.ast.cglib.test; public class A1Impl implements IA1{ @Override public void methodA1() { System.out.println("A1Impl methodA1"); } }
4、A2Impl.java
package com.ast.cglib.test; public class A2Impl implements IA2{ @Override public void methodA2() { System.out.println("A2Impl methodA2"); } }
5、MixinTest.java
package com.ast.cglib.test; import net.sf.cglib.proxy.Mixin; public class MixinTest { public static void main(String[] args) { Class[] interfaces = new Class[] { IA1.class, IA2.class }; Object[] delegates = new Object[] { new A1Impl(), new A2Impl() }; Object obj = Mixin.create(interfaces, delegates); IA1 a1 = (IA1) obj; a1.methodA1(); IA2 a2 = (IA2) obj; a2.methodA2(); } }