{"id":44698,"date":"2015-09-30T06:26:41","date_gmt":"2015-09-30T03:26:41","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=44698"},"modified":"2023-12-07T11:14:34","modified_gmt":"2023-12-07T09:14:34","slug":"proxy-design-pattern","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html","title":{"rendered":"Proxy Design Pattern Example"},"content":{"rendered":"<p><em>This article is part of our Academy Course titled <a href=\"http:\/\/www.javacodegeeks.com\/2015\/09\/java-design-patterns\/\">Java Design Patterns<\/a>.<\/em><\/p>\n<p>In this course you will delve into a vast number of Design Patterns and see how those are implemented and utilized in Java. You will understand the reasons why patterns are so important and learn when and how to apply each one of them. Check it out <a href=\"http:\/\/www.javacodegeeks.com\/2015\/09\/java-design-patterns\/\">here<\/a>!<\/p>\n<div class=\"toc\">\n<h4>Table Of Contents<\/h4>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#what_is\">2. What is the Proxy Pattern<\/a><\/dt>\n<dt><a href=\"#remote_proxy\">3. Remote Proxy<\/a><\/dt>\n<dt><a href=\"#virtual_proxy\">4. Virtual Proxy<\/a><\/dt>\n<dt><a href=\"#protection_proxy\">5. Protection Proxy<\/a><\/dt>\n<dt><a href=\"#when_to_use\">6. When to use the Proxy Pattern<\/a><\/dt>\n<dt><a href=\"#other_proxies\">7. Other Proxies<\/a><\/dt>\n<dt><a href=\"#proxy_pattern\">8. Proxy Pattern in JDK<\/a><\/dt>\n<dt><a href=\"#download\">9. Download the Source Code<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2><a name=\"introduction\"><\/a>1. Introduction<\/h2>\n<p>In this lesson we will discuss about a Structural Pattern, the Proxy Pattern. The Proxy Pattern provides a surrogate or placeholder for another object to control access to it.<\/p>\n<p>The Proxy Pattern comes up with many different variations. Some of the important variations are, Remote Proxy, Virtual Proxy, and Protection Proxy. In this lesson, we will know more about these variations and we will implement each of them in Java. But before we do that, let&#8217;s get to know more about the Proxy Pattern in general.<\/p>\n<h2><a name=\"what_is\"><\/a>2. What is the Proxy Pattern<\/h2>\n<p>The Proxy Pattern is used to create a representative object that controls access to another object, which may be remote, expensive to create or in need of being secured.<\/p>\n<p>One reason for controlling access to an object is to defer the full cost of its creation and initialization until we actually need to use it. Another reason could be to act as a local representative for an object that lives in a different JVM. The Proxy can be very useful in controlling the access to the original object, especially when objects should have different access rights.<\/p>\n<p>In the Proxy Pattern, a client does not directly talk to the original object, it delegates it calls to the proxy object which calls the methods of the original object. The important point is that the client does not know about the proxy, the proxy acts as an original object for the client. But there are many variations to this approach which we will see soon.<\/p>\n<p>Let us see the structure of the Proxy Pattern and its important participants.<\/p>\n<p><figure id=\"attachment_6239\" aria-describedby=\"caption-attachment-6239\" style=\"width: 296px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/Proxyclass_diagram_11.jpg\"><img decoding=\"async\" class=\"size-full wp-image-6239\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/Proxyclass_diagram_11.jpg\" alt=\"Figure 1\" width=\"296\" height=\"196\" \/><\/a><figcaption id=\"caption-attachment-6239\" class=\"wp-caption-text\">Figure 1<\/figcaption><\/figure><\/p>\n<ol>\n<li><strong>Proxy<\/strong>:<br \/>\n1a. 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.<br \/>\n1b. Provides an interface identical to Subject&#8217;s so that a proxy can be substituted for the real subject.<br \/>\n1c. Controls access to the real subject and may be responsible for creating and deleting it.<\/li>\n<li><strong>Subject<\/strong>:<br \/>\n2a. Defines the common interface for RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is expected.<\/li>\n<li><strong>RealSubject<\/strong>:<br \/>\n3a. Defines the real object that the proxy represents.<\/li>\n<\/ol>\n<p>There are three main variations to the Proxy Pattern:<\/p>\n<ol>\n<li>A remote proxy provides a local representative for an object in a different address space.<\/li>\n<li>A virtual proxy creates expensive objects on demand.<\/li>\n<li>A protection proxy controls access to the original object. Protection proxies are useful when objects should have different access rights.<\/li>\n<\/ol>\n<p>We will discuss these proxies one by one in next sections.<\/p>\n<h2><a name=\"remote_proxy\"><\/a>3. Remote Proxy<\/h2>\n<p>There is a Pizza Company, which has its outlets at various locations. The owner of the company gets a daily report by the staff members of the company from various outlets. The current application supported by the Pizza Company is a desktop application, not a web application. So, the owner has to ask his employees to generate the report and send it to him. But now the owner wants to generate and check the report by his own, so that he can generate it whenever he wants without anyone\u2019s help. The owner wants you to develop an application for him.<\/p>\n<p>The problem here is that all applications are running at their respective JVMs and the Report Checker application (which we will design soon) should run in the owner\u2019s local system. The object required to generate the report does not exist in the owner\u2019s system JVM and you cannot directly call on the remote object.<\/p>\n<p>Remote Proxy is used to solve this problem. We know that the report is generated by the users, so there is an object which is required to generate the report. All we need is to contact that object which resides in a remote location in order to get the result that we want. The Remote Proxy acts as a local representative of a remote object. A remote object is an object that lives in the heap of different JVM. You call methods to the local object which forward that calls on to the remote object.<\/p>\n<p>Your client object acts like its making remote method calls. But it is calling methods on a heap-local proxy object that handles all the low-level details of network communication.<\/p>\n<p>Java supports the communication between the two objects residing at two different locations (or two different JVMs) using RMI. RMI is Remote Method Invocation which is used to build the client and service helper objects, right down to creating a client helper object with the same methods as the remote service. Using RMI you don\u2019t have to write any of the networking or I\/O code yourself. With your client, you call remote methods just like normal method calls on objects running in the client\u2019s local JVM.<\/p>\n<p>RMI also provides the running infrastructure to make it all work, including a lookup service that the client can use to find and access the remote objects. There is one difference between RMI calls and local method calls. The client helper send the method call across the network, so there is networking and I\/O which involved in the RMI calls.<\/p>\n<p>Now let\u2019s take a look at the code. We have an interface <code>ReportGenerator<\/code> and its concrete implementation <code>ReportGeneratorImpl<\/code> already running at JVMs of different locations. First to create a remote service we need to change the codes.<\/p>\n<p>The <code>ReportGenerator<\/code> interface will now looks like this:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.remoteproxy;\n\nimport java.rmi.Remote;\nimport java.rmi.RemoteException;\n\npublic interface ReportGenerator extends Remote{\n\n\tpublic String generateDailyReport() throws RemoteException;\n\n}\n<\/pre>\n<p>This is a remote interface which defines the methods that a client can call remotely. It\u2019s what the client will use as the class type for your service. Both the Stub and actual service will implement this. The method in the interface returns a <code>String<\/code> object. You can return any object from the method; this object is going to be shipped over the wire from the server back to the client, so it must be <code>Serializable<\/code>. Please note that all the methods in this interface should throw <code>RemoteException<\/code>.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.remoteproxy;\n\nimport java.rmi.Naming;\nimport java.rmi.RemoteException;\nimport java.rmi.server.UnicastRemoteObject;\nimport java.util.Date;\n\npublic class ReportGeneratorImpl extends UnicastRemoteObject implements ReportGenerator{\n\n\tprivate static final long serialVersionUID = 3107413009881629428L;\n\n\tprotected ReportGeneratorImpl() throws RemoteException {\n\t}\n\n\t@Override\n\tpublic String generateDailyReport() throws RemoteException {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"********************Location X Daily Report********************\");\n\t\tsb.append(\"\\\\n Location ID: 012\");\n\t\tsb.append(\"\\\\n Today's Date: \"+new Date());\n\t\tsb.append(\"\\\\n Total Pizza's Sell: 112\");\n\t\tsb.append(\"\\\\n Total Price: $2534\");\n\t\tsb.append(\"\\\\n Net Profit: $1985\");\n\t\tsb.append(\"\\\\n ***************************************************************\");\n\n\t\treturn sb.toString();\n\t}\n\n\tpublic static void main(String[] args) {\n\n\t\ttry {\n\t\t\tReportGenerator reportGenerator = new ReportGeneratorImpl();\n\t\t\tNaming.rebind(\"PizzaCoRemoteGenerator\", reportGenerator);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n}\n<\/pre>\n<p>The above class is the remote implementation which does the real work. It\u2019s the object that the client wants to call methods on. The class extends <code>UnicastRemoteObject<\/code>, in order to work as a remote service object, your object needs some functionality related to being remote. The simplest way is to extend <code>UnicastRemoteObject<\/code> from the <code>java.rmi.server<\/code> package and let that class do the work for you.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The <code>UnicastRemoteObject<\/code> class constructor throws a <code>RemoteException<\/code>, so you need to write a no-arg constructor that declares a <code>RemoteException<\/code>.<\/p>\n<p>To make the remote service available to the clients you need to register the service with the RMI registry. You do this by instantiating it and putting it into the RMI registry. When you register the implementation object, the RMI system actually puts the stub in the registry, since that\u2019s what a client needs. The <code>Naming.rebind<\/code> method is used to register the object. It has two parameters, first a string to name the service and the other parameter takes object which will be fetched by the clients to use the service.<\/p>\n<p>Now, to create the stub you need to run <strong>rmic<\/strong> on the remote implementation class. The rmic tool comes with the Java software development kid, takes a service implementation and creates a new stub. You should open your command prompt (cmd) and run rmic from the directory where your remote implementation is located.<\/p>\n<p>The next step is to run the rmiregistry, bring up a terminal and start the registry, just type the command <strong>rmiregistry<\/strong>. But be sure you start it from a directory that has access to your classes.<br \/>\n[ulp id=&#8217;7eyRwVlMDyxg6Ptw&#8217;]<br \/>\n&nbsp;<br \/>\nThe final step is to start the service that is, run your concrete implementation of remote class, in this case the class is <code>ReportGeneratorImpl<\/code>.<\/p>\n<p>So far, we have created and run a service. Now, let\u2019s see how the client will use it. The report application for the owner of the pizza company will use this service in order to generate and check the report. We need to provide the interface <code>ReportGenerator<\/code> and the stub to the clients which will use the service. You can simply hand-deliver the stub and any other classes or interfaces required in the service.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.remoteproxy;\n\nimport java.rmi.Naming;\n\npublic class ReportGeneratorClient {\n\n\tpublic static void main(String[] args) {\n\t\tnew ReportGeneratorClient().generateReport();\n\t}\n\n\tpublic void generateReport(){\n\t\ttry {\n\t\t\tReportGenerator reportGenerator = (ReportGenerator)Naming.lookup(\"rmi:\/\/127.0.0.1\/PizzaCoRemoteGenerator\");\n\t\t\tSystem.out.println(reportGenerator.generateDailyReport());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n}\n<\/pre>\n<p>The above program will have as a result the following output:<\/p>\n<pre class=\"brush:bash\">********************Location X Daily Report********************\n Location ID: 012\n Today's Date: Sun Sep 14 00:11:23 IST 2014\n Total Pizza Sell: 112\n Total Sale: $2534\n Net Profit: $1985\n ***************************************************************\n<\/pre>\n<p>The above class does a naming lookup and retrieves the object which is used to generate the daily report. You need to provide the IP of the hostname and the name used to bind the service. The rest of it just looks like a regular old method call.<\/p>\n<p>In conclusion, the Remote Proxy acts as a local representative for an object that lives in a different JVM. A method call on the proxy results in the call being transferred over the wire, invoked remotely, and the result being returned back to the proxy and then to the client.<\/p>\n<h2><a name=\"virtual_proxy\"><\/a>4. Virtual Proxy<\/h2>\n<p>The Virtual Proxy pattern is a memory saving technique that recommends postponing an object creation until it is needed; it is used when creating an object the is expensive in terms of memory usage or processing involved. In a typical application, different objects make up different parts of the functionality. When an application is started, it may not need all of its objects to be available immediately. In such cases, the Virtual Proxy pattern suggests deferring objects creation until it is needed by the application. The object that is created the first time is referenced in the application and the same instance is reused from that point onwards. The advantage of this approach is a faster application start-up time, as it is not required to created and load all of the application objects.<\/p>\n<p>Suppose there is a <code>Company<\/code> object in your application and this object contains a list of employees of the company in a <code>ContactList<\/code> object. There could be thousands of employees in a company. Loading the <code>Company<\/code> object from the database along with the list of all its employees in the <code>ContactList<\/code> object could be very time consuming. In some cases you don\u2019t even require the list of the employees, but you are forced to wait until the company and its list of employees loaded into the memory.<\/p>\n<p>One way to save time and memory is to avoid loading of the employee objects until required, and this is done using the Virtual Proxy. This technique is also known as Lazy Loading where you are fetching the data only when it is required.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.virtualproxy;\n\npublic class Company {\n\n\tprivate String companyName;\n\tprivate String companyAddress;\n\tprivate String companyContactNo;\n\tprivate ContactList contactList ;\n\n\tpublic Company(String companyName,String companyAddress, String companyContactNo,ContactList contactList){\n\t\tthis.companyName = companyName;\n\t\tthis.companyAddress = companyAddress;\n\t\tthis.companyContactNo = companyContactNo;\n\t\tthis.contactList = contactList;\n\n\t\tSystem.out.println(\"Company object created...\");\n\t}\n\n\tpublic String getCompanyName() {\n\t\treturn companyName;\n\t}\n\n\tpublic String getCompanyAddress() {\n\t\treturn companyAddress;\n\t}\n\n\tpublic String getCompanyContactNo() {\n\t\treturn companyContactNo;\n\t}\n\n\tpublic ContactList getContactList(){\n\t\treturn contactList;\n\t}\n\n}\n<\/pre>\n<p>The above <code>Company<\/code> class has a reference to <code>ContactList<\/code> interface whose real object will be load only when requested to call of <code>getContactList()<\/code> method.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.virtualproxy;\n\nimport java.util.List;\n\npublic interface ContactList {\n\n\tpublic List&lt;Employee&gt; getEmployeeList();\n}\n<\/pre>\n<p>The <code>ContactList<\/code> interface only contains one method <code>getEmployeeList()<\/code> which is used to get the employee list of the company.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.virtualproxy;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class ContactListImpl implements ContactList{\n\n\t@Override\n\tpublic List&lt;Employee&gt; getEmployeeList() {\n\t\treturn getEmpList();\n\t}\n\n\tprivate static List&lt;Employee&gt;getEmpList(){\n\t\tList&lt;Employee&gt; empList = new ArrayList&lt;Employee&gt;(5);\n\t\tempList.add(new Employee(\"Employee A\", 2565.55, \"SE\"));\n\t\tempList.add(new Employee(\"Employee B\", 22574, \"Manager\"));\n\t\tempList.add(new Employee(\"Employee C\", 3256.77, \"SSE\"));\n\t\tempList.add(new Employee(\"Employee D\", 4875.54, \"SSE\"));\n\t\tempList.add(new Employee(\"Employee E\", 2847.01, \"SE\"));\n\t\treturn empList;\n\t}\n\n}\n<\/pre>\n<p>The above class will create a real <code>ContactList<\/code> object which will return the list of employees of the company. The object will be loaded on demand, only when required.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.virtualproxy;\n\nimport java.util.List;\n\npublic class ContactListProxyImpl implements ContactList{\n\n\tprivate ContactList contactList;\n\n\t@Override\n\tpublic List&lt;Employee&gt; getEmployeeList() {\n\t\tif(contactList == null){\n\t\t\tSystem.out.println(\"Creating contact list and fetching list of employees...\");\n\t\t\tcontactList = new ContactListImpl();\n\t\t}\n\t\treturn contactList.getEmployeeList();\n\t}\n\n}\n<\/pre>\n<p>The <code>ContactListProxyImpl<\/code> is the proxy class which also implements <code>ContactList<\/code> and holds a reference to the real <code>ContactList<\/code> object. On the implementation of the method <code>getEmployeeList()<\/code> it will check if the <code>contactList<\/code> reference is null, then it will create a real <code>ContactList<\/code> object and then will invoke the <code>getEmployeeList()<\/code> method on it to get the list of the employees.<\/p>\n<p>The Employee class looks like this.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.virtualproxy;\n\npublic class Employee {\n\n\tprivate String employeeName;\n\tprivate double employeeSalary;\n\tprivate String employeeDesignation;\n\n\tpublic Employee(String employeeName,double employeeSalary,String employeeDesignation){\n\t\tthis.employeeName = employeeName;\n\t\tthis.employeeSalary = employeeSalary;\n\t\tthis.employeeDesignation = employeeDesignation;\n\t}\n\n\tpublic String getEmployeeName() {\n\t\treturn employeeName;\n\t}\n\n\tpublic double getEmployeeSalary() {\n\t\treturn employeeSalary;\n\t}\n\n\tpublic String getEmployeeDesignation() {\n\t\treturn employeeDesignation;\n\t}\n\n\tpublic String toString(){\n\t\treturn \"Employee Name: \"+employeeName+\", EmployeeDesignation: \"+employeeDesignation+\", Employee Salary: \"+employeeSalary;\n\t}\n\n}\n\npackage com.javacodegeeks.patterns.proxypattern.virtualproxy;\n\nimport java.util.List;\n\npublic class TestVirtualProxy {\n\n\tpublic static void main(String[] args) {\n\t\tContactList contactList = new ContactListProxyImpl();\n\t\tCompany company = new Company(\"ABC Company\", \"India\", \"+91-011-28458965\", contactList);\n\n\t\tSystem.out.println(\"Company Name: \"+company.getCompanyName());\n\t\tSystem.out.println(\"Company Address: \"+company.getCompanyAddress());\n\t\tSystem.out.println(\"Company Contact No.: \"+company.getCompanyContactNo());\n\n\t\tSystem.out.println(\"Requesting for contact list\");\n\n\t\tcontactList = company.getContactList();\n\n\t\tList&lt;Employee&gt;empList = contactList.getEmployeeList();\n\t\tfor(Employee emp : empList){\n\t\t\tSystem.out.println(emp);\n\t\t}\n\t}\n\n}\n<\/pre>\n<p>The above program will have as a result the following output:<\/p>\n<pre class=\"brush:bash\">Company object created...\nCompany Name: ABC Company\nCompany Address: India\nCompany Contact No.: +91-011-28458965\nRequesting for contact list\nCreating contact list and fetching list of employees...\nEmployee Name: Employee A, EmployeeDesignation: SE, Employee Salary: 2565.55\nEmployee Name: Employee B, EmployeeDesignation: Manager, Employee Salary: 22574.0\nEmployee Name: Employee C, EmployeeDesignation: SSE, Employee Salary: 3256.77\nEmployee Name: Employee D, EmployeeDesignation: SSE, Employee Salary: 4875.54\nEmployee Name: Employee E, EmployeeDesignation: SE, Employee Salary: 2847.01\n<\/pre>\n<p>As you can see in the output generated by the <code>TestVirtualProxy<\/code>, first we have created a <code>Company<\/code> object with a proxy <code>ContactList<\/code> object. At this time, the <code>Company<\/code> object holds a proxy reference, not the real <code>ContactList<\/code> object\u2019s reference, so there no employee list loaded into the memory. We made some calls on the company object, and then asked for the employee list from the contact list proxy object using the <code>getEmployeeList()<\/code> method. On call of this method, the proxy object creates a real <code>ContactList<\/code> object and provides the list of employees.<\/p>\n<h2><a name=\"protection_proxy\"><\/a>5. Protection Proxy<\/h2>\n<p>In general, objects in an application interact with each other to implement the overall application functionality. Most application object are generally accessible to all other objects in the application. At times, it may be necessary to restrict the accessibility of an object only to a limited set of client objects based on their access rights. When a client object tries to access such an object, the client is given access to the services provided by the object only if the client can furnish proper authentication credentials. In such cases, a separate object can be designated with the responsibility of verifying the access privileges of different client objects when they access the actual object. In other words, every client must successfully authenticate with this designated object to get access to the actual object functionality. Such an object with which a client needs to authenticate to get access to the actual object can be referred as an object authenticator which is implemented using the Protection Proxy.<\/p>\n<p>Returning back to the <code>ReportGenerator<\/code> application that we developed for the pizza company, the owner now requires that only he can generate the daily report. No other employee should be able to do so.<\/p>\n<p>To implement this security feature, we used Protection Proxy which checks if the object which is trying to generate the report is the owner; in this case, the report gets generated, otherwise it is not.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.protectionproxy;\n\npublic interface Staff {\n\n\tpublic boolean isOwner();\n\tpublic void setReportGenerator(ReportGeneratorProxy reportGenerator);\n}\n<\/pre>\n<p>The <code>Staff<\/code> interface is used by the <code>Owner<\/code> and the <code>Employee<\/code> classes and the interface has two methods: <code>isOwner()<\/code> returns a <code>boolean<\/code> to check whether the calling object is the owner or not. The other method is used to set the <code>ReportGeneratorProxy<\/code> which is a protection proxy used to generate the report is <code>isOwner()<\/code> method return true.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.protectionproxy;\n\npublic class Employee implements Staff{\n\n\tprivate ReportGeneratorProxy reportGenerator;\n\n\t@Override\n\tpublic void setReportGenerator(ReportGeneratorProxy reportGenerator){\n\t\tthis.reportGenerator = reportGenerator;\n\t}\n\n\t@Override\n\tpublic boolean isOwner() {\n\t\treturn false;\n\t}\n\n\tpublic String generateDailyReport(){\n\t\ttry {\n\t\t\treturn reportGenerator.generateDailyReport();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn \"\";\n\t}\n\n}\n<\/pre>\n<p>The <code>Employee<\/code> class implements the <code>Staff<\/code> interface, since it\u2019s an employee <code>isOwner()<\/code> method return <code>false<\/code>. The <code>generateDailyReport()<\/code> method ask <code>ReportGenerator<\/code> to generate the daily report.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.protectionproxy;\n\npublic class Owner implements Staff {\n\n\tprivate boolean isOwner=true;\n\tprivate ReportGeneratorProxy reportGenerator;\n\n\t@Override\n\tpublic void setReportGenerator(ReportGeneratorProxy reportGenerator){\n\t\tthis.reportGenerator = reportGenerator;\n\t}\n\n\t@Override\n\tpublic boolean isOwner(){\n\t\treturn isOwner;\n\t}\n\n\tpublic String generateDailyReport(){\n\t\ttry {\n\t\t\treturn reportGenerator.generateDailyReport();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn \"\";\n\t}\n\n}\n<\/pre>\n<p>The <code>Owner<\/code> class looks almost same as the <code>Employee<\/code> class, the only difference is that the <code>isOwner()<\/code> method returns <code>true<\/code>.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.protectionproxy;\n\npublic interface ReportGeneratorProxy {\n\n\tpublic String generateDailyReport();\n}\n<\/pre>\n<p>The <code>ReportGeneratorProxy<\/code> acts as a Protection Proxy which has only one method <code>generateDailyReport()<\/code> that is used to generate the report.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.protectionproxy;\n\nimport java.rmi.Naming;\n\nimport com.javacodegeeks.patterns.proxypattern.remoteproxy.ReportGenerator;\n\npublic class ReportGeneratorProtectionProxy implements ReportGeneratorProxy{\n\n\tReportGenerator reportGenerator;\n\tStaff staff;\n\n\tpublic ReportGeneratorProtectionProxy(Staff staff){\n\t\tthis.staff = staff;\n\t}\n\n\t@Override\n\tpublic String generateDailyReport() {\n\t\tif(staff.isOwner()){\n\t\t\tReportGenerator reportGenerator = null;\n\t\t\ttry {\n\t\t\t\treportGenerator = (ReportGenerator)Naming.lookup(\"rmi:\/\/127.0.0.1\/PizzaCoRemoteGenerator\");\n\t\t\t\treturn reportGenerator.generateDailyReport();\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn \"\";\n\t\t}\n\t\telse{\n\t\t\treturn \"Not Authorized to view report.\";\n\t\t}\n\t}\n}\n<\/pre>\n<p>The above class is the concrete implementation of the <code>ReportGeneratorProxy<\/code> which holds a reference to the <code>ReportGenerator<\/code> interface which is the remote proxy. In the <code>generateDailyReport()<\/code> method, it checks if the staff is referring to the owner, then asks the remote proxy to generate the report, otherwise it returns a string with \u201cNot Authorized to view report\u201d as a message.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.patterns.proxypattern.protectionproxy;\n\npublic class TestProtectionProxy {\n\n\tpublic static void main(String[] args) {\n\n\t\tOwner owner = new Owner();\n\t\tReportGeneratorProxy reportGenerator = new ReportGeneratorProtectionProxy(owner);\n\t\towner.setReportGenerator(reportGenerator);\n\n\t\tEmployee employee = new Employee();\n\t\treportGenerator = new ReportGeneratorProtectionProxy(employee);\n\t\temployee.setReportGenerator(reportGenerator);\n\t\tSystem.out.println(\"For owner:\");\n\t\tSystem.out.println(owner.generateDailyReport());\n\t\tSystem.out.println(\"For employee:\");\n\t\tSystem.out.println(employee.generateDailyReport());\n\n\t}\n\n}\n<\/pre>\n<p>The above program will have as a result the following output:<\/p>\n<pre class=\"brush:bash\">For owner:\n********************Location X Daily Report********************\n Location ID: 012\n Today's Date: Sun Sep 14 13:28:12 IST 2014\n Total Pizza Sell: 112\n Total Sale: $2534\n Net Profit: $1985\n ***************************************************************\nFor employee:\nNot Authorized to view report.\n<\/pre>\n<p>The above output clearly shows that the owner can generate the report, whereas, the employee does not. The Protection Proxy protects the access of generating the report and only allows the authorized objects to generate the report.<\/p>\n<h2><a name=\"when_to_use\"><\/a>6. When to use the Proxy Pattern<\/h2>\n<p>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:<\/p>\n<ol>\n<li>A remote proxy provides a local representative for an object in a different address space.<\/li>\n<li>A virtual proxy creates expensive objects on demand.<\/li>\n<li>A protection proxy controls access to the original object. Protection proxies are useful when objects should have different access rights.<\/li>\n<\/ol>\n<h2><a name=\"other_proxies\"><\/a>7. Other Proxies<\/h2>\n<p>Besides the above discussed three main proxies, there are some other kinds of proxies.<\/p>\n<ol>\n<li><strong>Cache Proxy\/Server Proxy<\/strong>: To provide the functionality required to store the results of most frequently used target operations. The proxy object stores these results in some kind of a repository. When a client object requests the same operation, the proxy returns the operation results from the storage area without actually accessing the target object.<\/li>\n<li><strong>Firewall Proxy<\/strong>: The primary use of a firewall proxy is to protect target objects from bad clients. A firewall proxy can also be used to provide the functionality required to prevent clients from accessing harmful targets.<\/li>\n<li><strong>Synchronization Proxy<\/strong>: To provide the required functionality to allow safe concurrent accesses to a target object by different client objects.<\/li>\n<li><strong>Smart Reference Proxy<\/strong>: To provide the functionality to prevent the accidental disposal\/deletion of the target object when there are clients currently with references to it. To accomplish this, the proxy keeps a count of the number of references to the target object. The proxy deletes the target object if and when there are no references to it.<\/li>\n<li><strong>Counting Proxy<\/strong>: To provide some kind of audit mechanism before executing a method on the target object.<\/li>\n<\/ol>\n<h2><a name=\"proxy_pattern\"><\/a>8. Proxy Pattern in JDK<\/h2>\n<p>The following cases are examples of usage of the Proxy Pattern in the JDK.<\/p>\n<ol>\n<li><code>java.lang.reflect.Proxy<\/code><\/li>\n<li><code>java.rmi.* (whole package)<\/code><\/li>\n<\/ol>\n<h2><a name=\"download\"><\/a>9. Download the Source Code<\/h2>\n<p>This was a lesson on Proxy Pattern. You may download the source code here: <a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/ProxyPattern-Project.zip\"><strong>ProxyPattern-Project.zip<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how those are implemented and utilized in Java. You will understand the reasons why patterns are so important and learn when and how to apply each one of &hellip;<\/p>\n","protected":false},"author":967,"featured_media":148,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[145],"class_list":["post-44698","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-design-patterns"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Proxy Design Pattern Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Proxy Design Pattern Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-09-30T03:26:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-07T09:14:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rohit Joshi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit Joshi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html\"},\"author\":{\"name\":\"Rohit Joshi\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ddd1b95af381c5042c09833e6a108e20\"},\"headline\":\"Proxy Design Pattern Example\",\"datePublished\":\"2015-09-30T03:26:41+00:00\",\"dateModified\":\"2023-12-07T09:14:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html\"},\"wordCount\":2811,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"keywords\":[\"Design Patterns\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html\",\"name\":\"Proxy Design Pattern Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"datePublished\":\"2015-09-30T03:26:41+00:00\",\"dateModified\":\"2023-12-07T09:14:34+00:00\",\"description\":\"This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/09\\\/proxy-design-pattern.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/core-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Proxy Design Pattern Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ddd1b95af381c5042c09833e6a108e20\",\"name\":\"Rohit Joshi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/802a913bbb576309b246c8e839eaec9910390a9e7b8bf684a9706f8bfa3f6012?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/802a913bbb576309b246c8e839eaec9910390a9e7b8bf684a9706f8bfa3f6012?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/802a913bbb576309b246c8e839eaec9910390a9e7b8bf684a9706f8bfa3f6012?s=96&d=mm&r=g\",\"caption\":\"Rohit Joshi\"},\"description\":\"Rohit Joshi is a Senior Software Engineer from India. He is a Sun Certified Java Programmer and has worked on projects related to different domains. His expertise is in Core Java and J2EE technologies, but he also has good experience with front-end technologies like Javascript, JQuery, HTML5, and JQWidgets.\",\"sameAs\":[\"http:\\\/\\\/www.javacodegeeks.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/rohit-joshi\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Proxy Design Pattern Example - Java Code Geeks","description":"This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html","og_locale":"en_US","og_type":"article","og_title":"Proxy Design Pattern Example - Java Code Geeks","og_description":"This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how","og_url":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2015-09-30T03:26:41+00:00","article_modified_time":"2023-12-07T09:14:34+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","type":"image\/jpeg"}],"author":"Rohit Joshi","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Rohit Joshi","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html"},"author":{"name":"Rohit Joshi","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ddd1b95af381c5042c09833e6a108e20"},"headline":"Proxy Design Pattern Example","datePublished":"2015-09-30T03:26:41+00:00","dateModified":"2023-12-07T09:14:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html"},"wordCount":2811,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","keywords":["Design Patterns"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html","url":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html","name":"Proxy Design Pattern Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","datePublished":"2015-09-30T03:26:41+00:00","dateModified":"2023-12-07T09:14:34+00:00","description":"This article is part of our Academy Course titled Java Design Patterns. In this course you will delve into a vast number of Design Patterns and see how","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2015\/09\/proxy-design-pattern.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/core-java"},{"@type":"ListItem","position":4,"name":"Proxy Design Pattern Example"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ddd1b95af381c5042c09833e6a108e20","name":"Rohit Joshi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/802a913bbb576309b246c8e839eaec9910390a9e7b8bf684a9706f8bfa3f6012?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/802a913bbb576309b246c8e839eaec9910390a9e7b8bf684a9706f8bfa3f6012?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/802a913bbb576309b246c8e839eaec9910390a9e7b8bf684a9706f8bfa3f6012?s=96&d=mm&r=g","caption":"Rohit Joshi"},"description":"Rohit Joshi is a Senior Software Engineer from India. He is a Sun Certified Java Programmer and has worked on projects related to different domains. His expertise is in Core Java and J2EE technologies, but he also has good experience with front-end technologies like Javascript, JQuery, HTML5, and JQWidgets.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/rohit-joshi"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/967"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=44698"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44698\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/148"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=44698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=44698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=44698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}