<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # 動態代理 動態代理:不用手動編寫一個代理對象,不需要一一編寫與目標對象相同的方法(靜態代理),這個過程,在運行時 的內存中動態生成代理對象。------字節碼對象級別的代理對象 動態代理的API: 在jdk的API中存在一個Proxy中存在一個生成動態代理的的方法newProxyInstance ![](https://box.kancloud.cn/3c64ab0158ab7e4a48dd609354557e1f_682x67.jpg) 返回值:Object就是代理對象 參數:loader:代表與目標對象相同的類加載器-------目標對 象.getClass().getClassLoader() interfaces:代表與目標對象實現的所有的接口字節碼對象數組 h:具體的代理的操作,InvocationHandler接口 注意:JDK的Proxy方式實現的動態代理 目標對象必須有接口 沒有接口不能實現jdk版動態代理 這邊TargetInterface是接口 ~~~ TargetInterface objProxy = (TargetInterface) Proxy.newProxyInstance( Target.class.getClassLoader(), //與目標對象相同的類加載器 new Class[]{TargetInterface.class}, //這個也行target.getClass().getInterfaces() new InvocationHandler() { //invoke 代表的是執行代理對象的方法 @Override //method:代表目標對象的方法字節碼對象 //args:代表目標對象的響應的方法的參數 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("目標方法前的邏輯"); //執行目標對象的方法 Object invoke = method.invoke(new Target(), args); System.out.println("目標方法后的邏輯"); return invoke; } } ); objProxy.method1(); String method2 = objProxy.method2(); System.out.println(method2); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看