@Override @Nullable public View resolveViewName(String viewName, Locale locale) throws BeansException { ApplicationContext context = obtainApplicationContext(); if (!context.containsBean(viewName)) { // Allow for ViewResolver chaining... return null; } if (!context.isTypeMatch(viewName, View.class)) { if (logger.isDebugEnabled()) { logger.debug("Found bean named '" + viewName + "' but it does not implement View"); } // Since we're looking into the general ApplicationContext here, // let's accept this as a non-match and allow for chaining as well... return null; } return context.getBean(viewName, View.class); }
@Override @Nullable public View resolveViewName(String viewName, Locale locale) throws BeansException { ApplicationContext context = obtainApplicationContext(); if (!context.containsBean(viewName)) { // Allow for ViewResolver chaining... return null; } if (!context.isTypeMatch(viewName, View.class)) { if (logger.isDebugEnabled()) { logger.debug("Found bean named '" + viewName + "' but it does not implement View"); } // Since we're looking into the general ApplicationContext here, // let's accept this as a non-match and allow for chaining as well... return null; } return context.getBean(viewName, View.class); }
@Test public void typeCheck() { assertTrue(this.context.isTypeMatch("default", Executor.class)); assertTrue(this.context.isTypeMatch("default", TaskExecutor.class)); assertTrue(this.context.isTypeMatch("default", ThreadPoolTaskExecutor.class)); }
public boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, typeToMatch); }
public boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, typeToMatch); }
/** * @param arg0 * @param arg1 * @return * @throws NoSuchBeanDefinitionException * @see org.springframework.beans.factory.BeanFactory#isTypeMatch(java.lang.String, java.lang.Class) */ @SuppressWarnings("unchecked") public boolean isTypeMatch(String arg0, Class arg1) throws NoSuchBeanDefinitionException { return target.isTypeMatch(arg0, arg1); }
public boolean isTypeMatch(String name, ResolvableType targetType) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, targetType); } public Class<?> getType(String name)
/** * Delegates to internal ApplicationContext supplied by constructor */ @SuppressWarnings("unchecked") public final boolean isTypeMatch(String arg0, Class arg1) throws NoSuchBeanDefinitionException { return context.isTypeMatch(arg0, arg1); }
public boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, targetType); } public boolean isTypeMatch(String name, ResolvableType targetType)
public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException { return wrappedApplicationContext.isTypeMatch(name, targetType); }
@Override public boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException { return wrapped.isTypeMatch(name, typeToMatch); }
@Override public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, targetType); }
public static boolean isTypeMatch(String name, Class<?> typeToMatch) { return context.isTypeMatch(name, typeToMatch); }
public static boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, typeToMatch); }
@Override public boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException { return wrapped.isTypeMatch(name, typeToMatch); }
public static boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, typeToMatch); }
public static boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, typeToMatch); }
public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch(name, targetType); }
@Override public boolean isTypeMatch( String s, Class<?> aClass ) throws NoSuchBeanDefinitionException { return applicationContext.isTypeMatch( s, aClass ); }
/** * Returns the bean with an id matching the specified id, or null if none found. * * @param id Bean id * @param clazz Expected return type. * @return Returns the bean instance whose id matches the specified id, or null if none found or * if the application context cannot be determined. */ public static <T> T getBean(String id, Class<T> clazz) { ApplicationContext appContext = getAppContext(); return appContext == null ? null : appContext.containsBean(id) && appContext.isTypeMatch(id, clazz) ? appContext .getBean(id, clazz) : null; }