Adapter & Proxy Pattern
Philip zhong Feb, 2014
Agenda
•
•

•
•
•
•
•
•
•
•

Pattern Taxonomy
What’s Adapter?

Adapter Motivation
When To Use Adapter?
Adaptor Examples
What’s Proxy?
Proxy Motivation
When To Use Proxy?
Proxy Types
Proxy Example
Pattern Taxonomy
 Structural Patterns

Adapters, Bridges, Facades, and Proxies are
variations on a single theme:

They reduce the coupling between two or more classes.
They introduce an abstract class to enable future
extensions.
They encapsulate complex structures.
What’s Adapter
Convert the Interface of a class into
Target
another interface clients expect. Client uses.
Defines the domain-specific interface that
• Adapter
 Also Known As Wrapper
•


Adapts the interface Adaptee to the Target interface.


Adaptee
Defines an existing interface that needs adapting.



Client
Collaborates with objects conforming to the Target interface.
Adapter Poxy Pattern
Adapter Motivation
• Sometimes a toolkit or class library can
not be used because its interface is
incompatible with the interface required by
an application
• We can not change the library interface,
since we may not have its source code
• Even if we did have the source code, we
probably should not change the library for
each domain-specific application
Adapter Example
• Media Player
Client

Uses

VlcPlay er
+ playVlc()
+ playMp4()

MediaPlay er
Implements

Implements

Implements

AudioPlay er
+ play()

Uses

MediaAdapt er
+ play()

Uses
Adv anceMediaPlay er
Implements

Mp4Play er
+ playVlc()
+ playMp4()
Adapter Examples
OracleSt ore

MessageSt at em ent s

Message
Dat abasePersist enceAdapt er

+ long messageId
+ String message
+ Timestamp timestamp
+ String client

I Dat abasePersist ence Implements

Uses
Implements
MessagePersist ence
I MessagePersist ence

Uses

Client

Abst ract Dat abaseSt ore

Uses

Implements

MysqlSt ore
What’s Proxy
• Provide a surrogate or placeholder for
 Proxy

another object to that lets the proxy it.
Maintains a referencecontrol access toaccess
• the real subject. Surrogate
Also Known As
 Subject Interface
Defines the common interface for RealSubject and
proxy so that a Proxy can be used anywhere a
RealSubject is expected.
 RealSubject
Defines the real object that proxy represents.
Proxy Motivation
• There are situations in which a client does
not or can not reference an object directly,
but wants to still interact with the object.
• The proxy object has the same interface as
the target object.
• The proxy holds a reference to the target
object and can forward requests to the target
as required (delegation!).
• In effect, the proxy object has the authority
the act on behalf of the client to interact with
the target object.
Proxy Types
• Virtual Proxy :Allows the creation of a memory intensive object on
•

demand. The object will not be created until it is really needed.
Cache Proxy :Provides temporary storage of the results of expensive
target operations so that multiple clients can share the results.

• Protection (Access) Proxy: Provides different clients with

different levels of access to a target object, we can through
java dynamic proxy API to do.

• Remote Proxy :Provides a reference to an object located in a different
•
•
•
•

address space on the same or different machine. e.g.: RMI & CORBA
Synchronization Proxy :Provides multiple accesses to a target
object.
Copy-On-Write Proxy :Defers copying (cloning) a target object until
required by client actions. Really a form of virtual proxy.
Smart Reference Proxy :Provides additional actions whenever a
target object is referenced such as counting the number of references to the
object.
Firewall Proxy :Protects targets from bad clients (or vice versa).
Virtual Proxy Example
RealI m age

Implements
I m age
Delegates
Uses
Implements
Client

Pr ox y I m age
Cache Proxy Example
Cust om er Dao

Implements
Delegates
I Cust om er Dao
Implements
Cust om er CachedPr ox y

+ Uses

Google Cache
Dynamic Proxy Example
Dynamic Proxy Example
Remote Proxy Example
• Java RMI(Remote Method Invocation)
Synchronization Proxy Example
Table

Implements
I Table

Delegates
Implements
Row Lock TablePr ox y
Q & A

More Related Content

PPTX
Adapter Design Pattern
PDF
SpringPeople Introduction to HTML5 & CSS3
PDF
Scintillating
PPTX
Software Developer's Cartel - Not In The Job Description
PDF
Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya
PPTX
Application Architecture
PDF
Scala.io
DOCX
82159587 case-study-on-corba
Adapter Design Pattern
SpringPeople Introduction to HTML5 & CSS3
Scintillating
Software Developer's Cartel - Not In The Job Description
Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya
Application Architecture
Scala.io
82159587 case-study-on-corba

Viewers also liked (20)

