Simple Note
From reference:
A smart proxy interposes additional actions when an object is accessed. Typical uses include:
Counting the number of references to the real object so that it can be freed automatically when there are no more references (aka smart pointer),
Loading a persistent object into memory when it's first referenced,
Checking that the real object is locked before it is accessed to ensure that no other object can change it.
Smart References: providing a sophisticated access to certain objects such as tracking the number of references to an object and denying access if a certain number is reached, as well as loading an object from database into memory on demand.
Program
https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/proxy/smartproxy
Run TestMain.java to test.
OperatorProxy will limit the operation performed by RealOperator, at most 3 operation at a time.
Reference:
Proxy Design Pattern
Proxy Pattern
No comments:
Post a Comment