本文整理匯總了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);
}