hfhbd
11/22/2022, 10:20 AMCaused by: java.util.ServiceConfigurationError: Factory: Impl Unable to get public no-arg constructor
and NoSuchMethodException: Impl.<init>()
Joffrey
11/22/2022, 10:22 AMServiceLoader
to find and return an implementation that is a singleton object
? Not sure this can be done. But why not just make that object a regular class
if the goal is to use a Service Loader anyway?Joffrey
11/22/2022, 10:23 AMobject
for this implementationhfhbd
11/22/2022, 10:24 AMphldavies
11/22/2022, 10:26 AMobject
has a defined interface, you could have the serviceloader load an implementation of the interface that delegates to the object (not ideal but workable)Joffrey
11/22/2022, 10:27 AMJoffrey
11/22/2022, 10:27 AMphldavies
11/22/2022, 10:29 AMJoffrey
11/22/2022, 10:31 AMfactory.getImpl()
that returns the object. No extra wrapper.
I guess it depends on how much the object's interface is used compared to how much the service loader is used. But I would expect the service loader to be rarely used, probably once per application runhfhbd
11/22/2022, 10:34 AMPaul Griffith
11/22/2022, 4:37 PMclass LogViewerProxy : MultiClipboardTool by LogViewer
where LogViewer is my object, and MultiClipboardTool is my interface getting service loadedPaul Griffith
11/22/2022, 4:38 PM