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

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

Introduction

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

Prototype

AnnotationMetadata getMetadata();

Source Link

Document

Obtain the annotation metadata (as well as basic class metadata) for this bean definition's bean class.

Usage

From source file:org.rosenvold.spring.convention.ConventionBeanFactory.java

static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd) {
    if (abd.getMetadata().isAnnotated(Primary.class.getName())) {
        abd.setPrimary(true);// w w  w  .  j a  v a 2s.c o m
    }
    if (abd.getMetadata().isAnnotated(Lazy.class.getName())) {
        Boolean value = (Boolean) abd.getMetadata().getAnnotationAttributes(Lazy.class.getName()).get("value");
        abd.setLazyInit(value);
    }
    if (abd.getMetadata().isAnnotated(DependsOn.class.getName())) {
        String[] value = (String[]) abd.getMetadata().getAnnotationAttributes(DependsOn.class.getName())
                .get("value");
        abd.setDependsOn(value);
    }
}

From source file:com.longio.spring.LioScanningCandidateComponentProvider.java

@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {

    if (beanDefinition.getMetadata().hasAnnotation(LsAutowired.class.getCanonicalName())) {
        return true;
    }//w w w.j a  va 2 s . com

    return (beanDefinition.getMetadata().isConcrete() && beanDefinition.getMetadata().isIndependent());
}

From source file:com.github.ljtfreitas.restify.spring.configure.RestifyableTypeScanner.java

@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
    return beanDefinition.getMetadata().isInterface();
}

From source file:org.codehaus.grepo.core.config.GenericRepositoryBeanDefinitionScanner.java

/**
 * {@inheritDoc}//  w ww. jav a2 s. c  om
 */
@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
    // top level classes only...
    return !beanDefinition.getMetadata().hasEnclosingClass();
}

From source file:darks.orm.spring.MapperClassDefinitionScanner.java

/**
 * {@inheritDoc}/*from  w w w. ja v a2s  .  c o  m*/
 */
@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
    return ((beanDefinition.getMetadata().isInterface() || beanDefinition.getMetadata().isAbstract())
            && beanDefinition.getMetadata().isIndependent());
}

From source file:com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientClassPathScanner.java

/**
 * {@inheritDoc}/*from w ww.  j a v a 2s . c om*/
 */
@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
    return beanDefinition.getMetadata().isInterface() && beanDefinition.getMetadata().isIndependent();
}

From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringBeanNameGenerator.java

@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
    String result = super.generateBeanName(definition, registry);

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

        String scopeName = JsfCdiToSpring.scopeName(annDef.getMetadata().getAnnotationTypes());
        if (scopeName != null) {
            definition.setScope(scopeName);

            logger.debug(/*from   ww  w  .  j a  va  2s  .  c o  m*/
                    definition.getBeanClassName() + " - Scope(" + definition.getScope().toUpperCase() + ")");
        }
    }

    return result;
}

From source file:org.cleverbus.core.common.route.RouteBeanNameGenerator.java

protected boolean isRouteAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    for (String type : types) {
        if (type.equals(CAMEL_CONF_CLASSNAME)) {
            return true;
        }//from  w w  w  . j  a  v  a2s. c  om
    }

    return false;
}

From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringScopeMetadataResolver.java

/**
 * Discover spring scope using bean definition.
 *
 * @param definition bean definition//from   w  ww . j a va2  s .c o m
 * @return scope metadata
 */
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

        String scopeName = JsfCdiToSpring.scopeName(annDef.getMetadata().getAnnotationTypes());
        if (scopeName != null) {
            metadata.setScopeName(scopeName);

            logger.debug(definition.getBeanClassName() + " - Scope(" + metadata.getScopeName().toUpperCase()
                    + ") - " + metadata.getScopedProxyMode().toString().toUpperCase());
        } else {
            // do the regular Spring stuff..
            metadata = super.resolveScopeMetadata(definition);
        }
    }

    return metadata;
}

From source file:net.wessendorf.spring.scopes.CdiScopeMetadataResolver.java

/**
 * Checks if one of the following CDI scope annoations are used and maps
 * them to their matching Spring scopes:
 * /*from w  ww  .j  a  v a  2 s .c  o  m*/
 * <ul>
 * <li><code>&#064;javax.enterprise.context.RequestScoped</code></li>
 * <li><code>&#064;javax.enterprise.context.SessionScoped</code></li>
 * <li><code>&#064;javax.enterprise.context.ApplicationScoped</code></li>
 * </ul>
 * 
 * If none of them are found it delegates back to the original Spring
 * <code>AnnotationScopeMetadataResolver</code> class. 
 */
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
        Set<String> annotationTypes = annDef.getMetadata().getAnnotationTypes();

        if (annotationTypes.contains(RequestScoped.class.getName())) {
            metadata.setScopeName(WebApplicationContext.SCOPE_REQUEST);
        } else if (annotationTypes.contains(SessionScoped.class.getName())) {
            metadata.setScopeName(WebApplicationContext.SCOPE_SESSION);
        } else if (annotationTypes.contains(ApplicationScoped.class.getName())) {
            metadata.setScopeName(WebApplicationContext.SCOPE_APPLICATION);
        } else {
            // do the regular Spring stuff..
            return super.resolveScopeMetadata(definition);
        }
    }
    return metadata;
}