SpiCallerContainer extends AbstractContainer implements SpiTrigger { public synchronized <T extends EventListener> void addListener(Class<T> spiType, Supplier<T> spiListener) { Objects.requireNonNull(spiType, "spiType is null."); Objects.requireNonNull(spiListener, "spiListener is null."); List<Supplier<EventListener>> listenerList = this.spiListener.computeIfAbsent(spiType, k -> { return new ArrayList<>(5); }); listenerList.add((Supplier<EventListener>) spiListener); }  @Override R notifySpi(Class<T> spiType, SpiCaller<T, R> spiCaller, R defaultResult); @Override R chainSpi(Class<T> spiType, SpiCaller<T, R> spiCaller, R defaultResult); @Override boolean hasSpi(Class<? extends EventListener> spiType); @Override boolean hasJudge(Class<? extends SpiJudge> spiJudge); List<Supplier<EventListener>> getEventListenerList(Class<?> spiType); int getListenerTypeSize(); long getListenerSize(); synchronized void addListener(Class<T> spiType, Supplier<T> spiListener); synchronized void bindSpiJudge(Class<T> spiType, Supplier<SpiJudge> spiSpiJudgeSupplier); void forEachListener(Consumer<Map.Entry<Class<?>, EventListener>> action);  }
@Test public void spiTest2() { ArrayList<Object> receive = new ArrayList<>(); SpiCallerContainer spiCallerContainer = new SpiCallerContainer(); spiCallerContainer.addListener(ScopeProvisionListener.class, InstanceProvider.of((scopeName, scopeSupplier) -> { receive.add(scopeSupplier); })); assert receive.size() == 0; Supplier<? extends Scope> mockScope = PowerMockito.mock(Supplier.class); spiCallerContainer.notifySpiWithoutResult(ScopeProvisionListener.class, listener -> { listener.newScope("xxxx", mockScope); }); assert receive.size() == 1; assert receive.get(0) == mockScope; }