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


Java AnnotationAttributes.getEnum方法代码示例

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


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

示例1: resolveScopeMetadata

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
	ScopeMetadata metadata = new ScopeMetadata();
	if (definition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
		AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
		if (attributes != null) {
			metadata.setScopeName(attributes.getString("value"));
			ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
			if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
				proxyMode = this.defaultProxyMode;
			}
			metadata.setScopedProxyMode(proxyMode);
		}
	}
	return metadata;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AnnotationScopeMetadataResolver.java

示例2: selectImports

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableCache.class.getName(), false));
    Assert.notNull(attributes, String.format("@%s is not present on importing class '%s' as expected", EnableCache.class.getName(), importingClassMetadata.getClassName()));

    CacheMode cacheMode = attributes.getEnum(CACHE_MODE_ATTRIBUTE_NAME);

    if (cacheMode == CacheMode.EHCAHE) {
        return new String[]{EhcacheCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.GUAVA) {
        return new String[]{GuavaCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.REDIS) {
        return new String[]{RedisCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.MEMCACHED) {
        return new String[]{MemcachedCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.OSCACHE) {
        return new String[]{OscacheCacheConfiguration.class.getName()};
    }

    return new String[0];
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:22,代码来源:CacheImportSelector.java

示例3: selectImports

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableSearch.class.getName(), false));
    Assert.notNull(attributes, String.format("@%s is not present on importing class '%s' as expected", EnableSearch.class.getName(), importingClassMetadata.getClassName()));

    List<String> imports = new ArrayList<>();

    SearchType searchType = attributes.getEnum(SEARCH_TYPE_ATTRIBUTE_NAME);
    if (SearchType.SOLR.equals(searchType)) {
        imports.add(SolrConfiguration.class.getName());
    } else if (SearchType.LUCENE.equals(searchType)) {
        imports.add(LuceneConfiguration.class.getName());
    }

    return imports.toArray(new String[imports.size()]);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:17,代码来源:SearchConfigurationSelector.java

示例4: selectImports

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
/**
 * This implementation resolves the type of annotation from generic metadata and
 * validates that (a) the annotation is in fact present on the importing
 * {@code @Configuration} class and (b) that the given annotation has an
 * {@linkplain #getAdviceModeAttributeName() advice mode attribute} of type
 * {@link AdviceMode}.
 * <p>The {@link #selectImports(AdviceMode)} method is then invoked, allowing the
 * concrete implementation to choose imports in a safe and convenient fashion.
 * @throws IllegalArgumentException if expected annotation {@code A} is not present
 * on the importing {@code @Configuration} class or if {@link #selectImports(AdviceMode)}
 * returns {@code null}
 */
@Override
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
	Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
	AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
	if (attributes == null) {
		throw new IllegalArgumentException(String.format(
			"@%s is not present on importing class '%s' as expected",
			annoType.getSimpleName(), importingClassMetadata.getClassName()));
	}

	AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName());
	String[] imports = selectImports(adviceMode);
	if (imports == null) {
		throw new IllegalArgumentException(String.format("Unknown AdviceMode: '%s'", adviceMode));
	}
	return imports;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:AdviceModeImportSelector.java

示例5: resolveScopeMetadata

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
	ScopeMetadata metadata = new ScopeMetadata();
	if (definition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
		AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
		if (attributes != null) {
			metadata.setScopeName(attributes.getAliasedString("value", this.scopeAnnotationType, definition.getSource()));
			ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
			if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
				proxyMode = this.defaultProxyMode;
			}
			metadata.setScopedProxyMode(proxyMode);
		}
	}
	return metadata;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AnnotationScopeMetadataResolver.java

示例6: selectImports

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
/**
 * This implementation resolves the type of annotation from generic metadata and
 * validates that (a) the annotation is in fact present on the importing
 * {@code @Configuration} class and (b) that the given annotation has an
 * {@linkplain #getAdviceModeAttributeName() advice mode attribute} of type
 * {@link AdviceMode}.
 * <p>The {@link #selectImports(AdviceMode)} method is then invoked, allowing the
 * concrete implementation to choose imports in a safe and convenient fashion.
 * @throws IllegalArgumentException if expected annotation {@code A} is not present
 * on the importing {@code @Configuration} class or if {@link #selectImports(AdviceMode)}
 * returns {@code null}
 */
@Override
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
	Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
	AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
	Assert.notNull(attributes, String.format(
			"@%s is not present on importing class '%s' as expected",
			annoType.getSimpleName(), importingClassMetadata.getClassName()));

	AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName());
	String[] imports = selectImports(adviceMode);
	Assert.notNull(imports, String.format("Unknown AdviceMode: '%s'", adviceMode));
	return imports;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AdviceModeImportSelector.java

