<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 概念 代理類/代理對象就是增強類.就 已有類的功能進行增強. ## 動態代理 動態的給我們生成代理類/代理對象. java 已經給我們提供好了. proxy. 這個方式叫JDK的動態代理. ## 實例 ~~~ public static void main(String[] args) { final NormalPerson normalPerson = new NormalPerson(); //使用JDK提供的動態代理動態代理的方式增強 /** * 參數1:和要被增強的對象一樣的類加載器 * 參數2:和要被增強的對象一樣的接口 * 1.根據指定的傳遞接口返回一個該接口下的實例 * 2.傳遞的接口里面的方法就是可以被增強的所有方法,被增強類自己的方法無法被增強 * 參數3:所有的增強業務的實現(方法) */ Person proxyInstance = (Person) Proxy.newProxyInstance( normalPerson.getClass().getClassLoader(), normalPerson.getClass().getInterfaces(), //匿名內部類 new InvocationHandler() { //invoke里面就是所有的增強業務邏輯代碼 /** * 參數1:不用管,永遠是固定值,代理對象的類型 * 參數2:要被增強的方法 * 參數3:要被增強的方法運行過程中需要的參數 */ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { //讓之前的方法執行 /** * 參數1:本身執行這個方法的對象 * 參數2:執行這個方法需要的參數 */ method.invoke(normalPerson,args); //這里使用了normalPerson需要使用final進行修飾,否則會被垃圾回收機制進行回收 //寫增強業務邏輯 System.out.println("走變飛"); return null; } } ); proxyInstance.run(); } ~~~
                  <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>

                              哎呀哎呀视频在线观看