<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          【對線面試官】今天來聊聊Java注解

          共 1692字,需瀏覽 4分鐘

           ·

          2020-12-26 07:26

          public?void?send(String?userName)?{
          ??try?{
          ????//?qps?上報(bào)
          ????qps(params);
          ????long?startTime?=?System.currentTimeMillis();

          ????//?構(gòu)建上下文(模擬業(yè)務(wù)代碼)
          ????ProcessContext?processContext?=?new?ProcessContext();
          ????UserModel?userModel?=?new?UserModel();
          ????userModel.setAge("22");
          ????userModel.setName(userName);
          ????//...

          ????//?rt?上報(bào)
          ????long?endTime?=?System.currentTimeMillis();
          ????rt(endTime?-?startTime);
          ??}?catch?(Exception?e)?{
          ????
          ????//?出錯(cuò)上報(bào)
          ????error(params);
          ??}
          }
          @Around("@annotation(com.sanwai.service.openapi.monitor.Monitor)")
          public?Object?antispan(ProceedingJoinPoint?pjp)?throws?Throwable?{

          ????String?functionName?=?pjp.getSignature().getName();
          ????Map?tags?=?new?HashMap<>();

          ????logger.info(functionName);

          ????tags.put("functionName",?functionName);
          ????tags.put("flag",?"done");

          ????monitor.sum(functionName,?"start",?1);

          ????//方法執(zhí)行開始時(shí)間
          ????long?startTime?=?System.currentTimeMillis();

          ????Object?o?=?null;
          ????try?{
          ????????o?=?pjp.proceed();
          ????}?catch?(Exception?e)?{
          ????????//方法執(zhí)行結(jié)束時(shí)間
          ????????long?endTime?=?System.currentTimeMillis();

          ????????tags.put("flag",?"fail");
          ????????monitor.avg("rt",?tags,?endTime?-?startTime);

          ????????monitor.sum(functionName,?"fail",?1);
          ????????throw?e;
          ????}

          ????//方法執(zhí)行結(jié)束時(shí)間
          ????long?endTime?=?System.currentTimeMillis();

          ????monitor.avg("rt",?tags,?endTime?-?startTime);

          ????if?(null?!=?o)?{
          ????????monitor.sum(functionName,?"done",?1);
          ????}
          ????return?o;
          }

          文章以純面試的角度去講解,所以有很多的細(xì)節(jié)是未鋪墊的。

          比如說反射、.java文件到j(luò)vm的過程、AOP是什么等等等基礎(chǔ)...這些在【Java3y】都有過詳細(xì)的基本教程甚至電子書,我就不再詳述了。

          注解可以把它當(dāng)做是配置的載體,可能在運(yùn)行時(shí)、可能在編譯過程中解析注解,實(shí)現(xiàn)些方便好用的功能。


          歡迎關(guān)注我的微信公眾號【面試造火箭】來聊聊Java面試

          添加我的微信sanwaiyihao進(jìn)一步交流和學(xué)習(xí)

          瀏覽 61
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  日韩 码A片 | 久久在操 | 成人伊人网在线 | av网在线观看 | 玖玖视频在线观看 |