Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What else can be used in Java as the ServiceLoader alternative?

I'm looking for something like the ServiceLoader, but which does not depend on SPI file, where all the service implementations should be enumerated and then added to the path of some class loader, in order to be found.

Let's say there is an application, that has the interface and some implementations of a service. What framework can be used, that allows you to add a new JAR to the application, which contains some new implementations and they can be automatically added to the class path of all the class loaders inside that application? All the class loaders is very important here, because if this is a NetBeans module application, the NetBeans platform does weird magic and you never know which class loader is used by which thread, with which class path etc... It would be also great, if the application does not need to be restarted to find the new JAR, but that's not an important requirement.

I already heard about OSGi, but this seems too big and I only need 1% of its features.

Thanks for any suggestions!

like image 202
m_pGladiator Avatar asked Jan 21 '23 19:01

m_pGladiator


1 Answers

Simplest solution is to use JSPF.

More "enterprise" one could be to use OSGi ... but in that case, you'll have to take a look at iPOJO, as an example. Sorry, I finally re-read your message. I think that, contrary to what you say, OSGi is exactly scopped for your need, as it precisely allows service loading and dynamic wiring.

And IoC containers may provide, with some extensions, that kind of feature (I think it's at least possible using a Guice extension).

like image 147
Riduidel Avatar answered Jan 24 '23 10:01

Riduidel