本文整理汇总了Java中org.teavm.vm.spi.TeaVMPlugin类的典型用法代码示例。如果您正苦于以下问题:Java TeaVMPlugin类的具体用法?Java TeaVMPlugin怎么用?Java TeaVMPlugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TeaVMPlugin类属于org.teavm.vm.spi包,在下文中一共展示了TeaVMPlugin类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.teavm.vm.spi.TeaVMPlugin; //导入依赖的package包/类
public static List<TeaVMPlugin> load(ClassLoader classLoader) {
if (isBootstrap()) {
return TeaVMBootstrapPluginLoader.loadPlugins(false);
} else {
List<TeaVMPlugin> plugins = new ArrayList<>();
TeaVMPluginReader.load(classLoader, className -> plugins.add(instantiate(classLoader, className)));
return plugins;
}
}
示例2: instantiate
import org.teavm.vm.spi.TeaVMPlugin; //导入依赖的package包/类
private static TeaVMPlugin instantiate(ClassLoader classLoader, String className) {
try {
return (TeaVMPlugin) Class.forName(className, true, classLoader).newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new IllegalStateException("Can't instantiate plugin " + className, e);
}
}
示例3: loadPlugins
import org.teavm.vm.spi.TeaVMPlugin; //导入依赖的package包/类
private static void loadPlugins(Value<Boolean> ignore) {
Value<List<TeaVMPlugin>> plugins = emit(() -> new ArrayList<>());
List<String> pluginClassNames = new ArrayList<>();
TeaVMPluginReader.load(Metaprogramming.getClassLoader(), pluginClassNames::add);
for (String pluginClassName : pluginClassNames) {
ReflectClass<?> cls = findClass(pluginClassName);
ReflectMethod constructor = cls.getMethod("<init>");
emit(() -> plugins.get().add((TeaVMPlugin) constructor.construct()));
}
exit(() -> plugins.get());
}
示例4: installPlugins
import org.teavm.vm.spi.TeaVMPlugin; //导入依赖的package包/类
/**
* <p>Finds and install all plugins in the current class path. The standard {@link ServiceLoader}
* approach is used to find plugins. So this method scans all
* <code>META-INF/services/org.teavm.vm.spi.TeaVMPlugin</code> resources and
* obtains all implementation classes that are enumerated there.</p>
*/
public void installPlugins() {
for (TeaVMPlugin plugin : TeaVMPluginLoader.load(classLoader)) {
plugin.install(this);
}
}