本文整理汇总了Java中java.util.ServiceLoader.reload方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceLoader.reload方法的具体用法?Java ServiceLoader.reload怎么用?Java ServiceLoader.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ServiceLoader
的用法示例。
在下文中一共展示了ServiceLoader.reload方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import java.util.ServiceLoader; //导入方法依赖的package包/类
@Override
public void stop() {
for ( ServiceLoader serviceLoader : serviceLoaders.values() ) {
serviceLoader.reload(); // clear service loader providers
}
serviceLoaders.clear();
if ( aggregatedClassLoader != null ) {
aggregatedClassLoader.destroy();
aggregatedClassLoader = null;
}
}
示例2: testReload
import java.util.ServiceLoader; //导入方法依赖的package包/类
public void testReload() {
ServiceLoader<ScriptEngineFactory> sl = load(ScriptEngineFactory.class);
List<String> names1 = sl.stream()
.map(Provider::get)
.map(ScriptEngineFactory::getEngineName)
.collect(Collectors.toList());
assertFalse(names1.isEmpty());
sl.reload();
List<String> names2 = sl.stream()
.map(Provider::get)
.map(ScriptEngineFactory::getEngineName)
.collect(Collectors.toList());
assertEquals(names1, names2);
}
示例3: testIteratorHasNext
import java.util.ServiceLoader; //导入方法依赖的package包/类
@Test(expectedExceptions = { ConcurrentModificationException.class })
public void testIteratorHasNext() {
ServiceLoader<ScriptEngineFactory> sl = load(ScriptEngineFactory.class);
Iterator<ScriptEngineFactory> iterator = sl.iterator();
sl.reload();
iterator.hasNext();
}
示例4: testIteratorNext
import java.util.ServiceLoader; //导入方法依赖的package包/类
@Test(expectedExceptions = { ConcurrentModificationException.class })
public void testIteratorNext() {
ServiceLoader<ScriptEngineFactory> sl = load(ScriptEngineFactory.class);
Iterator<ScriptEngineFactory> iterator = sl.iterator();
assertTrue(iterator.hasNext());
sl.reload();
iterator.next();
}
示例5: testStreamFindAny
import java.util.ServiceLoader; //导入方法依赖的package包/类
@Test(expectedExceptions = { ConcurrentModificationException.class })
public void testStreamFindAny() {
ServiceLoader<ScriptEngineFactory> sl = load(ScriptEngineFactory.class);
Stream<Provider<ScriptEngineFactory>> stream = sl.stream();
sl.reload();
stream.findAny();
}
示例6: testSpliteratorTryAdvance
import java.util.ServiceLoader; //导入方法依赖的package包/类
@Test(expectedExceptions = { ConcurrentModificationException.class })
public void testSpliteratorTryAdvance() {
ServiceLoader<ScriptEngineFactory> sl = load(ScriptEngineFactory.class);
Stream<Provider<ScriptEngineFactory>> stream = sl.stream();
Spliterator<Provider<ScriptEngineFactory>> spliterator = stream.spliterator();
sl.reload();
spliterator.tryAdvance(System.out::println);
}