diff --git a/src/learn/simple_proxy/Main.java b/src/learn/simple_proxy/Main.java new file mode 100644 index 0000000..584a174 --- /dev/null +++ b/src/learn/simple_proxy/Main.java @@ -0,0 +1,8 @@ +package learn.simple_proxy; + +public class Main { + public static void main(String[] args) { + Subject subject = new Proxy(); + subject.request(); + } +} diff --git a/src/learn/simple_proxy/Proxy.java b/src/learn/simple_proxy/Proxy.java new file mode 100644 index 0000000..760002d --- /dev/null +++ b/src/learn/simple_proxy/Proxy.java @@ -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(); + } +} diff --git a/src/learn/simple_proxy/RealSubject.java b/src/learn/simple_proxy/RealSubject.java new file mode 100644 index 0000000..c638e12 --- /dev/null +++ b/src/learn/simple_proxy/RealSubject.java @@ -0,0 +1,8 @@ +package learn.simple_proxy; + +public class RealSubject implements Subject { + @Override + public void request() { + System.out.println("Real subject action"); + } +} diff --git a/src/learn/simple_proxy/Subject.java b/src/learn/simple_proxy/Subject.java new file mode 100644 index 0000000..65c8959 --- /dev/null +++ b/src/learn/simple_proxy/Subject.java @@ -0,0 +1,5 @@ +package learn.simple_proxy; + +public interface Subject { + public void request(); +}