<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://rasimsen.com/index.php?action=history&amp;feed=atom&amp;title=Proxy_Design_Pattern</id>
	<title>Proxy Design Pattern - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://rasimsen.com/index.php?action=history&amp;feed=atom&amp;title=Proxy_Design_Pattern"/>
	<link rel="alternate" type="text/html" href="http://rasimsen.com/index.php?title=Proxy_Design_Pattern&amp;action=history"/>
	<updated>2026-04-18T14:37:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>http://rasimsen.com/index.php?title=Proxy_Design_Pattern&amp;diff=662&amp;oldid=prev</id>
		<title>Rasimsen: Created page with &quot;In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.  In proxy pattern, we create object having ori...&quot;</title>
		<link rel="alternate" type="text/html" href="http://rasimsen.com/index.php?title=Proxy_Design_Pattern&amp;diff=662&amp;oldid=prev"/>
		<updated>2018-09-18T21:58:07Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.  In proxy pattern, we create object having ori...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.&lt;br /&gt;
&lt;br /&gt;
In proxy pattern, we create object having original object to interface its functionality to outer world.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
We are going to create an Image interface and concrete classes implementing the Image interface. ProxyImage is a a proxy class to reduce memory footprint of RealImage object loading.&lt;br /&gt;
&lt;br /&gt;
ProxyPatternDemo, our demo class, will use ProxyImage to get an Image object to load and display as it needs.&lt;br /&gt;
&lt;br /&gt;
https://www.tutorialspoint.com/design_pattern/images/proxy_pattern_uml_diagram.jpg&lt;br /&gt;
&lt;br /&gt;
=Step 1=&lt;br /&gt;
Create an interface.&lt;br /&gt;
&lt;br /&gt;
Image.java&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
public interface Image {&lt;br /&gt;
   void display();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Step 2=&lt;br /&gt;
Create concrete classes implementing the same interface.&lt;br /&gt;
&lt;br /&gt;
RealImage.java&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
public class RealImage implements Image {&lt;br /&gt;
&lt;br /&gt;
   private String fileName;&lt;br /&gt;
&lt;br /&gt;
   public RealImage(String fileName){&lt;br /&gt;
      this.fileName = fileName;&lt;br /&gt;
      loadFromDisk(fileName);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   @Override&lt;br /&gt;
   public void display() {&lt;br /&gt;
      System.out.println(&amp;quot;Displaying &amp;quot; + fileName);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   private void loadFromDisk(String fileName){&lt;br /&gt;
      System.out.println(&amp;quot;Loading &amp;quot; + fileName);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
ProxyImage.java&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
public class ProxyImage implements Image{&lt;br /&gt;
&lt;br /&gt;
   private RealImage realImage;&lt;br /&gt;
   private String fileName;&lt;br /&gt;
&lt;br /&gt;
   public ProxyImage(String fileName){&lt;br /&gt;
      this.fileName = fileName;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   @Override&lt;br /&gt;
   public void display() {&lt;br /&gt;
      if(realImage == null){&lt;br /&gt;
         realImage = new RealImage(fileName);&lt;br /&gt;
      }&lt;br /&gt;
      realImage.display();&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Step 3=&lt;br /&gt;
Use the ProxyImage to get object of RealImage class when required.&lt;br /&gt;
&lt;br /&gt;
ProxyPatternDemo.java&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
public class ProxyPatternDemo {&lt;br /&gt;
	&lt;br /&gt;
   public static void main(String[] args) {&lt;br /&gt;
      Image image = new ProxyImage(&amp;quot;test_10mb.jpg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
      //image will be loaded from disk&lt;br /&gt;
      image.display(); &lt;br /&gt;
      System.out.println(&amp;quot;&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
      //image will not be loaded from disk&lt;br /&gt;
      image.display(); 	&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Step 4=&lt;br /&gt;
Verify the output.&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
Loading test_10mb.jpg&lt;br /&gt;
Displaying test_10mb.jpg&lt;br /&gt;
&lt;br /&gt;
Displaying test_10mb.jpg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rasimsen</name></author>
		
	</entry>
</feed>