当前位置: 首页 > news >正文

浏览不良网站会被网警抓吗永久免费网站建设

浏览不良网站会被网警抓吗,永久免费网站建设,福州百度快照优化,公司建网站哪家代码地址 https://github.com/cmdch2017/JDKproxy.git/ 我的理解 我的理解是本身service-serviceImpl结构#xff0c;新增一个代理对象proxy#xff0c;代理对象去直接访问serviceImpl#xff0c;在proxy进行事务的增强操作#xff0c;所以代理对象实现了接口。如何实现…代码地址 https://github.com/cmdch2017/JDKproxy.git/ 我的理解 我的理解是本身service-serviceImpl结构新增一个代理对象proxy代理对象去直接访问serviceImpl在proxy进行事务的增强操作所以代理对象实现了接口。如何实现动态呢需要实现InovacationHandler接口并用反射调用invoke方法实现类似于泛型一样的效果。 CHATGPT回答 “JDK动态代理是通过Proxy类和InvocationHandler接口实现的。它允许在运行时生成代理类无需事先定义代理类从而在不修改原有代码的情况下对方法进行增强。通过实现InvocationHandler接口我们可以在目标方法执行前后插入自定义逻辑比如事务处理。动态代理的优势在于避免了手动创建大量代理类的繁琐工作使代码更加简洁和易维护。” 核心代码 客户端 public class TestStudent {public static void main(String[] args) { // testQuery(1);testQueryObject(1);} //这里是动态代理多实现了一个InvocationHandlerprivate static void testQueryObject(int id) {DaoTransaction transactionnew DaoTransaction();StudentServiceImpl studentServicenew StudentServiceImpl();TransactionHandler transactionHandlernew TransactionHandler(studentService,transaction);StudentService proxyInstance(StudentService)Proxy.newProxyInstance(StudentServiceImpl.class.getClassLoader(),StudentServiceImpl.class.getInterfaces(),transactionHandler);Student studentproxyInstance.query(id);System.out.println(id:student.getId(),name:student.getName());} //这里是静态代理private static void testQuery(int id) {DaoTransaction transactionnew DaoTransaction();StudentServiceImpl studentServicenew StudentServiceImpl();ProxyStudent proxyStudentnew ProxyStudent(studentService,transaction);Student studentproxyStudent.query(id);System.out.println(id:student.getId(),name:student.getName());} }动态代理学生 public class TransactionHandler implements InvocationHandler {private DaoTransaction daoTransaction;private Object object;public TransactionHandler(Object object, DaoTransaction daoTransaction) {this.object object;this.daoTransaction daoTransaction;}Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {return method.invoke(object,args);} }Data public class Student {private int id;private String name; }静态代理学生 public class ProxyStudent implements StudentService {private StudentServiceImpl studentService;private DaoTransaction daoTransaction;public ProxyStudent(StudentServiceImpl studentService, DaoTransaction daoTransaction) {this.studentService studentService;this.daoTransaction daoTransaction;}Overridepublic Student query(int id) {daoTransaction.startTransaction();Student studentstudentService.query(id);daoTransaction.endTransaction();return student;} }public class StudentServiceImpl implements StudentService {Overridepublic Student query(int id) {System.out.println(执行查询);Student studentnew Student();student.setId(id);student.setName(lst);return student;} }public interface StudentService {Student query(int id); } public class DaoTransaction {public void startTransaction() {System.out.println(开启事务);}public void endTransaction() {System.out.println(关闭事务);} }
http://www.hkea.cn/news/14553162/

相关文章:

  • 网站原型图设计南京网页设计照片
  • 细谈电商网站外链建设的策略石家庄网站设计制作
  • 百度小程序还需要做网站吗网页制作与设计专业
  • 导航网站教程网站免费优化
  • 建个网站做网络推广要花多少钱郑州网站优化公司排名
  • 西安宝马建设科技股份有限公司网站游戏开发大亨最佳搭配
  • 公司做网站怎么推广软件系统开发合同
  • 爱站网功能discuz做网站赚钱经历
  • 站酷网站建设社交网站wap模板
  • dede地方门户网站模板重庆公章备案查询网站
  • 青岛网站设计哪家好国土政务网站建设制度
  • 关于建设网站的经费请示西安百度seo排名
  • 中卫网站推广服务外贸营销型网站建设多少钱
  • 网站建设业务拓展wordpress qq留言
  • 怎么做棋牌网站国外网站怎么推广
  • 广东省医院建设协会网站横向网站源码
  • 网站广告位制作做网站的实验报告
  • 杭州正晖建设工程有限公司网站手机网页开发框架
  • 临漳+网站建设百度收录删除旧网站
  • 社交博客网站开发装修设计培训学费多少钱
  • 外贸建站哪家公司专业南阳美容网站建设
  • 手机网站跳转怎么做电子商务网站建设与管理的有关论文
  • 网站双链接怎么做近三年网络营销案例
  • 海外仓网站建设南昌官网seo厂家
  • 沙特网站后缀企业网站通常包含的栏目
  • 万荣网站建设淘宝的网站是怎么做的
  • 网站实现留言功能吗百度竞价app
  • 重庆做网站建设企业龙岩网络营销平台
  • 洛阳网站推广优化电脑端网站一般做多宽最好
  • 网站链接收费怎么做的网站建设创新能力痛点