Example usage for org.springframework.web.context WebApplicationContext getType

List of usage examples for org.springframework.web.context WebApplicationContext getType

Introduction

In this page you can find the example usage for org.springframework.web.context WebApplicationContext getType.

Prototype

@Nullable
Class<?> getType(String name) throws NoSuchBeanDefinitionException;

Source Link

Document

Determine the type of the bean with the given name.

Usage

From source file:org.springframework.web.jsf.el.WebApplicationContextFacesELResolver.java

@Override
@Nullable/*  www. j a va 2s .c o  m*/
public Class<?> getType(ELContext elContext, @Nullable Object base, Object property) throws ELException {
    if (base != null) {
        if (base instanceof WebApplicationContext) {
            WebApplicationContext wac = (WebApplicationContext) base;
            String beanName = property.toString();
            if (logger.isDebugEnabled()) {
                logger.debug("Attempting to resolve property '" + beanName + "' in root WebApplicationContext");
            }
            if (wac.containsBean(beanName)) {
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            "Successfully resolved property '" + beanName + "' in root WebApplicationContext");
                }
                elContext.setPropertyResolved(true);
                try {
                    return wac.getType(beanName);
                } catch (BeansException ex) {
                    throw new ELException(ex);
                }
            } else {
                // Mimic standard JSF/JSP behavior when base is a Map by returning null.
                return null;
            }
        }
    } else {
        if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(property)) {
            elContext.setPropertyResolved(true);
            return WebApplicationContext.class;
        }
    }

    return null;
}