Example usage for org.springframework.beans.factory.annotation AnnotatedBeanDefinition getFactoryMethodMetadata

List of usage examples for org.springframework.beans.factory.annotation AnnotatedBeanDefinition getFactoryMethodMetadata

Introduction

In this page you can find the example usage for org.springframework.beans.factory.annotation AnnotatedBeanDefinition getFactoryMethodMetadata.

Prototype

@Nullable
MethodMetadata getFactoryMethodMetadata();

Source Link

Document

Obtain metadata for this bean definition's factory method, if any.

Usage

From source file:org.joinfaces.annotations.JsfCdiToSpringBeanFactoryPostProcessor.java

/**
 * Checks how is bean defined and deduces scope name from JSF CDI annotations.
 *
 * @param definition beanDefinition/*from   w ww. jav a2  s  . c o  m*/
 */
private void registerJsfCdiToSpring(BeanDefinition definition) {

    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

        String scopeName = null;
        // firstly check whether bean is defined via configuration
        if (annDef.getFactoryMethodMetadata() != null) {
            scopeName = JsfCdiToSpring.deduceScopeName(annDef.getFactoryMethodMetadata());
        } else {
            // fallback to type
            scopeName = JsfCdiToSpring.deduceScopeName(annDef.getMetadata().getAnnotationTypes());
        }

        if (scopeName != null) {
            definition.setScope(scopeName);

            logger.debug(
                    definition.getBeanClassName() + " - Scope(" + definition.getScope().toUpperCase() + ")");
        }
    }
}