![Spring 5 Design Patterns](https://wfqqreader-1252317822.image.myqcloud.com/cover/646/36700646/b_36700646.jpg)
上QQ阅读APP看书,第一时间看更新
Implementation of the adapter design pattern in the Spring Framework
Spring Framework uses the adapter design pattern to implement a lot of functionality across the framework transparently. The following are some listed classes based on the adapter design pattern in the Spring Framework:
- JpaVendorAdapter
- HibernateJpaVendorAdapter
- HandlerInterceptorAdapter
- MessageListenerAdapter
- SpringContextResourceAdapter
- ClassPreProcessorAgentAdapter
- RequestMappingHandlerAdapter
- AnnotationMethodHandlerAdapter
- WebMvcConfigurerAdapter
The UML diagram for the adapter pattern
Let's understand the preceding UML diagram that illustrates the components of the adapter design pattern:
![](https://epubservercos.yuewen.com/5098A3/19470402901614006/epubprivate/OEBPS/Images/d434b73f-a719-4594-a789-0f07fdfa5ccb.jpg?sign=1738869020-DpF2GGp0Gm6hkwRhb0NgNByYwwYy8udj-0-249e32a33e1b6e7663227b4672ecb494)
- The Target Interface: This is the desired interface class that will be used by the clients
- The Adapter class: This class is a wrapper class that implements the desired target interface and modifies the specific request available from the Adaptee class
- The Adaptee class: This is the class that is used by the Adapter class to reuse the existing functionalities and modify them for desired use
- Client: This class will interact with the Adapter class
Let's look at the following sample implementation of the adapter design pattern.