docs: update virtual proxy

This commit is contained in:
Ilkka Seppälä committed 2024-05-27 14:55:38 +03:00
1 parent 3eb5813133
commit cca57bfa5e
1 file changed
+10 -11
+10 -11
View File
@@ -74,6 +74,7 @@ The `VideoObjectProxy` serves as a stand-in for `RealExpensiveObject`.
```java ```java
@Getter @Getter
public class VideoObjectProxy implements ExpensiveObject { public class VideoObjectProxy implements ExpensiveObject {
private RealVideoObject realVideoObject; private RealVideoObject realVideoObject;
public void setRealVideoObject(RealVideoObject realVideoObject) { public void setRealVideoObject(RealVideoObject realVideoObject) {
@@ -93,23 +94,21 @@ public class VideoObjectProxy implements ExpensiveObject {
And here’s how the proxy is used in the system. And here’s how the proxy is used in the system.
```java ```java
ExpensiveObject object = new VirtualProxy(); public static void main(String[] args) {
object.process(); // The real object is created at this point ExpensiveObject videoObject = new VideoObjectProxy();
object.process(); // Uses the already created object videoObject.process(); // The first call creates and plays the video
videoObject.process(); // Subsequent call uses the already created object
}
``` ```
Program output: Program output:
``` ```
13:11:13.583 [main] INFO com.iluwatar.virtual.proxy.RealVideoObject -- Loading initial video configurations... 14:54:30.602 [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... 14:54:30.604 [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.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 ## Applicability
Use the Virtual Proxy pattern when: Use the Virtual Proxy pattern when:
@@ -120,7 +119,7 @@ Use the Virtual Proxy pattern when:
## Tutorials ## 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 ## Known Uses