PPTX
Mff715 w1 2_generating_researchideas_fall11
PDF
Our GBU bioepistemological educational project (BEEMP)
PDF
The Implementation of CSR in European Football by Geoff Walters
PPT
SEO再入門
PPTX
Early national literature
DOCX
Guión ingles
PDF
World Renaissance Nov 2011
PDF
REDD+ (Transforming Development for Sustainability)
PPTX
Empowering Marketing
DOCX
PDF
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
PDF
長野市のふるさと納税、小泉提案でようやくここまで来た!!
PDF
Pec do Teto de Gastos - o que é?
PPT
PPTX
FUM Belize Friends School
PPTX
Post new korean cinema
PPT
Продукция ТРАДО для вашего здоровья
PPSX
Bio-vision_Kerala quiz 2016
PDF
Ports For Future Offshore Wind-Event Brochure
PDF
Perfil losa deportiva
Mff715 w1 2_generating_researchideas_fall11
Our GBU bioepistemological educational project (BEEMP)
The Implementation of CSR in European Football by Geoff Walters
SEO再入門
Early national literature
Guión ingles
World Renaissance Nov 2011
REDD+ (Transforming Development for Sustainability)
Empowering Marketing
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
長野市のふるさと納税、小泉提案でようやくここまで来た!!
Pec do Teto de Gastos - o que é?
FUM Belize Friends School
Post new korean cinema
Продукция ТРАДО для вашего здоровья
Bio-vision_Kerala quiz 2016
Ports For Future Offshore Wind-Event Brochure
Perfil losa deportiva
Ad

Similar to Adapter Poxy Pattern (20)

PPT
Proxy pattern
PPSX
Proxy design pattern
PPTX
Proxy Design Patterns
PPTX
Proxy Design Pattern
PDF
Gang of four Proxy Design Pattern
PDF
Proxy deep-dive java-one_20151027_001
PPTX
Proxy & adapter pattern
PDF
Proxy Deep Dive Voxxed Belgrad 2015
PDF
Proxy Deep Dive JUG Saxony Day 2015-10-02
PPTX
Introduction-to-Design-Patternsssss.pptx
PDF
Proxy design pattern (Class Ambassador)
PDF
Beyond MVC: from Model to Domain
PDF
Proxy OOP Pattern in PHP
PPTX
PDF
005281271.pdf
PPTX
Remote Method Invocation
PDF
corbaintroductionandexample-140703005744-phpapp02.pdf
PPT
Corba introduction and simple example
PPTX
Factory method, strategy pattern & chain of responsibilities
PPTX
Reducing External Risk
Proxy pattern
Proxy design pattern
Proxy Design Patterns
Proxy Design Pattern
Gang of four Proxy Design Pattern
Proxy deep-dive java-one_20151027_001
Proxy & adapter pattern
Proxy Deep Dive Voxxed Belgrad 2015
Proxy Deep Dive JUG Saxony Day 2015-10-02
Introduction-to-Design-Patternsssss.pptx
Proxy design pattern (Class Ambassador)
Beyond MVC: from Model to Domain
Proxy OOP Pattern in PHP
005281271.pdf
Remote Method Invocation
corbaintroductionandexample-140703005744-phpapp02.pdf
Corba introduction and simple example
Factory method, strategy pattern & chain of responsibilities
Reducing External Risk
Ad

More from Philip Zhong (14)

PPTX
Cisco Webex Distributed Framework and Data Store Design
PPTX
How to Implement Distributed Data Store
PPT
MongoDB Knowledge Shareing
PPTX
How to estimate_oracle_cost
PDF
Mongo db program_installation_guide
PDF
Mongo db sharding_cluster_installation_guide
PDF
Vitess percona 2012
PDF
Distributed_Database_System
PPTX
Mysql performance tuning
PPTX
Mysql5.1 character set testing
PPTX
How to write_language_compiler
PPTX
Compare mysql5.1.50 mysql5.5.8
PPTX
Mysql handle socket
PPTX
Mysql architecture&parameters
Cisco Webex Distributed Framework and Data Store Design
How to Implement Distributed Data Store
MongoDB Knowledge Shareing
How to estimate_oracle_cost
Mongo db program_installation_guide
Mongo db sharding_cluster_installation_guide
Vitess percona 2012
Distributed_Database_System
Mysql performance tuning
Mysql5.1 character set testing
How to write_language_compiler
Compare mysql5.1.50 mysql5.5.8
Mysql handle socket
Mysql architecture&parameters

Recently uploaded (20)

