Wednesday, May 21, 2014

Smart Proxy Pattern in Java

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.


Run to test.

OperatorProxy will limit the operation performed by RealOperator, at most 3 operation at a time.


Proxy Design Pattern

Proxy Pattern

No comments:

Post a Comment