docs: update virtual proxy

This commit is contained in:
Ilkka Seppälä
2024-05-27 14:55:38 +03:00
parent 3eb5813133
commit cca57bfa5e
+10 -11
View File
@@ -74,6 +74,7 @@ The `VideoObjectProxy` serves as a stand-in for `RealExpensiveObject`.
```java
@Getter
public class VideoObjectProxy implements ExpensiveObject {
private RealVideoObject realVideoObject;
public void setRealVideoObject(RealVideoObject realVideoObject) {
@@ -93,23 +94,21 @@ public class VideoObjectProxy implements ExpensiveObject {
And heres how the proxy is used in the system.
```java
ExpensiveObject object = new VirtualProxy();
object.process(); // The real object is created at this point
object.process(); // Uses the already created object
public static void main(String[] args) {
ExpensiveObject videoObject = new VideoObjectProxy();
videoObject.process(); // The first call creates and plays the video
videoObject.process(); // Subsequent call uses the already created object
}
```
Program output:
```
13:11:13.583 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Loading initial video configurations...
13:11:13.585 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Processing and playing video content...
13:11:13.585 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Processing and playing video content...
14:54:30.602 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Loading initial video configurations...
14:54:30.604 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Processing and playing video content...
14:54:30.604 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Processing and playing video content...
```
## Class diagram
![Virtual Proxy](./etc/virtual.proxy.urm.png "Virtual Proxy pattern class diagram")
## Applicability
Use the Virtual Proxy pattern when:
@@ -120,7 +119,7 @@ Use the Virtual Proxy pattern when:
## Tutorials
* [The Proxy Pattern in Java - Baeldung](https://www.baeldung.com/java-proxy-pattern)
* [The Proxy Pattern in Java (Baeldung)](https://www.baeldung.com/java-proxy-pattern)
## Known Uses