﻿<?xml-stylesheet type="text/xsl" href="../../templates/doc.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html 
	xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:doc="http://www.lepus.org.uk/doc" 
	xmlns:classz="http://www.lepus.org.uk/classz" 
	xmlns:fopl="http://www.lepus.org.uk/fopl" 
	xml:lang="EN-GB" 
	xmlns:v="urn:schemas-microsoft-com:vml" 
	xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
	<link rel="stylesheet" type="text/css" href="../../templates/doc.css" />
	<title>Proxy pattern: The LePUS3 &amp; Class-Z companion to the GoF</title>
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<meta name="Author" content="Amnon H Eden" />
</head>


<body>


<h5><a href="./index.xml">The 'Gang of Four' Companion:</a></h5>

<p class="pagetitle">Proxy Design Pattern</p>

<h5><a href="./index.xml">Formal specification of design patterns in LePUS3 and Class-Z</a></h5>

<p><a href="companion.pdf" style="border:0px">
	<img alt="Print this document" src="../../site/print.gif" /></a></p>

<div class="abstract">

	<p>This page is part of the <a href="./index.xml">The 'Gang of Four' Companion</a> 
	dedicated to the formal specification in LePUS3 and Class-Z of patterns from the 'Gang of Four' catalogue [<a href="http://www.lepus.org.uk/ref/index.xml#bib">Gamma 
	et al 1995</a>].</p>

</div> <!-- Abstract-->

<doc:toc />

<h3>Links</h3>

<div class="abstract">

<ul>
		<li><a href="../legend/legend.xml">Legend: Key to LePUS3 and Class-Z Symbols</a></li>
		<li><a href="ref/refman/refman.xml">Reference Manual for LePUS3 &amp; Class-Z </a></li>
		<li><a href="faq.xml">Modelling Design Patterns: Frequently-Asked Questions</a></li>
	</ul>

	<p>Download:</p>
	
	<ul>
		<li><a href="../../spec/gof/lepus3/gof.vsd">The 'gang of four' patterns in LePUS3 (Visio 2003 format)</a></li>
		<li><a href="../../spec/gof/uml/gof.vsd">The 'gang of four' patterns in UML (Visio 2003 format)</a></li>
	</ul>
	
</div> <!-- Links -->


<h1>The Proxy design motif</h1>

<p>The informal description: Excerpts from [<a href="../index.xml#bib">Gamma et al. 1995</a>] (adapted for 
	this purpose):</p>

<p><strong>Intent</strong>: Provide a surrogate or placeholder for another object to control access to it.</p>
	
<p><strong>Structure</strong>: Original OMT diagram converted to UML (<a href="faq.xml#Why_did_you_convert_the_original_diagrams_to_UML_and_how?">Why 
	and How?</a>):</p>

<img alt="Proxy in UML" src="../../spec/gof/uml/Proxy.png" /> <br />

<p><strong>Participants</strong>: </p>
<ul>
	<li><b>Proxy</b>:
		<ul>
			<li>Maintains a reference that lets the proxy access the real subject. Proxy may refer to a Subject if the RealSubject and Subject interfaces are the same.</li>
			<li>Provides an interface identical to Subject's so that a proxy can by substituted for the real subject.</li>
			<li>Controls access to the real subject and may be responsible for creating and deleting it.</li>
			<li>Other responsibilities depend on the kind of proxy:
				<ul>
					<li>Remote proxies are responsible for encoding a request and its arguments and for sending the encoded request to the real subject in a different address space.</li>
					<li>Virtual proxies may cache additional information about the real subject so that they can postpone accessing it. For example, the ImageProxy from the Motivation caches the real image's extent.</li>
					<li>Protection proxies check that the caller has the access permissions required to perform a request.</li>
          		</ul>
          	</li>
		</ul>
	</li>
	<li><b>Subject</b>: defines the common interface for RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is expected.</li>
	<li><b>RealSubject</b>: defines the real object that the proxy represents.</li>
</ul>

<p><strong>Collaborations</strong>: Proxy forwards requests to RealSubject when appropriate, depending on the kind of proxy.</p>

<h1>Formal specification</h1>
<p>See also:</p>
<ul>
		<li><a href="../legend/legend.xml">Legend: Key to LePUS3 and Class-Z Symbols</a></li>
		<li><a href="ref/refman/refman.xml">Reference Manual for LePUS3 &amp; Class-Z </a></li>
		<li><a href="../../spec/gof/classz/Proxy.xml">Proxy in XML</a></li>
		<li><a href="faq.xml">Modelling Design Patterns: Frequently-Asked Questions</a></li>
	</ul>

<table class="chartandschema">
<tr>
	<td>
	<img class="chart" id="Proxy" alt="Proxy in LePUS3" src="../../spec/gof/lepus3/Proxy.gif" /></td>
</tr>
<tr>
	<th>Proxy in LePUS3 (<a href="../legend/legend.xml">legend</a>)</th>
</tr>
<tr>
	<td><doc:include value="../../spec/gof/classz/Proxy.xml" /></td>
</tr>
<tr>
	<th>Proxy in Class-Z (<a href="../legend/legend.xml">legend</a>)</th>
</tr>
</table>
</body>
</html>
