Time |
S |
Nick |
Message |
17:15 |
|
pdurbin |
aditsu semiosis: what do you think of ServiceLoader? https://docs.oracle.com/javase/tutorial/ext/basics/spi.html ... my use case is basically http://stackoverflow.com/questions/16102010/dynamically-loading-plugin-jars-using-serviceloader |
17:18 |
|
aditsu |
pdurbin: I've used it; the concept is great but I don't like the implementation very much (but it works) |
17:19 |
|
semiosis |
i wrote a filesystem provider plugin by implementing the NIO.2 SPI. was a big project but it actually worked. lets you connect to glusterfs using native java filesystem API... github.com/semiosis/glusterfs-java-filesystem |
17:21 |
|
pdurbin |
aditsu: ok. thanks |
17:22 |
|
pdurbin |
semiosis: well, I'm not interested in writing the plugin itself but rather the plugin system that allows others to write plugins by dropping jars into place: https://github.com/IISH/dataverse/commit/a1c7615#commitcomment-17238686 |
17:25 |
|
aditsu |
you just write an interface and then use ServiceLoader to load implementations |
17:27 |
|
aditsu |
people implement it and add a reference under META-INF |
17:29 |
|
pdurbin |
aditsu: cool. sounds like what I want. lighter than OSGi and I don't have to wait for Jigsaw (Java 9) |
17:30 |
|
aditsu |
btw, that SO question seems to be more about adding jars at runtime (which I haven't tried, and is not done by ServiceLoader) |
17:31 |
|
aditsu |
ServiceLoader just loads whatever it can find in the current classpath |
17:31 |
|
semiosis |
i get the impression that loading jars at runtime is hard. both eclipse (last time i used it) and intellij require a restart of the app to add/remove plugins |
17:33 |
|
aditsu |
eclipse doesn't usually require it, but strongly encourages you to restart anyway |
17:33 |
|
semiosis |
i would also look for other libs to handle plugins that may work better for you than the core javase api |
17:34 |
|
semiosis |
maybe this one? https://github.com/decebals/pf4j |
17:34 |
|
pdurbin |
wait, I though you *could* load jars at runtime with ServiceLoader |
17:35 |
|
pdurbin |
semiosis: interesting. thanks |
17:35 |
|
pdurbin |
"With PF4J you can easily transform a monolithic java application in a modular application." |
17:35 |
|
aditsu |
nope, the typical usage is you add a jar with an implementation and start (or restart) the application |
17:35 |
|
pdurbin |
aditsu: oh, well that's fine. people can stop the app for a bit |
17:37 |
|
pdurbin |
it's doesn't need to be *that* dynamic :) |
17:37 |
|
aditsu |
you can also do it at runtime, as shown in that question; the 2nd example is cleaner |
17:38 |
|
pdurbin |
cool |
17:39 |
|
aditsu |
(just ServiceLoader doesn't do it for you) |
17:40 |
|
pdurbin |
right |
17:41 |
|
aditsu |
it still helps a bit - it lets you give it a custom ClassLoader |
19:57 |
|
|
sivoais joined #sourcefu |