1.1.3. Proxy Variations
From the book:
Proxy has several use cases:
- Virtual proxy creates expensive objects on demand. An example is the LazyConnectionDataSourceProxyin the Spring Framework, which lazily creates the real JDBCDataSourcewhen the firstStatementis created.
- Remote proxy provides a local representation of an object that sits in a different address space, for example on a remote machine. Note that the remote proxy does not have a real pointer to the remote object, but invokes the methods via RPC, RMI, Thrift, ProtoBuf, gRPC, REST, HTTP, TCP/UDP, or a different remoting mechanism.
- Protection proxy controls access to the original object. This could be for access control or thread safety. An example is Collections.synchronizedCollection(), which returns a newCollectionthat is guarded against race conditions.
0 comments