本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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"));
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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();
}