Looking into java service provider interface (SPI). Learning by example.

  Рет қаралды 7,494

Daniel Persson (Kalaspuffar)

Daniel Persson (Kalaspuffar)

Күн бұрын

I took a look at the service provider interface in java. This is a needed interface to build simple services using easy building blocks to extend and improve programs or libraries. We will create one example and also look into some tools that use this interface already.
Repository:
github.com/kal...
Get on the fast track to a career in cybersecurity. In this certificate program, you'll learn in-demand skills, and get AI training from Google experts. Learn at your own pace, no degree or experience required.
imp.i384100.ne...
Join the channel to get access to more perks:
/ @danielpersson
Or visit my blog at:
danielpersson.dev
Outro music: Sanaas Scylla
#java #service #spi

Пікірлер: 17
@roman_mf
@roman_mf 3 ай бұрын
Hello Daniel, thank you for refresher, such a short and sweet video. Are SPIs used primarily for compile-time extensions or runtime extensions? If I recompile a classfile of a plugin and ask ServiceLoader to load it again, will it load the updated classfile, or do I need exert additional effort to unload the previous version from memory?
@DanielPersson
@DanielPersson 2 ай бұрын
Hi Roman To my knowledge, it's more of a runtime extension, and you should be able to switch out functions on the fly. I'm not sure if there are any recommendations to unload the class before loading a new one, but I really hope the garbage collector handles that issue. Currently, I only use it to load classes that extend common functionality and pack them in at compile time; I'm not switching in runtime. I hope this helps. Thank you for watching my videos. Best regards Daniel
@marko-pololo
@marko-pololo Жыл бұрын
Thank you for the video! very interesting! I saw a project with SPI and didn’t even know what it was, now it’s a little clearer! Sorry for my English)
@БажанКозаченко
@БажанКозаченко 3 жыл бұрын
It was a good example. Thank you for teaching java service provider interface.
@hellosagar
@hellosagar 2 жыл бұрын
Thank you so much for the explanation
@SarveshBhatnagar1214
@SarveshBhatnagar1214 Жыл бұрын
Well taught! Thanks....
@yaroslavsoltys4846
@yaroslavsoltys4846 3 жыл бұрын
thank you for the great explanation!
@Aragorn.Strider
@Aragorn.Strider 3 жыл бұрын
I hoped to find the Java9 version of this, but this Java6 version is a nice introduction, I learned something new, thanks
@DanielPersson
@DanielPersson 3 жыл бұрын
Hi Aragorn. Thank you for watching my videos. I did not know that the interface had changed in newer versions of java. I need to look into this; perhaps there is a better solution. The more you know :) Best regards Daniel
@olafkliemt1145
@olafkliemt1145 3 жыл бұрын
very nice - thanks !
@GK-rl5du
@GK-rl5du 3 жыл бұрын
Hi Daniel, in the video you have mentioned for the serviceLoader to detect classes we have to mention the fully qualified class names under META-INF directory. I am wondering how does twelwemonkeys implementation is discovered wthout it?
@DanielPersson
@DanielPersson 3 жыл бұрын
Hi Goutham. I explain this after 6:30 in the video. We look into the jar file and see that they have added this file. So the service loader will look in the service files for all jar files and compile a list of optional formats that you could handle. Thank you for watching my videos. I hope this helps. Best regards Daniel
@GK-rl5du
@GK-rl5du 3 жыл бұрын
@@DanielPersson Thanks for the reply.. I thought you were showing the META-INF directory of the actual project and not the library. My bad I was totally confused.
@LeandroCoutinho
@LeandroCoutinho 3 жыл бұрын
Very nice Daniel! So then some jar can hijack interfaces?! Oo If you could do a video about Java Annotation Processor it would be great *-*
@DanielPersson
@DanielPersson 3 жыл бұрын
Hi Leandro Thank you for watching my videos. Yes, if there is an interface available you may extend with other implementations. I'll look into JAP and see if I can create a video about it. Best regards Daniel
Java BlockingQueue
17:48
Jakob Jenkov
Рет қаралды 40 М.
Running With Bigger And Bigger Lunchlys
00:18
MrBeast
Рет қаралды 137 МЛН
Зу-зу Күлпаш 2. Бригадир.
43:03
ASTANATV Movie
Рет қаралды 733 М.
Part 5. Roblox trend☠️
00:13
Kan Andrey
Рет қаралды 3 МЛН
Бенчик, пора купаться! 🛁 #бенчик #арти #симбочка
00:34
Симбочка Пимпочка
Рет қаралды 3 МЛН
Extend your JVM app at runtime with SPI
19:10
Jakub Kozłowski
Рет қаралды 871
How to do logging in  java using log4j api, best practices and tips
17:05
Daniel Persson (Kalaspuffar)
Рет қаралды 26 М.
Programming with ServiceLoader API in Java - Venkat Subramaniam
58:43
Developer Summit
Рет қаралды 7 М.
Егор Зиборов - Java, сделай мне больно!
41:19
JPoint, Joker и JUG ru
Рет қаралды 3,3 М.
Understanding SPI
11:50
Rohde Schwarz
Рет қаралды 94 М.
Using JMeter for performance testing
11:36
Daniel Persson (Kalaspuffar)
Рет қаралды 37 М.
Vectors in Java: The 1 Situation You Might Want To Use Them
16:13
Coding with John
Рет қаралды 82 М.
Modules and Services
44:49
Java
Рет қаралды 10 М.
Spring Tips: Spring Modulith
37:39
SpringDeveloper
Рет қаралды 27 М.
Running With Bigger And Bigger Lunchlys
00:18
MrBeast
Рет қаралды 137 МЛН