ScopeContainer extends AbstractContainer { public boolean isSingleton(BindInfo<?> bindInfo) { Supplier<Scope>[] scopeArrays = collectScope(bindInfo); if (scopeArrays != null && scopeArrays.length > 0) { for (Supplier<Scope> scope : scopeArrays) { if (scope.get() == singletonScope) { return true; } } } return false; } ScopeContainer(SpiCallerContainer spiContainer); Supplier<T> registerAlias(String scopeName, String aliasName); Supplier<T> registerScope(String scopeName, Scope scopeInstance); Supplier<T> registerScopeProvider(String scopeName, Supplier<T> scopeProvider); Supplier<Scope> findScope(String scopeName); Supplier<Scope>[] collectScope(BindInfo<?> bindInfo); Supplier<Scope>[] collectScope(Class<?> targetType); boolean isSingleton(BindInfo<?> bindInfo); boolean isSingleton(Class<?> targetType);  }
@Test public void scopTest8() { SpiCallerContainer spiCallerContainer = new SpiCallerContainer(); ScopeContainer scopeContainer = new ScopeContainer(spiCallerContainer); scopeContainer.init(); DefaultBindInfoProviderAdapter<SampleFace> adapter1 = new DefaultBindInfoProviderAdapter<>(); adapter1.setBindID("1234"); adapter1.setBindType(SampleFace.class); adapter1.setSourceType(SingletonSampleBean.class); assert scopeContainer.isSingleton(adapter1); DefaultBindInfoProviderAdapter<SampleBean> adapter2 = new DefaultBindInfoProviderAdapter<>(); adapter2.setBindID("1234"); adapter2.setBindType(SampleBean.class); assert !scopeContainer.isSingleton(adapter2); }
@Test public void scopTest9() { SpiCallerContainer spiCallerContainer = new SpiCallerContainer(); ScopeContainer scopeContainer = new ScopeContainer(spiCallerContainer); scopeContainer.init(); DefaultBindInfoProviderAdapter<SingletonSampleBean> adapter = new DefaultBindInfoProviderAdapter<>(); adapter.setBindID("1234"); adapter.setBindType(SingletonSampleBean.class); assert scopeContainer.isSingleton(adapter); assert !scopeContainer.isSingleton(PrototypePublicCallDestroyBean.class); assert scopeContainer.isSingleton(SingletonPublicCallDestroyBean.class); }