infoo

//要代理的对象

private A target;

//获取代理对象

public A getProxy(){

      A a=null;

      //确定代理对象的类加载器

      ClassLoader loader=target.getClass().getClassLoader();

     //代理对象类型,即其中有哪些方法

     Class []interfaces=new Class[]{A.class}

    //当调用代理对象其中的方法时,执行的代码

    InvocationHandler h=new InvocationHandler(){

      @Override

       public Object invoke(Object proxy,Method method,Object[] args) throws  Throwable{

            

           *******************

         return null; 

       }

     };

 

    a=(A)Proxy.newProxyInstance(loader,interfaces,h);

    return a;

}

 

分类:

技术点:

相关文章:

  • 2022-01-28
  • 2022-01-20
  • 2021-06-05
  • 2021-04-16
  • 2021-04-18
  • 2021-08-30
  • 2021-06-28
猜你喜欢
  • 2021-07-15
  • 2021-08-05
  • 2021-09-17
  • 2021-12-26
  • 2021-12-11
  • 2021-09-03
  • 2021-08-03
  • 2021-08-22
相关资源
相似解决方案