当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedBeanDefinition.getMetadata方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedBeanDefinition.getMetadata方法的具体用法?Java AnnotatedBeanDefinition.getMetadata怎么用?Java AnnotatedBeanDefinition.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.annotation.AnnotatedBeanDefinition的用法示例。


在下文中一共展示了AnnotatedBeanDefinition.getMetadata方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerBeanDefinitions

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    Set<String> basePackages = getBasePackages(importingClassMetadata);
    ClassPathScanningCandidateComponentProvider scanner = getScanner();
    scanner.addIncludeFilter(new AnnotationTypeFilter(MuonRepository.class));
    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner
                .findCandidateComponents(basePackage);
        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {

                AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
                Assert.isTrue(annotationMetadata.isInterface(),
                        "@FeignClient can only be specified on an interface");

                BeanDefinitionHolder holder = createBeanDefinition(annotationMetadata);
                BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
            }
        }
    }

}
 
开发者ID:muoncore,项目名称:muon-java,代码行数:24,代码来源:MuonRepositoryRegistrar.java

示例2: registerBeanDefinitions

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    LepServiceProvider scanner = getScanner();
    Set<String> basePackages = getBasePackages(importingClassMetadata);
    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(basePackage);

        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {
                AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();

                Map<String, Object> attributes = annotationMetadata
                    .getAnnotationAttributes(LepService.class.getCanonicalName());

                registerLepService(registry, annotationMetadata, attributes);
            }
        }
    }
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:24,代码来源:LepServicesRegistrar.java

