added proxy example

This commit is contained in:
Louis Heredero 2024-11-11 09:24:37 +01:00
parent 94df35881e
commit 3743b47887
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
4 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package learn.simple_proxy;
public class Main {
public static void main(String[] args) {
Subject subject = new Proxy();
subject.request();
}
}

View 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();
}
}

View File

@ -0,0 +1,8 @@
package learn.simple_proxy;
public class RealSubject implements Subject {
@Override
public void request() {
System.out.println("Real subject action");
}
}

View File

@ -0,0 +1,5 @@
package learn.simple_proxy;
public interface Subject {
public void request();
}