public <T> T getComponent(String name) { T bean = null; try { bean = (T) this.applicationContext.getBean(name); } catch (Exception ignore) { } return bean; }
public <T> T getBean(Class<T> clazz) { String[] beanNames = applicationContext.getBeanNamesForType(clazz); if (beanNames.length == 1) { return (T) applicationContext.getBean(beanNames[0]); } else if (beanNames.length == 0 && parent != null) { return parent.getBean(clazz); } else { throw new NoSuchBeanDefinitionException(clazz, "expected single bean but found " + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames)); } }
@SuppressWarnings("unchecked") public <T> T getComponent(String name) { T bean = null; try { bean = (T) applicationContext.getBean(name); } catch (Exception ignore) { log.warn("The requested bean doesn't exist: '{}'", name); } return bean; }
public <T> T getComponent(String name) { T bean = null; try { bean = (T) applicationContext.getBean(name); } catch (Exception ignore) { } if (bean == null && servletContext != null) { WebApplicationContext rootWebAppContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (rootWebAppContext != null) { try { bean = (T) rootWebAppContext.getBean(name); } catch (Exception ignore) { } } } return bean; }
public <T> T getComponent(Class<T> requiredType) { T bean = null; try { bean = (T) applicationContext.getBean(requiredType); } catch (Exception ignore) { log.warn("The requested bean doesn't exist by the required type: '{}'", requiredType); } if (bean == null) { throw new ComponentsException("No component found, not exactly matching a single component by the specified type, " + requiredType); } return bean; }
public <T> T getBean(String name) { try { return (T) applicationContext.getBean(name); } catch (NoSuchBeanDefinitionException e) { // String message = e.getMessage(); // if (message.equals(noBeanCaseInfo.replace(hashCode() + "", // name))) { if (parent != null) { return (T) parent.getBean(name); } // } throw e; } }
public <T> T getBean(String name, Class<T> clazz) { try { return (T) applicationContext.getBean(name, clazz); } catch (NoSuchBeanDefinitionException e) { // String message = e.getMessage(); // if (message.equals(noBeanCaseInfo.replace(hashCode() + "", // name))) { if (parent != null) { return parent.getBean(name, clazz); } // } throw e; } }
bean = (T) applicationContext.getBean(name); } catch (Exception e) { if (fallbackRootApplicationContextLookup && servletContext != null) {
bean = applicationContext.getBean(requiredType); } catch (Exception e) { if (fallbackRootApplicationContextLookup && servletContext != null) {