To load calsses in runtime java uses ClassLoader mechanism which is based on next core principles: delegation - by default uses parent-first delegation, - child ClassLoader will be used if parent is not able to find or load class.
I recently needed a simple example of an SPI implementation I could send around as copy and paste template. After some looking around I found some tutorials, but most of them were rather heavy in the implementation and are thereby loosing the point of being a simple extension system within the JDK.
In this article, we are going to talk about Java’s Service Provider Interface (SPI). We will have a short overview of what the SPI is and describe some cases where we can use it. Then we will give an implementation of an SPI for a practical use case.