1.先创建以DAO层接口
package cn.ouyang.test.entity;
//DAO层接口
public interface Student {
id);
id);
}
2.为之前接口写实现类
package cn.ouyang.test.entity;
public class StudentImpl implements
Student {
@Override
@Override
}
3.写代理类:(动态代理):
package cn.ouyang.test.entity;
import
java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class Inction implements
InvocationHandler {
@Override
Object[] args)
Throwable {
result=method.invoke(terget, args);
Proxy.newProxyInstance(terget.getClass().getClassLoader(),
terget.getClass().getInterfaces(), this);
}
4.写测试类:
package cn.ouyang.test.test;
import
cn.ouyang.test.entity.Inction;
import cn.ouyang.test.entity.Student;
import cn.ouyang.test.entity.StudentImpl;
public class Test {
StudentImpl();
Inction(student);
student2=(Student)inction.getProxy();
}