serviceloader

Keep 'META-INF/services'-files in apk

房东的猫 提交于 2019-11-27 04:35:17
问题 I have a custom charset which is already working on JavaSE. The class of my CharsetProvider is specified in a file java.nio.charset.spi.CharsetProvider which is located in META-INF/services and everything get's loaded normally and works as expected. However now I'm using the lib on android as well, but the charset isn't loaded in Android-App. How can I integrate my charset, so that it can be used like expected in an Android-App? Charset.forName("MyCS"); At the moment I'm doing a workaround

Using serviceloader on android

 ̄綄美尐妖づ 提交于 2019-11-27 04:33:16
I am very new to java and android development and to learn I am trying to start with an application to gather statistics and information like munin does. I am trying to be able to load "plugins" in my application. These plugins are already in the application but I don't want to have to invoke them all separately, but be able to iterate over them. I was trying to use serviceloader but could never get the META-INF/services into my apk. So I am wondering if it is possible to use serviceloader on android Thanks EDIT: I am asking about java.util.ServiceLoader, I think it should, but I can't figure

Java ServiceLoader with multiple Classloaders

夙愿已清 提交于 2019-11-26 17:55:21
问题 What are the best practices for using ServiceLoader in an Environment with multiple ClassLoaders? The documentation recommends to create and save a single service instance at initialization: private static ServiceLoader<CodecSet> codecSetLoader = ServiceLoader.load(CodecSet.class); This would initialize the ServiceLoader using the current context classloader. Now suppose this snippet is contained in a class loaded using a shared classloader in a web container and multiple web applications

Dynamically loading plugin jars using ServiceLoader

大城市里の小女人 提交于 2019-11-26 15:16:43
问题 I'm trying to create a plugin system for my application, and I want to start with something simple. Every plugin should be packed in a .jar file and implement the SimplePlugin interface: package plugintest; public interface SimplePlugin { public String getName(); } Now I've created an implementation of SimplePlugin , packed in a .jar and put it in the plugin/ subdirectory of the main application: package plugintest; public class PluginTest implements SimplePlugin { public String getName() {