stoop 437-proxy

9
S.Ducasse 1 QuickTime™ TIFF (Uncompr are needed t Stéphane Ducasse [email protected] http://www.listic.univ-savoie.f r/~ducasse/ Proxy

Upload: the-world-of-smalltalk

Post on 27-Nov-2014

535 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Stoop 437-proxy

S.Ducasse 1

QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.

Stéphane [email protected]://www.listic.univ-savoie.fr/~ducasse/

Proxy

Page 2: Stoop 437-proxy

S.Ducasse 2

License: CC-Attribution-ShareAlike 2.0http://creativecommons.org/licenses/by-sa/2.0/

Page 3: Stoop 437-proxy

S.Ducasse 3

Proxy•Category

• Structural

• Intent• Provide a surrogate or placeholder for another

object to control access to it

•Also known as• Surrogate

Page 4: Stoop 437-proxy

S.Ducasse 4

Proxy Pattern Motivation

Page 5: Stoop 437-proxy

S.Ducasse 5

Proxy Applicability

• 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, in order to enforce access rights

• A smart reference is a replacement for a bare pointer that performs additional actions when an object is accessed

Page 6: Stoop 437-proxy

S.Ducasse 6

Proxy Pattern Structure

Page 7: Stoop 437-proxy

S.Ducasse 7

Proxy Pattern Participants• Proxy (ImageProxy)

• maintains a reference that lets the proxy access the real subject

• provides an interface identical to Subject’s so that a proxy can be substituted for the real subject

• controls access to the real subject and may be responsible for creating and deleting it

Page 8: Stoop 437-proxy

S.Ducasse 8

Proxy Participants (continued)•Subject (Graphic)

• defines the common interface for RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is expected

•RealSubject (Image)• defines the real object that the proxy

represents

Page 9: Stoop 437-proxy

S.Ducasse 9

Proxy Consequences•Consequences

• A remote proxy can hide the fact that an object resides in a different address space

• A virtual proxy can perform optimizations such as creating an object on demand

• Both protection proxies and smart references allow additional housekeeping tasks when an object is accessed