本文整理汇总了Java中org.springframework.core.type.AnnotationMetadata.getAnnotationAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationMetadata.getAnnotationAttributes方法的具体用法?Java AnnotationMetadata.getAnnotationAttributes怎么用?Java AnnotationMetadata.getAnnotationAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.type.AnnotationMetadata
的用法示例。
在下文中一共展示了AnnotationMetadata.getAnnotationAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBasePackages
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
/**
* Gets base packages.
*
* @param importingClassMetadata the importing class metadata
* @return the base packages
*/
protected Set<String> getBasePackages(AnnotationMetadata importingClassMetadata) {
Map<String, Object> attributes = importingClassMetadata
.getAnnotationAttributes(EnableRestyPass.class.getCanonicalName());
Set<String> basePackages = new HashSet<>();
if (StringUtils.hasText((String) attributes.get("value"))) {
basePackages.add((String) attributes.get("value"));
}
for (String pkg : (String[]) attributes.get("basePackages")) {
if (StringUtils.hasText(pkg)) {
basePackages.add(pkg);
}
}
for (Class<?> clazz : (Class[]) attributes.get("basePackageClasses")) {
basePackages.add(ClassUtils.getPackageName(clazz));
}
if (basePackages.isEmpty()) {
basePackages.add(
ClassUtils.getPackageName(importingClassMetadata.getClassName()));
}
return basePackages;
}
示例2: registerBeanDefinitions
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的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: getEntityCollectionInfo
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
private String getEntityCollectionInfo(String className) throws IOException
{
AnnotationMetadata annotationMetaData = getAnnotationMetadata(className);
if (annotationMetaData.isConcrete() && annotationMetaData.isIndependent())
{
if (annotationMetaData.getAnnotationTypes().contains(EntityResource.class.getCanonicalName()))
{
Map<String, Object> attrs = annotationMetaData.getAnnotationAttributes(EntityResource.class.getName());
return (String) attrs.get("name");
}
else
{
return null;
}
}
else
{
throw new AlfrescoRuntimeException("");
}
}
示例4: registerBeanDefinitions
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
Map<String, Object> attributes = annotationMetadata.getAnnotationAttributes(EnableBeanContext.class.getName());
if (attributes == null) {
return;
}
boolean lookupByType = (boolean) attributes.get("lookupByType");
// check environment
if (environment.containsProperty(EnableBeanContext.LOOKUP_BY_TYPE_PROPERTY_NAME)) {
lookupByType = environment.getProperty(EnableBeanContext.LOOKUP_BY_TYPE_PROPERTY_NAME, Boolean.class);
}
// register post processor
if (!registry.containsBeanDefinition(BEAN_FACTORY_SCOPE_POST_PROCESSOR_NAME)) {
BeanDefinitionBuilder postProcessorBuilder = BeanDefinitionBuilder
.genericBeanDefinition(BeanFactoryScopePostProcessor.class).setDestroyMethodName("unregister")
.addPropertyValue("lookupByType", lookupByType).setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
registry.registerBeanDefinition(BEAN_FACTORY_SCOPE_POST_PROCESSOR_NAME,
postProcessorBuilder.getBeanDefinition());
}
}
示例5: registerBeanDefinitions
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
// Single annotation
if (annotationMetadata.isAnnotated(repeatableAnnotation.getName())) {
register(annotationMetadata.getAnnotationAttributes(repeatableAnnotation.getName()), registry, false);
} else if (annotationMetadata.isAnnotated(repeatableAnnotationContainer.getName())) {
// Multiple annotations
Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(repeatableAnnotationContainer.getName());
AnnotationAttributes[] repetitions = (AnnotationAttributes[]) attributes.get("value");
if (repetitions != null) {
for (AnnotationAttributes repetition : repetitions) {
register(repetition, registry, true);
}
}
}
}
示例6: registerBeanDefinitions
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
if (!annotationMetadata.isAnnotated(EnableJdbcDatastore.class.getName())) {
// ignore call from sub classes
return;
}
Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(EnableJdbcDatastore.class.getName());
// attributes
String dataContextId = BeanRegistryUtils.getAnnotationValue(attributes, "dataContextId", null);
PrimaryMode primaryMode = BeanRegistryUtils.getAnnotationValue(attributes, "primary", PrimaryMode.AUTO);
String dataSourceReference = BeanRegistryUtils.getAnnotationValue(attributes, "dataSourceReference", null);
String dataSourceBeanName = dataSourceReference;
if (dataSourceBeanName == null) {
dataSourceBeanName = BeanRegistryUtils.buildBeanName(dataContextId,
EnableDataSource.DEFAULT_DATASOURCE_BEAN_NAME);
}
registerDatastore(registry, getEnvironment(), dataContextId, primaryMode, dataSourceBeanName,
BeanRegistryUtils.getAnnotationValue(attributes, "platform", DatabasePlatform.NONE),
BeanRegistryUtils.getAnnotationValue(attributes, "transactional", true), beanClassLoader);
}
示例7: registerBeanDefinitions
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
if (!annotationMetadata.isAnnotated(EnableDataSource.class.getName())) {
// ignore call from sub classes
return;
}
Map<String, Object> attributes = annotationMetadata.getAnnotationAttributes(EnableDataSource.class.getName());
// Annotation values
String dataContextId = BeanRegistryUtils.getAnnotationValue(attributes, "dataContextId", null);
PrimaryMode primaryMode = BeanRegistryUtils.getAnnotationValue(attributes, "primary", PrimaryMode.AUTO);
boolean registerTransactionManager = BeanRegistryUtils.getAnnotationValue(attributes,
"enableTransactionManager", false);
String dsBeanName = registerDataSource(getEnvironment(), registry, dataContextId, primaryMode);
// Transaction manager
if (registerTransactionManager) {
registerDataSourceTransactionManager(registry, dsBeanName, dataContextId, primaryMode);
}
}
示例8: getRelationCollectionInfo
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
private Pair<String, String> getRelationCollectionInfo(Class<?> resourceClass) throws IOException
{
AnnotationMetadata annotationMetaData = getAnnotationMetadata(resourceClass.getCanonicalName());
if (annotationMetaData.isConcrete() && annotationMetaData.isIndependent())
{
if (annotationMetaData.getAnnotationTypes().contains(RelationshipResource.class.getCanonicalName()))
{
Map<String, Object> attrs = annotationMetaData.getAnnotationAttributes(RelationshipResource.class.getName());
String relationshipCollectionName = (String) attrs.get("name");
Class<?> entityResource = (Class<?>) attrs.get("entityResource");
String entityCollectionName = getEntityCollectionInfo(entityResource.getCanonicalName());
Pair<String, String> ret = new Pair<String, String>(entityCollectionName, relationshipCollectionName);
return ret;
}
else
{
return null;
}
}
else
{
throw new AlfrescoRuntimeException("");
}
}
示例9: selectImports
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String[] selectImports(AnnotationMetadata metadata) {
List<String> imports = new ArrayList<>();
Map<String, Object> attributes = metadata.getAnnotationAttributes(EnableContextPropagation.class.getName(), true);
if (attributes != null) {
ATTRIBUTES.forEach(x -> importStrategy(imports, attributes, x));
}
return imports.toArray(new String[imports.size()]);
}
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:13,代码来源:ExecutionContextPropagationImport.java
示例10: setImportMetadata
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableRedissonHttpSession.class.getName());
AnnotationAttributes attrs = AnnotationAttributes.fromMap(map);
keyPrefix = attrs.getString("keyPrefix");
maxInactiveIntervalInSeconds = attrs.getNumber("maxInactiveIntervalInSeconds");
}
示例11: selectImports
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
Map<String, Object> attributes = importingClassMetadata.getAnnotationAttributes(EnableVertx.class.getName());
boolean deployVerticles = (boolean) attributes.getOrDefault("deployVerticles", Boolean.TRUE);
if (deployVerticles) {
return new String[] { VertxConfiguration.class.getName(), VerticleDeploymentConfiguration.class.getName() };
} else {
return new String[] { VertxConfiguration.class.getName() };
}
}
示例12: setImportMetadata
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
/**
* setImportMetadata
*
* @param importMetadata Annotations Metadata to validate...
*/
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableYourMicroservice.class.getName());
this.enableYourMicroservice = AnnotationAttributes.fromMap(map);
if (this.enableYourMicroservice == null) {
String message =
"@EnableYourMicroservice is not present on importing class " + importMetadata.getClassName();
LOGGER.error(message);
throw new IllegalArgumentException(message);
}
}
示例13: attributesForRepeatable
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
String containerClassName, String annotationClassName) {
Set<AnnotationAttributes> result = new LinkedHashSet<AnnotationAttributes>();
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
if (container != null && container.containsKey("value")) {
for (Map<String, Object> containedAttributes : (Map<String, Object>[]) container.get("value")) {
addAttributesIfNotNull(result, containedAttributes);
}
}
return Collections.unmodifiableSet(result);
}
示例14: setImportMetadata
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的package包/类
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName());
this.attributes = AnnotationAttributes.fromMap(map);
Assert.notNull(this.attributes,
"@EnableMBeanExport is not present on importing class " + importMetadata.getClassName());
}
示例15: determineBeanNameFromAnnotation
import org.springframework.core.type.AnnotationMetadata; //导入方法依赖的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;
}