示例3: determineBeanNameFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
/**
 * Derive a bean name from one of the annotations on the class.
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
	AnnotationMetadata amd = annotatedDef.getMetadata();
	Set<String> types = amd.getAnnotationTypes();
	String beanName = null;
	for (String type : types) {
		AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(amd, type);
		if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
			Object value = attributes.get("value");
			if (value instanceof String) {
				String strVal = (String) value;
				if (StringUtils.hasLength(strVal)) {
					if (beanName != null && !strVal.equals(beanName)) {
						throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
								"component names: '" + beanName + "' versus '" + strVal + "'");
					}
					beanName = strVal;
				}
			}
		}
	}
	return beanName;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AnnotationBeanNameGenerator.java

示例4: processCommonDefinitionAnnotations

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd, AnnotatedTypeMetadata metadata) {
	if (metadata.isAnnotated(Lazy.class.getName())) {
		abd.setLazyInit(attributesFor(metadata, Lazy.class).getBoolean("value"));
	}
	else if (abd.getMetadata() != metadata && abd.getMetadata().isAnnotated(Lazy.class.getName())) {
		abd.setLazyInit(attributesFor(abd.getMetadata(), Lazy.class).getBoolean("value"));
	}

	if (metadata.isAnnotated(Primary.class.getName())) {
		abd.setPrimary(true);
	}
	if (metadata.isAnnotated(DependsOn.class.getName())) {
		abd.setDependsOn(attributesFor(metadata, DependsOn.class).getStringArray("value"));
	}

	if (abd instanceof AbstractBeanDefinition) {
		AbstractBeanDefinition absBd = (AbstractBeanDefinition) abd;
		if (metadata.isAnnotated(Role.class.getName())) {
			absBd.setRole(attributesFor(metadata, Role.class).getNumber("value").intValue());
		}
		if (metadata.isAnnotated(Description.class.getName())) {
			absBd.setDescription(attributesFor(metadata, Description.class).getString("value"));
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:AnnotationConfigUtils.java

示例5: processCommonDefinitionAnnotations

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
public static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd) {
	AnnotationMetadata metadata = abd.getMetadata();
	if (metadata.isAnnotated(Primary.class.getName())) {
		abd.setPrimary(true);
	}
	if (metadata.isAnnotated(Lazy.class.getName())) {
		abd.setLazyInit(attributesFor(metadata, Lazy.class).getBoolean("value"));
	}
	if (metadata.isAnnotated(DependsOn.class.getName())) {
		abd.setDependsOn(attributesFor(metadata, DependsOn.class).getStringArray("value"));
	}
	if (abd instanceof AbstractBeanDefinition) {
		if (metadata.isAnnotated(Role.class.getName())) {
			Integer role = attributesFor(metadata, Role.class).getNumber("value");
			((AbstractBeanDefinition)abd).setRole(role);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:19,代码来源:AnnotationConfigUtils.java

示例6: determineBeanNameFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
/**
 * Derive a bean name from one of the annotations on the class.
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
	AnnotationMetadata amd = annotatedDef.getMetadata();
	Set<String> types = amd.getAnnotationTypes();
	String beanName = null;
	for (String type : types) {
		AnnotationAttributes attributes = MetadataUtils.attributesFor(amd, type);
		if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
			Object value = attributes.get("value");
			if (value instanceof String) {
				String strVal = (String) value;
				if (StringUtils.hasLength(strVal)) {
					if (beanName != null && !strVal.equals(beanName)) {
						throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
								"component names: '" + beanName + "' versus '" + strVal + "'");
					}
					beanName = strVal;
				}
			}
		}
	}
	return beanName;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:28,代码来源:AnnotationBeanNameGenerator.java

示例7: getMetadataFromBeanDefinition

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
private AnnotatedTypeMetadata getMetadataFromBeanDefinition(BeanDefinition beanDefinition) {
    if (beanDefinition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition abd = (AnnotatedBeanDefinition) beanDefinition;
        MethodMetadata factoryMethodMetadata = abd.getFactoryMethodMetadata();
        if (factoryMethodMetadata != null) {
            return factoryMethodMetadata;
        } else {
            return abd.getMetadata();
        }
    }
    return null;
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:13,代码来源:VerticleBeanPostProcessor.java

示例8: determineBeanNameFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
@Override
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
	AnnotationMetadata amd = annotatedDef.getMetadata();
	Set<String> types = amd.getAnnotationTypes();
	String beanName = null;
	for (String type : types) {
		Map<String, Object> attributes = amd.getAnnotationAttributes(type);
		if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
			String value = null;
			if (PermissionForRight.class.getName().equals(type)) {
				Right right = (Right)attributes.get("value");
				value = "permission" + right.name();
			} else if (GwtRpcImplements.class.getName().equals(type)) {
				Class<?> requestClass = (Class<?>)attributes.get("value");
				value = requestClass.getName();
			} else if (GwtRpcLogging.class.getName().equals(type)) {
				continue;
			} else {
				value = (String) attributes.get("value");
			}
			if (StringUtils.hasLength(value)) {
				if (beanName != null && !value.equals(beanName)) {
					throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
							"component names: '" + beanName + "' versus '" + value + "'");
				}
				beanName = value;
			}
		}
	}
	return beanName;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:32,代码来源:CustomBeanNameGenerator.java

示例9: registerSoapClients

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
public void registerSoapClients(AnnotationMetadata metadata,
                                 BeanDefinitionRegistry registry) {
    ClassPathScanningCandidateComponentProvider scanner = getScanner();
    scanner.setResourceLoader(this.resourceLoader);

    AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter(
            SoapClient.class);
    scanner.addIncludeFilter(annotationTypeFilter);

    Set<String> basePackages = getBasePackages(metadata);

    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner
                .findCandidateComponents(basePackage);

        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {
                // verify annotated class is an interface
                AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
                Assert.isTrue(annotationMetadata.isInterface(),
                        "@SoapClient can only be specified on an interface");

                Map<String, Object> attributes = annotationMetadata
                        .getAnnotationAttributes(
                                SoapClient.class.getCanonicalName());
                registerSoapClient(registry, annotationMetadata, attributes);
            }
        }
    }
}
 
开发者ID:Salmondx,项目名称:spring-soap-client-starter,代码行数:32,代码来源:SoapClientRegistrar.java

示例10: determineBeanNameFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
/**
 * Derive a bean name from one of the annotations on the class. First delegate to the super class and if it is not a
 * spring annotation then check for the bnd annotation
 * 
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
@Override
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    String beanName = super.determineBeanNameFromAnnotation(annotatedDef);
    if (beanName != null) {
        return beanName;
    } // else check for BND annotation
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    for (String type : types) {
        AnnotationAttributes attributes = AnnotationAttributes.fromMap(amd.getAnnotationAttributes(type, false));
        if (isStereotypeWithBndNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
            Object value = attributes.get("name");
            if (value instanceof String) {
                String strVal = (String) value;
                if (StringUtils.hasLength(strVal)) {
                    if (beanName != null && !strVal.equals(beanName)) {
                        throw new IllegalStateException("Stereotype annotations suggest inconsistent " + "component names: '"
                                + beanName + "' versus '" + strVal + "'");
                    }
                    beanName = strVal;
                }
            }
        }
    }
    return beanName;
}
 
开发者ID:Talend,项目名称:daikon,代码行数:34,代码来源:BndToSpringBeanNameGenerator.java

示例11: isRouteAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
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;
        }
    }

    return false;
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:12,代码来源:RouteBeanNameGenerator.java

示例12: determineBeanNameFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入方法依赖的package包/类
/**
 * 将bean名称设置为@HessianService注解的实现类的className
 */
protected String determineBeanNameFromAnnotation(
		AnnotatedBeanDefinition annotatedDef) {
	AnnotationMetadata amd = annotatedDef.getMetadata();
	return amd.getClassName();
}
 
开发者ID:pugwoo,项目名称:hessoa,代码行数:9,代码来源:HessianServiceScanner.java


注:本文中的org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.getMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。