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

天河网站建设哪里好营销类网站建设需要注意的问题

天河网站建设哪里好,营销类网站建设需要注意的问题,网站链接推广怎么赚钱,项目介绍ppt模板前置通知环绕通知后置通知最终通知异常通知 API类似#xff0c;只是生效的时机不一样#xff0c;并且#xff0c;不能保证#xff0c;各个通知的顺序 try {//前置通知before();//环绕通知#xff0c;内部是执行的方法around(proxy,method,args,methodProxy);//后置通知a…前置通知环绕通知后置通知最终通知异常通知 API类似只是生效的时机不一样并且不能保证各个通知的顺序 try {//前置通知before();//环绕通知内部是执行的方法around(proxy,method,args,methodProxy);//后置通知afterReturn(); } catch (Throwable e) {exception();//异常通知 }finally {after();//最终通知 } 前置通知 被访问的方法执行之前执行的通知 先执行通知的方法然后再执行被访问的方法本身 public void f2(JoinPoint joinPoint){ System.out.println(----------前置通知); //被访问方法的参数 Object[] args joinPoint.getArgs(); //被访问方法所在类的bean对象 Object target joinPoint.getTarget(); //被访问的方法 MethodSignature signature (MethodSignature) joinPoint.getSignature(); Method method signature.getMethod(); System.out.println(method.getName()被调用了传入了参数 Arrays.toString(args)---所在类target); } 环绕通知 public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {System.out.println(环绕通知开始);//调用方法必须写的如果不写目标方法不会被调用//Object o 是被执行方法的返回值Object o joinPoint.proceed();//MethodSignature signature (MethodSignature) joinPoint.getSignature();Method method signature.getMethod();Object[] args joinPoint.getArgs();//method.invoke(12);System.out.println(环绕通知结束method.getName());return o; } 配置通知 aop:aspect reftest1!--前置通知,在切入点的方法,被访问之前,执行的方法--aop:before methodf2 pointcut-refq3/aop:around methodaroundMethod pointcut-refq3/aop:after-throwing methodf3 pointcut-refq3/aop:after methodf4 pointcut-refq3/aop:after-returning methodf5 pointcut-refq3/ /aop:aspect SpringAOP原理 动态代理 注解AOP ?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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aophttps://www.springframework.org/schema/aop/spring-aop.xsd context:component-scan base-packagecom.javasm/!--开启AOP注解--aop:aspectj-autoproxy/ /beans //aop:aspect refaspect2 Component(aspect2) Aspect public class TestAspect2 {//切点标记Pointcut(execution(* com.javasm.*.service.*.*.query*(..)))void f1(){}Before(f1())void before(JoinPoint joinPoint){System.out.println(注解前置通知);}Around(f1())Object aroundTest(ProceedingJoinPoint joinPoint) throws Throwable {System.out.println(-----环绕通知开始);Object proceed joinPoint.proceed();System.out.println(------环绕通知结束);return proceed;}After(f1())void after(JoinPoint joinPoint){System.out.println(最终通知);}//AfterReturning(f1())AfterReturning(value f1(),returning msg)void afterReturn(JoinPoint joinPoint,Object msg){System.out.println(##########后置通知########返回值:msg);}//AfterThrowing(f1())AfterThrowing(value f1(),throwing e)void afterThrowing(JoinPoint joinPoint,Throwable e){System.out.println(异常通知:e);} } 自定义注解 自定义注解搭配AOP注解,灵活的控制方法 案例: 想在项目中记录日志 但是不是每个模块每个方法都记录 哪个方法需要记录,现在还不确定,但是要提前把业务逻辑写好 利用自定义注解,哪个方法需要增加日志,就在哪个方法上面加上自定义注解 自定义注解 Target(ElementType.METHOD) Retention(RetentionPolicy.RUNTIME) public interface SaveLog {//String value(); } 切面类 Component Aspect public class SaveLogAspect {ResourceLogService logService;//方法执行结束之后,保存日志AfterReturning(annotation(com.javasm.aspect.SaveLog))public void saveLog(JoinPoint joinPoint){String msg %s方法,在%s时间,被调用了,参数是%s;//方法MethodSignature signature (MethodSignature) joinPoint.getSignature();Method method signature.getMethod();String methodName method.getName();//时间SimpleDateFormat simpleDateFormat new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);String time simpleDateFormat.format(new Date());//参数String parameters Arrays.toString(joinPoint.getArgs());msg String.format(msg,methodName,time,parameters);logService.save(msg);} } SaveLog 控制到类 案例: 统计方法运行消耗的时间 统计某一个类所有的方法 within必须是在类级别生效 Retention(RetentionPolicy.RUNTIME) Target(ElementType.TYPE) public interface Time { } Component Aspect public class TimeAspect {Around(within(com.javasm.aspect.Time))public Object around(ProceedingJoinPoint joinPoint) throws Throwable {long start System.currentTimeMillis();Object proceed joinPoint.proceed();long time System.currentTimeMillis() - start;String msg %s方法,运行消耗的时间是%s毫秒;MethodSignature signature (MethodSignature) joinPoint.getSignature();String methodName signature.getMethod().getName();System.out.printf(msg,methodName,time);return proceed;} } Time 配置类启动 Configuration ComponentScan(com.javasm) EnableAspectJAutoProxy//开启注解AOP public class JavasmConfig {} AnnotationConfigApplicationContext applicationContext new AnnotationConfigApplicationContext(JavasmConfig.class);
http://www.pierceye.com/news/357250/

相关文章:

  • 网站建设实现用户登录济南网站建设找老兵
  • 做网站还挣钱吗成都网站设计策划免费
  • 阿里云服务器怎么放网站百度开户渠道商哪里找
  • 网赢天下深圳网站建设建设一个小说网站
  • 北湖区网站建设哪家好什么做网站的公司好
  • 做司法亲子鉴定网站专业设计服务网站
  • 网站建设排序题wordpress菜单左对齐
  • 太原网站建设方案维护北京网站建设东轩seo
  • 网站弹屏广告怎么做的自适应网站建设特点
  • 有一个网站专门做民宿做数据可视化图的网站
  • 手机产品 网站建设网站建设费怎么记账
  • 网站页面设计好了后台如何添加构建平台还是搭建平台
  • 公司展示类网站模板中国校园网站做的比较好的学校
  • 锡山建设局网站白云做网站的公
  • 上海网站制作软件wordpress 访问控制
  • 西部数码助手网站后台管理优秀的包装设计案例
  • 建站教学做门户网站怎么赚钱
  • 怎么自己编程做网站成都住建平台
  • 林州二建集团建设有限公司网站免费做链接的app有哪些
  • 建设企业网站企业网上银行登录官网宁波网站建设公司名单推荐
  • 网站直播用php怎么做的书城网站开发的参考文献
  • 广州免费自助建站平台韩国出线了吗
  • asp.net网站开发实训爆款采集推广引流软件
  • 怎么把自己做的网站挂到外网上中文 网站模板
  • 篮球运动装备网站模板昆明网站seo多少钱
  • 建筑网站起名wordpress评论折叠
  • 东莞seo网站推广建设抖音开放平台注册
  • 怎么做淘宝客采集网站建设局考试通知文件网站
  • 百度云网站建设视频教程超市网站设计
  • 主机屋 建网站教程wordpress收费会员插件