@Test public void shouldProvideCurrentHttpRequest() { ServletRequest httpRequest = container.instanceFor(ServletRequest.class); assertNotNull("can provide request", httpRequest); }
public <T> T instanceFor(Class<T> type) { try { return parentContext.getBean(type); } catch (NoSuchBeanDefinitionException e) { Map<String, T> beans = parentContext.getBeansOfType(type); for (Entry<String, T> def : beans.entrySet()) { BeanDefinition definition = parentContext.getBeanFactory().getBeanDefinition(def.getKey()); if (isPrimary(definition) || hasGreaterRoleThanInfrastructure(definition)) { return def.getValue(); } } throw e; } }
SpringBasedContainer extends AbstractComponentRegistry implements Container { public <T> T instanceFor(Class<T> type) { try { return parentContext.getBean(type); } catch (NoSuchBeanDefinitionException e) { Map<String, T> beans = parentContext.getBeansOfType(type); for (Entry<String, T> def : beans.entrySet()) { BeanDefinition definition = parentContext.getBeanFactory().getBeanDefinition(def.getKey()); if (isPrimary(definition) || hasGreaterRoleThanInfrastructure(definition)) { return def.getValue(); } } throw e; } } }
SpringBasedContainer extends AbstractComponentRegistry implements Container { public <T> T instanceFor(Class<T> type) { try { return parentContext.getBean(type); } catch (NoSuchBeanDefinitionException e) { Map<String, T> beans = parentContext.getBeansOfType(type); for (Entry<String, T> def : beans.entrySet()) { BeanDefinition definition = parentContext.getBeanFactory().getBeanDefinition(def.getKey()); if (isPrimary(definition) || hasGreaterRoleThanInfrastructure(definition)) { return def.getValue(); } } throw e; } } SpringBasedContainer(ConfigurableWebApplicationContext parentContext); }
SpringBasedContainer extends AbstractComponentRegistry implements Container { public <T> T instanceFor(Class<T> type) { try { return parentContext.getBean(type); } catch (NoSuchBeanDefinitionException e) { Map<String, T> beans = parentContext.getBeansOfType(type); for (Entry<String, T> def : beans.entrySet()) { BeanDefinition definition = parentContext.getBeanFactory().getBeanDefinition(def.getKey()); if (isPrimary(definition) || hasGreaterRoleThanInfrastructure(definition)) { return def.getValue(); } } throw e; } } SpringBasedContainer(ConfigurableWebApplicationContext parentContext); void register(Class<?> requiredType, Class<?> componentType); T instanceFor(Class<T> type); boolean canProvide(Class<T> type); void start(ServletContext context); void stop(); }
SpringBasedContainer extends AbstractComponentRegistry implements Container { public <T> T instanceFor(Class<T> type) { try { return parentContext.getBean(type); } catch (NoSuchBeanDefinitionException e) { Map<String, T> beans = parentContext.getBeansOfType(type); for (Entry<String, T> def : beans.entrySet()) { BeanDefinition definition = parentContext.getBeanFactory().getBeanDefinition(def.getKey()); if (isPrimary(definition) || hasGreaterRoleThanInfrastructure(definition)) { return def.getValue(); } } throw e; } } SpringBasedContainer(ConfigurableWebApplicationContext parentContext); void register(Class<?> requiredType, Class<?> componentType); T instanceFor(Class<T> type); boolean canProvide(Class<T> type); void start(ServletContext context); void stop();  }