PPTX
Chapter 5: Probability Theory and Statistics
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
Modernising the Digital Integration Hub
PDF
STKI Israel Market Study 2025 version august
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
August Patch Tuesday
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
CloudStack 4.21: First Look Webinar slides
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Chapter 5: Probability Theory and Statistics
O2C Customer Invoices to Receipt V15A.pptx
Hybrid model detection and classification of lung cancer
DP Operators-handbook-extract for the Mautical Institute
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Modernising the Digital Integration Hub
STKI Israel Market Study 2025 version august
A review of recent deep learning applications in wood surface defect identifi...
Final SEM Unit 1 for mit wpu at pune .pptx
Tartificialntelligence_presentation.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Benefits of Physical activity for teenagers.pptx
sustainability-14-14877-v2.pddhzftheheeeee
Getting started with AI Agents and Multi-Agent Systems
August Patch Tuesday
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
CloudStack 4.21: First Look Webinar slides
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
NewMind AI Weekly Chronicles – August ’25 Week III
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf

Adapter Poxy Pattern

  • 1. Adapter & Proxy Pattern Philip zhong Feb, 2014
  • 2. Agenda • • • • • • • • • • Pattern Taxonomy What’s Adapter? Adapter Motivation When To Use Adapter? Adaptor Examples What’s Proxy? Proxy Motivation When To Use Proxy? Proxy Types Proxy Example
  • 3. Pattern Taxonomy  Structural Patterns Adapters, Bridges, Facades, and Proxies are variations on a single theme: They reduce the coupling between two or more classes. They introduce an abstract class to enable future extensions. They encapsulate complex structures.
  • 4. What’s Adapter Convert the Interface of a class into Target another interface clients expect. Client uses. Defines the domain-specific interface that • Adapter  Also Known As Wrapper •  Adapts the interface Adaptee to the Target interface.  Adaptee Defines an existing interface that needs adapting.  Client Collaborates with objects conforming to the Target interface.
  • 6. Adapter Motivation • Sometimes a toolkit or class library can not be used because its interface is incompatible with the interface required by an application • We can not change the library interface, since we may not have its source code • Even if we did have the source code, we probably should not change the library for each domain-specific application
  • 7. Adapter Example • Media Player Client Uses VlcPlay er + playVlc() + playMp4() MediaPlay er Implements Implements Implements AudioPlay er + play() Uses MediaAdapt er + play() Uses Adv anceMediaPlay er Implements Mp4Play er + playVlc() + playMp4()
  • 8. Adapter Examples OracleSt ore MessageSt at em ent s Message Dat abasePersist enceAdapt er + long messageId + String message + Timestamp timestamp + String client I Dat abasePersist ence Implements Uses Implements MessagePersist ence I MessagePersist ence Uses Client Abst ract Dat abaseSt ore Uses Implements MysqlSt ore
  • 9. What’s Proxy • Provide a surrogate or placeholder for  Proxy another object to that lets the proxy it. Maintains a referencecontrol access toaccess • the real subject. Surrogate Also Known As  Subject Interface Defines the common interface for RealSubject and proxy so that a Proxy can be used anywhere a RealSubject is expected.  RealSubject Defines the real object that proxy represents.
  • 10. Proxy Motivation • There are situations in which a client does not or can not reference an object directly, but wants to still interact with the object. • The proxy object has the same interface as the target object. • The proxy holds a reference to the target object and can forward requests to the target as required (delegation!). • In effect, the proxy object has the authority the act on behalf of the client to interact with the target object.
  • 11. Proxy Types • Virtual Proxy :Allows the creation of a memory intensive object on • demand. The object will not be created until it is really needed. Cache Proxy :Provides temporary storage of the results of expensive target operations so that multiple clients can share the results. • Protection (Access) Proxy: Provides different clients with different levels of access to a target object, we can through java dynamic proxy API to do. • Remote Proxy :Provides a reference to an object located in a different • • • • address space on the same or different machine. e.g.: RMI & CORBA Synchronization Proxy :Provides multiple accesses to a target object. Copy-On-Write Proxy :Defers copying (cloning) a target object until required by client actions. Really a form of virtual proxy. Smart Reference Proxy :Provides additional actions whenever a target object is referenced such as counting the number of references to the object. Firewall Proxy :Protects targets from bad clients (or vice versa).
  • 12. Virtual Proxy Example RealI m age Implements I m age Delegates Uses Implements Client Pr ox y I m age
  • 13. Cache Proxy Example Cust om er Dao Implements Delegates I Cust om er Dao Implements Cust om er CachedPr ox y + Uses Google Cache
  • 16. Remote Proxy Example • Java RMI(Remote Method Invocation)
  • 17. Synchronization Proxy Example Table Implements I Table Delegates Implements Row Lock TablePr ox y
  • 18. Q & A