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

临川区建设局网站平面设计有前景吗

临川区建设局网站,平面设计有前景吗,cms管理是什么,阿里云免费域名#x1f600;前言 手动实现 Spring 底层机制的第2篇 实现了任务阶段一编写自己 Spring 容器-准备篇【2】 #x1f3e0;个人主页#xff1a;尘觉主页 #x1f9d1;个人简介#xff1a;大家好#xff0c;我是尘觉#xff0c;希望我的文章可以帮助到大家#xff0c;您的… 前言 手动实现 Spring 底层机制的第2篇 实现了任务阶段一编写自己 Spring 容器-准备篇【2】 个人主页尘觉主页 个人简介大家好我是尘觉希望我的文章可以帮助到大家您的满意是我的动力 在csdn获奖荣誉: csdn城市之星2名 ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ Java全栈群星计划top前5 ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣ ⁣⁣⁣⁣  端午大礼包获得者 欢迎大家这里是CSDN我总结知识的地方欢迎来到我的博客感谢大家的观看 如果文章有什么需要改进的地方还请大佬不吝赐教 先在次感谢啦 文章目录 手动实现 Spring 底层机制 实现任务阶段一编写自己 Spring 容器-准备篇【2】创建SmartAnimalable接口创建SmartDog类创建SmartAnimalAspect切面类修改类beans.xml创建AppMain类输出结果 简单分析AOP 和 BeanPostProces关系看一下 AnnotationAwareAspectJAutoProxyCreator 的类图分析总结 手动实现 Spring 底层机制 实现任务阶段一编写自己 Spring 容器-准备篇【2】 创建SmartAnimalable接口 public interface SmartAnimalable {float getSum(float i, float j);float getSub(float i, float j); }创建SmartDog类 Component public class SmartDog implements SmartAnimalable {public float getSum(float i, float j) {float res i j;System.out.println(SmartDog-getSum-res res);return res;}public float getSub(float i, float j) {float res i - j;System.out.println(SmartDog-getSub-res res);return res;} }创建SmartAnimalAspect切面类 Component Aspect public class SmartAnimalAspect {//给SmartDog配置前置返回异常最终通知//前置通知Before(value execution(public float com.wyxde.spring.aop.SmartDog.getSum(float, float)))public void showBeginLog(JoinPoint joinPoint) {//通过连接点对象joinPoint 可以获取方法签名Signature signature joinPoint.getSignature();System.out.println(SmartAnimalAspect-切面类showBeginLog()[使用的myPointCut()]-方法执行前-日志-方法名- signature.getName() -参数 Arrays.asList(joinPoint.getArgs()));}//返回通知AfterReturning(value execution(public float com.wyxde.spring.aop.SmartDog.getSum(float, float)), returning res)public void showSuccessEndLog(JoinPoint joinPoint, Object res) {Signature signature joinPoint.getSignature();System.out.println(SmartAnimalAspect-切面类showSuccessEndLog()-方法执行正常结束-日志-方法名- signature.getName() 返回的结果是 res);}//异常通知AfterThrowing(value execution(public float com.wyxde.spring.aop.SmartDog.getSum(float, float)), throwing throwable)public void showExceptionLog(JoinPoint joinPoint, Throwable throwable) {Signature signature joinPoint.getSignature();System.out.println(SmartAnimalAspect-切面类showExceptionLog()-方法执行异常-日志-方法名- signature.getName() 异常信息 throwable);}//最终通知After(value execution(public float com.wyxde.spring.aop.SmartDog.getSum(float, float)))public void showFinallyEndLog(JoinPoint joinPoint) {Signature signature joinPoint.getSignature();System.out.println(SmartAnimalAspect-切面类showFinallyEndLog()-方法最终执行完毕-日志-方法名- signature.getName());}}修改类beans.xml 配置自动扫描的包, 同时引入对应的名称空间 如果我们是普通的java项目, beans.xml 放在src下如果我们是java maven 项目, beans.xml 放在 src/main/resources ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsdcontext:component-scan base-packagecom.wyxde.spring.component/context:component-scan base-packagecom.wyxde.spring.aop/!--启用基于注解方式的AOP功能--aop:aspectj-autoproxy/!--配置后置处理器--bean classcom.wyxde.spring.process.MyBeanPostProcessor idmyBeanPostProcessor/ /beans创建AppMain类 public class AppMain {public static void main(String[] args) {//测试看看是否可以得到spring容器中的bean , 同时看看依赖注入是否OKApplicationContext ioc new ClassPathXmlApplicationContext(beans.xml);UserAction userAction (UserAction) ioc.getBean(userAction);UserAction userAction2 (UserAction) ioc.getBean(userAction);System.out.println(userAction userAction);System.out.println(userAction2 userAction2);UserDao userDao (UserDao) ioc.getBean(userDao);System.out.println(userDao userDao);UserService userService (UserService) ioc.getBean(userService);System.out.println(userService userService);//测试一下当前的依赖注入userService.m1();//测试一下AOPSmartAnimalable smartDog ioc.getBean(SmartAnimalable.class);smartDog.getSum(10, 2);} }输出结果 简单分析 AOP 和 BeanPostProces关系 AOP 实现 Spring 可以通过给一个类加入注解 EnableAspectJAutoProxy 来指定, 比 如 我们来追一下EnableAspectJAutoProxy 看一下 AnnotationAwareAspectJAutoProxyCreator 的类图 分析 AOP 底层是基于 BeanPostProcessor 机制的. 即在 Bean 创建好后根据是否需要 AOP 处理决定返回代理对象还是原生 Bean 在返回代理对象时就可以根据要代理的类和方法来返回 其实这个机制并不难本质就是在 BeanPostProcessor 机制 动态代理技术 下面我们就准备自己来实现 AOP 机制, 这样小伙伴们就不在觉得 AOP 神秘通透很多了. 总结 到本文为止以及全部完成了准备了下一篇就开始正式手动实现 Spring 底层机制 手动实现 Spring 底层机制【初始化 IOC容器依赖注入BeanPostProcessor 机制AOP】系列 手动实现 Spring 底层机制 实现任务阶段一编写自己 Spring 容器-准备篇【1】 热门专栏推荐 想学习vue的可以看看这个 java基础合集 数据库合集 redis合集 nginx合集 linux合集 等等等还有许多优秀的合集在主页等着大家的光顾感谢大家的支持 欢迎大家加入我的社区 尘觉社区 文章到这里就结束了如果有什么疑问的地方请指出诸佬们一起来评论区一起讨论 希望能和诸佬们一起努力今后我们一起观看感谢您的阅读 如果帮助到您不妨3连支持一下创造不易您们的支持是我的动力
http://www.w-s-a.com/news/792929/

