added proxy example
This commit is contained in:
parent
94df35881e
commit
3743b47887
8
src/learn/simple_proxy/Main.java
Normal file
8
src/learn/simple_proxy/Main.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package learn.simple_proxy;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Subject subject = new Proxy();
|
||||||
|
subject.request();
|
||||||
|
}
|
||||||
|
}
|
11
src/learn/simple_proxy/Proxy.java
Normal file
11
src/learn/simple_proxy/Proxy.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package learn.simple_proxy;
|
||||||
|
|
||||||
|
public class Proxy implements Subject {
|
||||||
|
private RealSubject realSubject = new RealSubject();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void request() {
|
||||||
|
System.out.println("Proxy does some preliminary job and checks");
|
||||||
|
realSubject.request();
|
||||||
|
}
|
||||||
|
}
|
8
src/learn/simple_proxy/RealSubject.java
Normal file
8
src/learn/simple_proxy/RealSubject.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package learn.simple_proxy;
|
||||||
|
|
||||||
|
public class RealSubject implements Subject {
|
||||||
|
@Override
|
||||||
|
public void request() {
|
||||||
|
System.out.println("Real subject action");
|
||||||
|
}
|
||||||
|
}
|
5
src/learn/simple_proxy/Subject.java
Normal file
5
src/learn/simple_proxy/Subject.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package learn.simple_proxy;
|
||||||
|
|
||||||
|
public interface Subject {
|
||||||
|
public void request();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user