-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProxyPattern.java
44 lines (31 loc) · 983 Bytes
/
ProxyPattern.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package br.com.luzaraldi;
//luzaraldi.medium.com
public class ProxyPattern {
public static void main(String[] args) {
System.out.println();
new client().greet("LuzAraldi");
}
interfaceSubctInterface {
String greet(String name);
}
class RealSubject implements SubjectInterface {
@Override
public String greet(String name) {
return ("Hello, " + name + "!");
}
}
class RealSubjectProxy implements SubjectInterface {
private SubjectInterface realsubject = new Realsubject();
@Override
public String greet(String );
System.out.println("Proxy: Loggin before gretting...");
String result = realSubject.greet(name);
System.out.println("Proxy: Loggin after gretting...");
return result;
}
Class Client {
public String greet(String name) {
var realSubjectProxy = new RealSubtProxi();
return realSubjectProxy.greet(name);
}
}