Proxy Design Pattern in Java and Spring

Implementation of the Design Patterns in Java and Spring Framework

Ali Zeynalli
2 min readJul 9, 2021
Photo by Steve Johnson on Unsplash

Using proxy behavior is fundamental to information technologies. Appliance of proxies can be for instance found in network connections in form of network proxies. The usage of the Proxy Design Pattern is widespread not only in traditional java based software systems, but also in spring this behavior is one of the basics.

The main idea of the Proxy Design Pattern is delegating one object, which is called proxy in this context, to control the access to another object, which is subject. The reasons to use this design pattern is on the one hand, to hide the complexity of subject object, on the other hand to have full control over that subject with extra security layer.

The following UML diagram represents java implementation of the Proxy Design Pattern. Basically we have got firstly Impl class of an IncomeService secondly ProxyImpl class that controls the usage of the Impl class. Here you can take a look at a similar example in my git account.

UML Diagram of the Proxy Design Pattern

The Proxy behavior in spring is pretty popular technique being used in transactions…

--

--

Ali Zeynalli

IT-Architect | BMW Group | M.Sc. Technical University of Berlin