相关文章:

  • 好的宝安网站建设中企动力的网站开发语言
  • flash网站模板怎么用怎么套模板 网站
  • 建设二手商品网站总结石景山安保服务公司电话
  • 网站建设对于企业的重要性龙岗企业网站设计公司
  • 网站搭建在线支付数码产品网站模板
  • 白云网站建设多少钱WORDPRESS添加前台会员注册
  • 商业网站模板中国字体设计网站
  • 做网站闵行网站建设中英语
  • 写作网站大全如何简单制作生理盐水
  • 云南网站建设维护互联网广告是做什么的
  • 网站 谁建设 谁负责做网站项目
  • 网站建设子栏目怎么弄海口专门做网站
  • 网站建设 温州建设网上银行个人网上银行登
  • 黄页网站推广方案wordpress 压缩插件
  • 网站建设常州网站简介 title
  • 惠州市网站建设个人深圳网站优化价格
  • 营销型网站工程专业网站开发公司
  • 两个路由器做双网站西安关键词优化服务
  • 企业建站系统信息远象建设 网站
  • 移动建站平台物业管理系统app
  • 济南网站建设多少钱郑州公司做网站
  • 在阿里云网站建设wordpress模板如何修改字体
  • 网站推广方案设计购物网站模块例子
  • 潍坊网站定制公司网站图片放大特效怎么做的
  • 淘宝店铺买卖湘潭seo优化价格
  • 最好的网站建设用途合肥企业网站建设
  • 计算机编程与网站建设好玩的网页传奇
  • 商务网站建设找哪家本地推广找哪些网站
  • 手机h5网站企业网站管理系统的运维服务
  • 南京建设网站公司网站游戏怎么制作