package com.sxt.Thread;
/**
* 静态代理
* 公共接口:
* 1、真实角色
* 2、代理角色
* @author
*
*/
public class StaticProxy {
public static void main(String[] args) {
new WeddingCompany(new You()).happyMarry();
}
}
interface Marry {
void happyMarry();
}
//真实角色
class You implements Marry{
@Override
public void happyMarry() {
System.out.println("终于和嫦娥奔月了...");
}
}
//代理角色
class WeddingCompany implements Marry{
//真实角色
private Marry target;
public WeddingCompany(Marry target) {
this.target = target;
}
@Override
public void happyMarry() {
ready();
this.target.happyMarry();
after();
}
public void ready() {
System.out.println("准备新人的洞房...");
}
public void after() {
System.out.println("闹玉兔...");
}
}