Files
abstract-factory
adapter
async-method-invocation
bridge
builder
business-delegate
callback
chain
command
composite
dao
decorator
dependency-injection
double-checked-locking
double-dispatch
event-aggregator
execute-around
facade
factory-method
flux
flyweight
front-controller
half-sync-half-async
intercepting-filter
interpreter
iterator
layers
lazy-loading
mediator
memento
message-channel
model-view-controller
model-view-presenter
multiton
naked-objects
null-object
object-pool
observer
poison-pill
private-class-data
property
prototype
proxy
etc
src
index.md
pom.xml
repository
resource-acquisition-is-initialization
servant
service-layer
service-locator
singleton
specification
state
step-builder
strategy
template-method
thread-pool
tolerant-reader
visitor
.gitignore
.travis.yml
LICENSE.md
README.md
checkstyle.xml
faq.md
pom.xml
java-design-patterns/proxy/index.md

35 lines
1.1 KiB
Markdown
Raw Normal View History

---
layout: pattern
title: Proxy
folder: proxy
permalink: /patterns/proxy/
categories: Structural
tags: Java
---
**Intent:** Provide a surrogate or placeholder for another object to control
access to it.
![alt text](./etc/proxy_1.png "Proxy")
**Applicability:** Proxy is applicable whenever there is a need for a more
versatile or sophisticated reference to an object than a simple pointer. Here
are several common situations in which the Proxy pattern is applicable
* a remote proxy provides a local representative for an object in a different address space.
* a virtual proxy creates expensive objects on demand.
* a protection proxy controls access to the original object. Protection proxies are useful when objects should have different access rights.
**Typical Use Case:**
* control access to another object
* lazy initialization
* implement logging
* facilitate network connection
* to count references to an object
**Real world examples:**
* [java.lang.reflect.Proxy](http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Proxy.html)
* [Apache Commons Proxy](https://commons.apache.org/proper/commons-proxy/)