- Forward


The Proxy Pattern
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Motivation
Back SMYC Forward
  • The Need:
    • Control access to an object
  • Examples:
    • The object may be expensive to use (e.g., the manipulation of an image) and it may not be necessary to do so (e.g., because the image is not visible or because you are using a thumbnail)
    • The object being accessed may reside on a "remote" address space/machine and special "communications" may be required
    • The object being accessed may be "privileged" (e.g., for security reasons) in some applications and not in others
Implementation
Back SMYC Forward

One Approach (in UML)

proxy
The Dynamics
Back SMYC Forward

A UML Sequence Diagram

proxy_sequence
An Example
Back SMYC Forward
javaexamples/proxy/IconProxy.java
 
An Example (cont.)
Back SMYC Forward
javaexamples/proxy/IconFrame.java
 
An Example (cont.)
Back SMYC Forward
javaexamples/proxy/Driver.java
 
Combining Proxy and FactoryMethod
Back SMYC Forward

In UML

proxywithfactory_sequence
There's Always More to Learn
Back -