@Test public void individualBeanWithNullReturningSupplier() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBean("a", BeanA.class, () -> null); context.registerBean("b", BeanB.class, BeanB::new); context.registerBean("c", BeanC.class, BeanC::new); context.refresh(); assertTrue(ObjectUtils.containsElement(context.getBeanNamesForType(BeanA.class), "a")); assertTrue(ObjectUtils.containsElement(context.getBeanNamesForType(BeanB.class), "b")); assertTrue(ObjectUtils.containsElement(context.getBeanNamesForType(BeanC.class), "c")); assertTrue(context.getBeansOfType(BeanA.class).isEmpty()); assertSame(context.getBean(BeanB.class), context.getBeansOfType(BeanB.class).values().iterator().next()); assertSame(context.getBean(BeanC.class), context.getBeansOfType(BeanC.class).values().iterator().next()); }
@Test public void testProxyingDecoratorNoInstance() throws Exception { String[] beanNames = this.beanFactory.getBeanNamesForType(ApplicationListener.class); assertTrue(Arrays.asList(beanNames).contains("debuggingTestBeanNoInstance")); assertEquals(ApplicationListener.class, this.beanFactory.getType("debuggingTestBeanNoInstance")); try { this.beanFactory.getBean("debuggingTestBeanNoInstance"); fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { assertTrue(ex.getRootCause() instanceof BeanInstantiationException); } }
@Override public String[] getBeanNamesForType(@SuppressWarnings("rawtypes") Class type, boolean includeNonSingletons, boolean allowEagerInit) { return m_moduleContext.getBeanNamesForType(type, includeNonSingletons, allowEagerInit); }
@Override public String[] getBeanNamesForType(@SuppressWarnings("rawtypes") Class type, boolean includeNonSingletons, boolean allowEagerInit) { return m_moduleContext.getBeanNamesForType(type, includeNonSingletons, allowEagerInit); }
@Override public boolean hasRegisteredType(Class<?> type) { return context.getBeanNamesForType(type).length > 0; }
@Override public String[] getBeanNamesForType(@SuppressWarnings("rawtypes") Class type) { return m_moduleContext.getBeanNamesForType(type); }
@Override public boolean canFind(Class<?> type) { return context.getBeanNamesForType(type).length > 0; }
@Override public String[] getBeanNamesForType(@SuppressWarnings("rawtypes") Class type) { return m_moduleContext.getBeanNamesForType(type); }
@Override public boolean canFind(Class<?> type) { return context.getBeanNamesForType(type).length > 0; }
/** * Gets an <code>Iterator</code> over the roles that have been loaded. * * @return (<code>String</code>s) The roles. */ public final Iterator<String> loadedModuleRoles() { String [] names = m_moduleContext.getBeanNamesForType(Module.class,false,true); return Arrays.asList(names).iterator(); }
/** * Gets an <code>Iterator</code> over the roles that have been loaded. * * @return (<code>String</code>s) The roles. */ public final Iterator<String> loadedModuleRoles() { String [] names = m_moduleContext.getBeanNamesForType(Module.class,false,true); return Arrays.asList(names).iterator(); }
public Iterator<String> datastoreConfigIds() { String [] dsNames = m_moduleContext.getBeanNamesForType(DatastoreConfiguration.class,false,true); return Arrays.asList(dsNames).iterator(); }
public Iterator<String> datastoreConfigIds() { String [] dsNames = m_moduleContext.getBeanNamesForType(DatastoreConfiguration.class,false,true); return Arrays.asList(dsNames).iterator(); }
/** * Returns all beans of type {@link SpringCamelContext} that are present in the Spring bean factory. * @return Unmodifiable list of {@link SpringCamelContext} instances */ public List<SpringCamelContext> getSpringCamelContexts() { List<SpringCamelContext> beans = new ArrayList<>(); for (String name : applicationContext.getBeanNamesForType(SpringCamelContext.class)) { beans.add(applicationContext.getBean(name, SpringCamelContext.class)); } return Collections.unmodifiableList(beans); }
/** * Returns all beans of type {@link SpringCamelContext} that are present in the Spring bean factory. * @return Unmodifiable list of {@link SpringCamelContext} instances */ public List<SpringCamelContext> getSpringCamelContexts() { List<SpringCamelContext> beans = new ArrayList<>(); for (String name : applicationContext.getBeanNamesForType(SpringCamelContext.class)) { beans.add(applicationContext.getBean(name, SpringCamelContext.class)); } return Collections.unmodifiableList(beans); }
ctx.refresh(); String[] secureDeliveryModuleBeanNames = ctx.getBeanNamesForType( SecureDeliveryModuleIfc.class ); if ( secureDeliveryModuleBeanNames.length == 0 ) log.warn( "Secure delivery plugin doesn't define any beans of type SecureDeliveryModuleIfc" );
ctx.refresh(); String[] secureDeliveryModuleBeanNames = ctx.getBeanNamesForType( SecureDeliveryModuleIfc.class ); if ( secureDeliveryModuleBeanNames.length == 0 ) log.warn( "Secure delivery plugin doesn't define any beans of type SecureDeliveryModuleIfc" );