@Test void getUserService() { jdkProxyDemo.getUserService().addUser("xiaoming"); jdkProxyDemo.getUserService().removeUser("xiaoming"); jdkProxyDemo.getUserService().getUsername("xiaoming"); System.out.println(); jdkProxyDemo.getUserService().getClass(); }
public UserService getUserService(){ ProxyHandler proxyHandler = new ProxyHandler(userService); return (UserService) Proxy.newProxyInstance(proxyHandler.getClass().getClassLoader(),userService.getClass().getInterfaces(),proxyHandler); }
JDKProxyDemo { public UserService getUserService(){ ProxyHandler proxyHandler = new ProxyHandler(userService); return (UserService) Proxy.newProxyInstance(proxyHandler.getClass().getClassLoader(),userService.getClass().getInterfaces(),proxyHandler); } }
JDKProxyDemo { public UserService getUserService(){ ProxyHandler proxyHandler = new ProxyHandler(userService); return (UserService) Proxy.newProxyInstance(proxyHandler.getClass().getClassLoader(),userService.getClass().getInterfaces(),proxyHandler); }  }
JDKProxyDemo { public UserService getUserService(){ ProxyHandler proxyHandler = new ProxyHandler(userService); return (UserService) Proxy.newProxyInstance(proxyHandler.getClass().getClassLoader(),userService.getClass().getInterfaces(),proxyHandler); }  UserService getUserService(); }
JDKProxyDemo { public UserService getUserService(){ ProxyHandler proxyHandler = new ProxyHandler(userService); return (UserService) Proxy.newProxyInstance(proxyHandler.getClass().getClassLoader(),userService.getClass().getInterfaces(),proxyHandler); }  UserService getUserService();  }