Skip to content

Commit d907e7a

Browse files
committed
增加代理模式
1 parent 4aa73fc commit d907e7a

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

src/main/java/cn/byhieg/collectiontutorial/maptutorial/TreeMapExample.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.byhieg.collectiontutorial.maptutorial;
22

3-
import apple.laf.JRSUIUtils;
43

54
import java.util.Iterator;
65
import java.util.Map;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.byhieg.designpatterntutorial.proxy.staticproxy;
2+
3+
/**
4+
* Created by shiqifeng on 2017/3/17.
5+
* Mail byhieg@gmail.com
6+
*/
7+
public class Client {
8+
9+
public static void main(String[] args) {
10+
ProxySubject subject = new ProxySubject(new RealSubject());
11+
subject.visit();
12+
}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cn.byhieg.designpatterntutorial.proxy.staticproxy;
2+
3+
/**
4+
* Created by shiqifeng on 2017/3/17.
5+
* Mail byhieg@gmail.com
6+
*/
7+
public class ProxySubject implements Subject{
8+
9+
private Subject subject;
10+
11+
public ProxySubject(Subject subject) {
12+
this.subject = subject;
13+
}
14+
15+
@Override
16+
public void visit() {
17+
subject.visit();
18+
}
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cn.byhieg.designpatterntutorial.proxy.staticproxy;
2+
3+
/**
4+
* Created by shiqifeng on 2017/3/17.
5+
* Mail byhieg@gmail.com
6+
*/
7+
public class RealSubject implements Subject {
8+
9+
private String name = "byhieg";
10+
@Override
11+
public void visit() {
12+
System.out.println(name);
13+
}
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package cn.byhieg.designpatterntutorial.proxy.staticproxy;
2+
3+
/**
4+
* Created by shiqifeng on 2017/3/17.
5+
* Mail byhieg@gmail.com
6+
*/
7+
public interface Subject {
8+
9+
void visit();
10+
}

0 commit comments

Comments
 (0)