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

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

Introduction

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

Prototype

public Class<?> getBeanClass() throws IllegalStateException 

Source Link

Document

Return the class of the wrapped bean (assuming it is resolved already).

Usage

From source file:org.springmodules.jcr.jackrabbit.JackrabbitNamespaceHandlerTests.java

public void testFullDefinition() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory.getBeanDefinition("full");
    assertSame(RepositoryFactoryBean.class, (beanDefinition.getBeanClass()));
    assertPropertyValue(beanDefinition, "homeDir", "file:///homeDir");
    assertPropertyValue(beanDefinition, "repositoryConfig", "repoCfg");
}

From source file:org.springmodules.jcr.jackrabbit.JackrabbitNamespaceHandlerTests.java

public void testMinimalDefinition() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory.getBeanDefinition("minimal");
    assertSame(RepositoryFactoryBean.class, beanDefinition.getBeanClass());
    assertPropertyValue(beanDefinition, "configuration", "classpath:config.xml");
}

From source file:org.springmodules.jcr.jackrabbit.JackrabbitNamespaceHandlerTests.java

public void testExtendedDefinition() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory.getBeanDefinition("extended");
    assertSame(RepositoryFactoryBean.class, (beanDefinition.getBeanClass()));
    assertPropertyValue(beanDefinition, "configuration", "file:config.xml");
    assertPropertyValue(beanDefinition, "homeDir", "file:///homeDir");
}

From source file:org.springmodules.jcr.config.JcrNamespaceHandlerTests.java

public void testSessionFactory() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory
            .getBeanDefinition("sessionFactory");
    assertSame(JcrSessionFactory.class, beanDefinition.getBeanClass());

}

From source file:org.springmodules.jcr.config.JcrNamespaceHandlerTests.java

public void testEventListenerDefinition() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory
            .getBeanDefinition("eventListenerFull");
    assertSame(EventListenerDefinition.class, beanDefinition.getBeanClass());
    assertPropertyValue(beanDefinition, "absPath", "/somePath");
    assertPropertyValue(beanDefinition, "isDeep", "true");
    assertPropertyValue(beanDefinition, "noLocal", "false");
    assertPropertyValue(beanDefinition, "eventType", new Integer(17));
    assertTrue(ObjectUtils.nullSafeEquals(new String[] { "123" },
            (Object[]) getPropertyValue(beanDefinition, "uuid")));
    assertTrue(ObjectUtils.nullSafeEquals(new String[] { "foo", "bar" },
            (Object[]) getPropertyValue(beanDefinition, "nodeTypeName")));
}

From source file:org.springmodules.jcr.jackrabbit.JackrabbitNamespaceHandlerTests.java

public void testTransactionManager() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory
            .getBeanDefinition("transactionManager");
    assertSame(LocalTransactionManager.class, (beanDefinition.getBeanClass()));
    assertPropertyValue(beanDefinition, "sessionFactory", "jcrSessionFactory");
}

From source file:org.sakaiproject.util.NoisierDefaultListableBeanFactory.java

public void preInstantiateSingletons() throws BeansException {
    if (logger.isDebugEnabled()) {
        logger.debug("Pre-instantiating singletons in factory [" + this + "]");
    }//from w w  w . j a  v a 2s  .  c  om

    // The superclass's variable by this name is declared private.
    String[] beanDefinitionNames = getBeanDefinitionNames();
    String beanName = null; // Remember in case of an exception
    try {
        //         for (Iterator it = this.beanDefinitionNames.iterator(); it.hasNext();) {
        for (int i = 0; i < beanDefinitionNames.length; i++) {
            beanName = beanDefinitionNames[i];
            if (!containsSingleton(beanName) && containsBeanDefinition(beanName)) {
                RootBeanDefinition bd = getMergedBeanDefinition(beanName, false);
                if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
                    if (bd.hasBeanClass() && FactoryBean.class.isAssignableFrom(bd.getBeanClass())) {
                        FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
                        if (factory.isSingleton()) {
                            getBean(beanName);
                        }
                    } else {
                        getBean(beanName);
                    }
                }
            }
        }
    } catch (BeansException ex) {
        // Destroy already created singletons to avoid dangling resources.
        logger.error(
                "Failed to preinstantiate the singleton named " + beanName + ". Destroying all Spring beans.",
                ex);
        try {
            destroySingletons();
        } catch (Throwable ex2) {
            logger.error(
                    "Pre-instantiating singletons failed, " + "and couldn't destroy already created singletons",
                    ex2);
        }
        throw ex;
    }
}

From source file:com.liferay.arkadiko.bean.AKBeanPostProcessor.java

/**
 * Try to get an Arkadiko bean which is a proxy backed by an OSGi service
 * tracker which is either going to wrap an existing spring bean, or wait
 * for one to be registered. This only happens when the bean is declared to
 * be wrapped by name or by class/interface.
 *
 * @param rootBeanDefinition//  w  w w  .j a v a  2 s.  c  om
 * @param beanName
 * @return a bean or null
 */
protected Object getServiceBean(RootBeanDefinition rootBeanDefinition, String beanName) {

    BeanDefinition originatingBeanDefinition = rootBeanDefinition.getOriginatingBeanDefinition();

    if ((originatingBeanDefinition != null) && (originatingBeanDefinition instanceof AKBeanDefinition)) {

        AKBeanDefinition akBeanDefinition = (AKBeanDefinition) originatingBeanDefinition;

        return akBeanDefinition.getProxy();
    } else if (rootBeanDefinition.hasBeanClass()) {
        Class<?> clazz = rootBeanDefinition.getBeanClass();

        if (clazz.isInterface()) {
            AKBeanDefinition akBeanDefinition = new AKBeanDefinition(this, rootBeanDefinition, beanName,
                    getServiceRegistry());

            return akBeanDefinition.getProxy();
        }
    }

    return null;
}

From source file:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.java

@Override
public void autowireBean(Object existingBean) {
    // Use non-singleton bean definition, to avoid registering bean as dependent bean.
    RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean));
    bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
    bd.allowCaching = ClassUtils.isCacheSafe(bd.getBeanClass(), getBeanClassLoader());
    BeanWrapper bw = new BeanWrapperImpl(existingBean);
    initBeanWrapper(bw);// w  w w . jav a  2s .  c o  m
    populateBean(bd.getBeanClass().getName(), bd, bw);
}

From source file:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.java

@Override
public void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)
        throws BeansException {

    if (autowireMode == AUTOWIRE_CONSTRUCTOR) {
        throw new IllegalArgumentException("AUTOWIRE_CONSTRUCTOR not supported for existing bean instance");
    }//ww w  . jav  a2s  .  c  om
    // Use non-singleton bean definition, to avoid registering bean as dependent bean.
    RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean), autowireMode,
            dependencyCheck);
    bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
    BeanWrapper bw = new BeanWrapperImpl(existingBean);
    initBeanWrapper(bw);
    populateBean(bd.getBeanClass().getName(), bd, bw);
}