當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。