示例7: registerBeanDefinitions

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(annotationMetadata.getAnnotationAttributes(EnableDfs.class.getName(), false));
    Assert.notNull(attributes, String.format("@%s is not present on importing class '%s' as expected", EnableDfs.class.getName(), annotationMetadata.getClassName()));

    DfsType type = attributes.getEnum(VALUE_ATTRIBUTE_NAME);
    Class<? extends DfsService> clazz = type != null ? type.getImplClazz() : null;

    if (clazz == null) {
        return;
    }

    BeanDefinitionBuilder fsServiceBean = BeanDefinitionBuilder.genericBeanDefinition(clazz);
    beanDefinitionRegistry.registerBeanDefinition("fsService", fsServiceBean.getBeanDefinition());
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:16,代码来源:DfsBeanDefinitionRegistrar.java

示例8: getEnum

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private static <E extends Enum<?>> E getEnum(AnnotationAttributes attributes, String attributeName,
		E inheritedOrDefaultValue, E defaultValue) {
	E value = attributes.getEnum(attributeName);
	if (value == inheritedOrDefaultValue) {
		value = defaultValue;
	}
	return value;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:MergedSqlConfig.java

示例9: selectImports

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {

    Class<?> annoType = EnableOAuth2.class;
    AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
    if (attributes == null) {
        throw new IllegalArgumentException(String.format(
                "@%s is not present on importing class '%s' as expected",
                annoType.getSimpleName(), importingClassMetadata.getClassName()));
    }
    List<String> configurationClasses = new ArrayList<>();
    if (attributes.getEnum("mode") == OperationMode.COMBINED) {
        configurationClasses.add(ResourceServerConfiguration.class.getName());
        configurationClasses.add(AuthorizationServerConfiguration.class.getName());
        OAuth2Configuration.authenticationProviderBean = attributes.getString("authenticationProviderBean");
    }
    if (attributes.getEnum("mode") == OperationMode.RESOURCES) {
        configurationClasses.add(ResourceServerConfiguration.class.getName());

        String authenticationUrl = attributes.getString("authenticationUrl");
        Assert.hasText(authenticationUrl, "Standalone resource servers need to have an authentication endpoint configured, property authenticationUrl");
        AuthenticationProviderConfiguration.authenticationUrl = authenticationUrl;
        OAuth2Configuration.authenticationProviderBean = "httpAuthenticationProvider";
        configurationClasses.add(AuthenticationProviderConfiguration.class.getName());
    }
    if (attributes.getEnum("mode") == OperationMode.AUTHORIZATIONS) {
        configurationClasses.add(AuthorizationServerConfiguration.class.getName());
        OAuth2Configuration.authenticationProviderBean = attributes.getString("authenticationProviderBean");
    }
    configurationClasses.add(OAuth2Configuration.class.getName());
    return configurationClasses.toArray(new String[configurationClasses.size()]);
}
 
开发者ID:openwms,项目名称:webworms,代码行数:36,代码来源:OAuth2ImportSelector.java

示例10: typeFiltersFor

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {
	List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
	FilterType filterType = filterAttributes.getEnum("type");

	for (Class<?> filterClass : filterAttributes.getClassArray("value")) {
		switch (filterType) {
			case ANNOTATION:
				Assert.isAssignable(Annotation.class, filterClass,
						"An error occured while processing a @ComponentScan ANNOTATION type filter: ");
				@SuppressWarnings("unchecked")
				Class<Annotation> annotationType = (Class<Annotation>) filterClass;
				typeFilters.add(new AnnotationTypeFilter(annotationType));
				break;
			case ASSIGNABLE_TYPE:
				typeFilters.add(new AssignableTypeFilter(filterClass));
				break;
			case CUSTOM:
				Assert.isAssignable(TypeFilter.class, filterClass,
						"An error occured while processing a @ComponentScan CUSTOM type filter: ");
				typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class));
				break;
			default:
				throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
		}
	}

	for (String expression : filterAttributes.getStringArray("pattern")) {
		switch (filterType) {
			case ASPECTJ:
				typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader()));
				break;
			case REGEX:
				typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
				break;
			default:
				throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
		}
	}

	return typeFilters;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:ComponentScanAnnotationParser.java

示例11: typeFiltersFor

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {

		List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
		FilterType filterType = filterAttributes.getEnum("type");

		for (Class<?> filterClass : filterAttributes.getClassArray("value")) {
			switch (filterType) {
			case ANNOTATION:
				Assert.isAssignable(Annotation.class, filterClass,
						"An error occured when processing a @ComponentScan "
								+ "ANNOTATION type filter: ");
				@SuppressWarnings("unchecked")
				Class<Annotation> annoClass = (Class<Annotation>) filterClass;
				typeFilters.add(new AnnotationTypeFilter(annoClass));
				break;
			case ASSIGNABLE_TYPE:
				typeFilters.add(new AssignableTypeFilter(filterClass));
				break;
			case CUSTOM:
				Assert.isAssignable(TypeFilter.class, filterClass,
						"An error occured when processing a @ComponentScan "
								+ "CUSTOM type filter: ");
				typeFilters
						.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class));
				break;
			default:
				throw new IllegalArgumentException("Unknown filter type " + filterType);
			}
		}

		for (String expression : getPatterns(filterAttributes)) {

			String rawName = filterType.toString();

			if ("REGEX".equals(rawName)) {
				typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
			} else if ("ASPECTJ".equals(rawName)) {
				typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader
						.getClassLoader()));
			} else {
				throw new IllegalArgumentException("Unknown filter type " + filterType);
			}
		}

		return typeFilters;
	}
 
