1
静态代理
Singer.java
public interface Singer {
void sing(String song);
void dance(String dance);
}
SingerImpl.java
public class SingerImpl implements Singer{
@Override
public void sing(String song) {
System.out.println("调试后自己开始唱:" + song);
}
@Override
public void dance(String dance) {
System.out.println("完备后自己开始跳:" + dance);
}
}
ProxySinger.java
public class ProxySinger implements Singer {
Singer mSinger;
ProxySinger(Singer singer) {
mSinger = singer;
}
@Override
public void sing(String song) {
System.out.println("代理帮忙调试麦克风");
mSinger.sing(song);
}
@Override
public void dance(String dance) {
System.out.println("代理帮忙准备舞台");
mSinger.dance(dance);
}
}
** 总结 **
能代理类
动态代理
cglib
https://blog.csdn.net/pangqiandou/article/details/52964066
网友评论