Example usage for org.springframework.beans.factory.support RootBeanDefinition resolveBeanClass

List of usage examples for org.springframework.beans.factory.support RootBeanDefinition resolveBeanClass

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support RootBeanDefinition resolveBeanClass.

Prototype

@Nullable
public Class<?> resolveBeanClass(@Nullable ClassLoader classLoader) throws ClassNotFoundException 

Source Link

Document

Determine the class of the wrapped bean, resolving it from a specified class name if necessary.

Usage

From source file:org.apache.struts2.spring.ClassReloadingBeanFactory.java

protected Class resolveBeanClass(RootBeanDefinition mbd, String beanName, Class[] typesToMatch) {
    try {//  ww w . j  av  a 2 s. c  om
        //commented to cached class is not used
        /* if (mbd.hasBeanClass()) {
        return mbd.getBeanClass();
        }*/
        if (typesToMatch != null) {
            ClassLoader tempClassLoader = getTempClassLoader();
            if (tempClassLoader != null) {
                if (tempClassLoader instanceof DecoratingClassLoader) {
                    DecoratingClassLoader dcl = (DecoratingClassLoader) tempClassLoader;
                    for (int i = 0; i < typesToMatch.length; i++) {
                        dcl.excludeClass(typesToMatch[i].getName());
                    }
                }
                String className = mbd.getBeanClassName();
                return (className != null ? ClassUtils.forName(className, tempClassLoader) : null);
            }
        }
        return mbd.resolveBeanClass(getBeanClassLoader());
    } catch (ClassNotFoundException ex) {
        throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(),
                ex);
    } catch (LinkageError err) {
        throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(),
                err);
    }
}