Sunday, December 22, 2013

proxy pattern

http://ramj2ee.blogspot.in/2013/11/proxy-design-pattern.html
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. Protection proxies are useful when objects should have different access rights.
A smart reference is a replacement for a bare pointer that performs additional actions when an object is accessed.
Provide a surrogate or placeholder for another object to control access to it. Proxy means ‘in place of’ or  ‘Representing’ or ‘in place of’ or ‘on behalf of’ There are four common situations in which the Proxy pattern is applicable.
  1. A virtual proxy is a placeholder for "expensive to create" objects. The real object is only created when a client first requests/accesses the object.eg google map
  2. A remote proxy provides a local representative for an object that resides in a different address space. This is what the "stub" code in RPC and CORBA provides.eg webservice call
  3. A protective proxy controls access to a sensitive master object. The "surrogate" object checks that the caller has the access permissions required prior to forwarding the request.
  4. A smart proxy interposes additional actions when an object is accessed. Typical uses include:  
    • Counting the number of references to the real object so that it can be freed automatically when there are no more references (aka smart pointer)
    • Loading a persistent object into memory when it's first referenced
    • Checking that the real object is locked before it is accessed to ensure that no other object can change it

No comments:

Post a Comment