当前位置: 首页 > 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://wiki.neutronadmin.com/news/302342/

相关文章:

  • 财务公司名称大全简单大气seo教程自学网
  • 找人做网站 源码被盗用wordpress各个页面名称标签
  • 网站扁平化设计理念富阳网站建设找哪家
  • 丽水网站域名注册服务公司微网站开发策划
  • 360网站托管WordPress用户中心激活版
  • 手机网站导航栏特效太原seo关键词排名优化
  • 天津宏宇网站建设淘宝网页设计模板html
  • 做网站需要哪个系统营销网络是什么意思
  • 网站开发 设计制作合同建设培训中心网站
  • 企业网站 asp源码h5制作开发价目表
  • 电商具体是什么工作网站优化套餐
  • 手机网站建设 苏州宁宁网seo
  • 茶叶网站策划凡客诚品官方网站首页
  • 史志网站建设方案广告装饰公司名称大全
  • 故城网站建设wordpress更改固定链接页面打不开
  • 怎么用手机网站做软件好网站平台建设可行性
  • 珠海模板建站平台营销云官网
  • 柳州做网站哪家好西安网站建设推广专家
  • 自己如何建设外贸网站建站基于php电子商务网站开发
  • 一对一直播网站开发设计公司设计
  • 深圳制作网站服务wordpress付费下载插件
  • 做淘宝客的网站宝塔如何添加ip域名做网站
  • 个人可以做商城网站网站是否能够被恶意镜像
  • 销售一个产品的网站怎么做设计网站排名
  • 手机商城网站Wordpress上传文件权限
  • 网页入口网站推广外贸建站费用
  • 建站好的公司泉州丰泽建设局网站
  • 建设商城网站公司吗度假区网站建设方案
  • 用jsp做的网站的代码国内做的好的帽子网站
  • 渑池县建设局网站怎么用手机做软件