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