public class ProxyTarget {
public void doSomething() {
System.out.println("do something");
}
}
public class StaticProxy {
private ProxyTarget target;
public StaticProxy(ProxyTarget target) {
this.target = target;
}
public void before() {
System.out.println("before execution...");
target.doSomething();
}
public void around() {
System.out.println("before execution...");
target.doSomething();
System.out.println("after execution...");
}
public void after() {
target.doSomething();
System.out.println("after execution...");
}
}
public class StaticProxyTester {
public static void main(String args[]) {
ProxyTarget target = new ProxyTarget();
StaticProxy proxy = new StaticProxy(target);
proxy.before();
System.out.println();
proxy.around();
System.out.println();
proxy.after();
}
}
before execution...
do something
before execution...
do something
after execution...
do something
after execution...