开发者ID:beingsagir,项目名称:play-java-spring-data-jpa,代码行数:47,代码来源:GuiceModuleRegistrar.java

示例12: typeFiltersFor

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {
	List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
	FilterType filterType = filterAttributes.getEnum("type");

	for (Class<?> filterClass : filterAttributes.getAliasedClassArray("classes", ComponentScan.Filter.class, null)) {
		switch (filterType) {
			case ANNOTATION:
				Assert.isAssignable(Annotation.class, filterClass,
						"An error occured while processing a @ComponentScan ANNOTATION type filter: ");
				@SuppressWarnings("unchecked")
				Class<Annotation> annotationType = (Class<Annotation>) filterClass;
				typeFilters.add(new AnnotationTypeFilter(annotationType));
				break;
			case ASSIGNABLE_TYPE:
				typeFilters.add(new AssignableTypeFilter(filterClass));
				break;
			case CUSTOM:
				Assert.isAssignable(TypeFilter.class, filterClass,
						"An error occured while processing a @ComponentScan CUSTOM type filter: ");
				typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class));
				break;
			default:
				throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
		}
	}

	for (String expression : filterAttributes.getStringArray("pattern")) {
		switch (filterType) {
			case ASPECTJ:
				typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader()));
				break;
			case REGEX:
				typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
				break;
			default:
				throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
		}
	}

	return typeFilters;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:42,代码来源:ComponentScanAnnotationParser.java

示例13: registerBeanDefinitions

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata,
		BeanDefinitionRegistry registry) {

	Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!");
	Assert.notNull(registry, "BeanDefinitionRegistry must not be null!");

	registry.registerBeanDefinition("VaultPropertySourceRegistrar",
			BeanDefinitionBuilder //
					.rootBeanDefinition(VaultPropertySourceRegistrar.class) //
					.setRole(BeanDefinition.ROLE_INFRASTRUCTURE) //
					.getBeanDefinition());

	Set<AnnotationAttributes> propertySources = attributesForRepeatable(
			annotationMetadata, VaultPropertySources.class.getName(),
			VaultPropertySource.class.getName());

	int counter = 0;

	for (AnnotationAttributes propertySource : propertySources) {

		String[] paths = propertySource.getStringArray("value");
		String ref = propertySource.getString("vaultTemplateRef");
		String propertyNamePrefix = propertySource.getString("propertyNamePrefix");
		Renewal renewal = propertySource.getEnum("renewal");

		Assert.isTrue(paths.length > 0,
				"At least one @VaultPropertySource(value) location is required");

		Assert.hasText(ref,
				"'vaultTemplateRef' in @EnableVaultPropertySource must not be empty");

		PropertyTransformer propertyTransformer = StringUtils
				.hasText(propertyNamePrefix) ? PropertyTransformers
				.propertyNamePrefix(propertyNamePrefix) : PropertyTransformers.noop();

		for (String propertyPath : paths) {

			if (!StringUtils.hasText(propertyPath)) {
				continue;
			}

			AbstractBeanDefinition beanDefinition = createBeanDefinition(ref,
					renewal, propertyTransformer, propertyPath);

			registry.registerBeanDefinition("vaultPropertySource#" + counter,
					beanDefinition);

			counter++;
		}
	}
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:53,代码来源:VaultPropertySourceRegistrar.java

示例14: typeFiltersFor

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {
	List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
	FilterType filterType = filterAttributes.getEnum("type");

	for (Class<?> filterClass : filterAttributes.getAliasedClassArray("classes", ComponentScan.Filter.class, null)) {
		switch (filterType) {
			case ANNOTATION:
				Assert.isAssignable(Annotation.class, filterClass,
						"An error occured while processing a @ComponentScan ANNOTATION type filter: ");
				@SuppressWarnings("unchecked")
				Class<Annotation> annotationType = (Class<Annotation>) filterClass;
				typeFilters.add(new AnnotationTypeFilter(annotationType));
				break;
			case ASSIGNABLE_TYPE:
				typeFilters.add(new AssignableTypeFilter(filterClass));
				break;
			case CUSTOM:
				Assert.isAssignable(TypeFilter.class, filterClass,
						"An error occured while processing a @ComponentScan CUSTOM type filter: ");
				TypeFilter filter = BeanUtils.instantiateClass(filterClass, TypeFilter.class);
				invokeAwareMethods(filter);
				typeFilters.add(filter);
				break;
			default:
				throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
		}
	}

	for (String expression : filterAttributes.getStringArray("pattern")) {
		switch (filterType) {
			case ASPECTJ:
				typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader()));
				break;
			case REGEX:
				typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
				break;
			default:
				throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
		}
	}

	return typeFilters;
}
 
开发者ID:txazo,项目名称:spring,代码行数:44,代码来源:ComponentScanAnnotationParser.java


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