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


Java AnnotationAttributes.getClassArray方法代码示例

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


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

示例1: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(ServletComponentScan.class.getName()));
    String[] value = attributes.getStringArray("value");
    String[] basePackages = attributes.getStringArray("basePackages");
    Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
    if (!ObjectUtils.isEmpty(value)) {
        Assert.state(ObjectUtils.isEmpty(basePackages),
                "@ServletComponentScan basePackages and value attributes are" + " mutually exclusive");
    }
    Set<String> packagesToScan = new LinkedHashSet<String>();
    packagesToScan.addAll(Arrays.asList(value));
    packagesToScan.addAll(Arrays.asList(basePackages));
    for (Class<?> basePackageClass : basePackageClasses) {
        packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
    }
    if (packagesToScan.isEmpty()) {
        return Collections.singleton(ClassUtils.getPackageName(metadata.getClassName()));
    }
    return packagesToScan;
}
 
开发者ID:PebbleTemplates,项目名称:pebble-spring-boot-starter,代码行数:22,代码来源:ServletComponentScanRegistrar.java

示例2: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
	AnnotationAttributes attributes = AnnotationAttributes.fromMap(
			metadata.getAnnotationAttributes(ServletComponentScan.class.getName()));
	String[] basePackages = attributes.getStringArray("basePackages");
	Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
	Set<String> packagesToScan = new LinkedHashSet<String>();
	packagesToScan.addAll(Arrays.asList(basePackages));
	for (Class<?> basePackageClass : basePackageClasses) {
		packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
	}
	if (packagesToScan.isEmpty()) {
		return Collections
				.singleton(ClassUtils.getPackageName(metadata.getClassName()));
	}
	return packagesToScan;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ServletComponentScanRegistrar.java

示例3: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
	AnnotationAttributes attributes = AnnotationAttributes
			.fromMap(metadata.getAnnotationAttributes(EntityScan.class.getName()));
	String[] basePackages = attributes.getAliasedStringArray("basePackages",
			EntityScan.class, metadata.getClassName());
	Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
	Set<String> packagesToScan = new LinkedHashSet<String>();
	packagesToScan.addAll(Arrays.asList(basePackages));
	for (Class<?> basePackageClass : basePackageClasses) {
		packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
	}
	if (packagesToScan.isEmpty()) {
		return Collections
				.singleton(ClassUtils.getPackageName(metadata.getClassName()));
	}
	return packagesToScan;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:EntityScanRegistrar.java

示例4: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
	AnnotationAttributes attributes = AnnotationAttributes.fromMap(
			metadata.getAnnotationAttributes(EntityScan.class.getName()));
	String[] basePackages = attributes.getStringArray("basePackages");
	Class<?>[] basePackageClasses = attributes
			.getClassArray("basePackageClasses");
	Set<String> packagesToScan = new LinkedHashSet<String>();
	packagesToScan.addAll(Arrays.asList(basePackages));
	for (Class<?> basePackageClass : basePackageClasses) {
		packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
	}
	if (packagesToScan.isEmpty()) {
		String packageName = ClassUtils.getPackageName(metadata.getClassName());
		Assert.state(!StringUtils.isEmpty(packageName),
				"@EntityScan cannot be used with the default package");
		return Collections.singleton(packageName);
	}
	return packagesToScan;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:EntityScanPackages.java

示例5: getBasePackages

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
public static String[] getBasePackages(AnnotationAttributes attributes, String[] defaultPackages) {
	
	String[] value = attributes.getStringArray("value");
	String[] basePackages = attributes.getStringArray(BASE_PACKAGES);
	Class<?>[] basePackageClasses = attributes.getClassArray(BASE_PACKAGE_CLASSES);

	// Default configuration - return package of annotated class
	if (value.length == 0 && basePackages.length == 0 && basePackageClasses.length == 0) {
		return defaultPackages;
	}

	Set<String> packages = new HashSet<String>();
	packages.addAll(Arrays.asList(value));
	packages.addAll(Arrays.asList(basePackages));

	for (Class<?> typeName : basePackageClasses) {
		packages.add(ClassUtils.getPackageName(typeName));
	}

	return packages.toArray(new String[] {});
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:22,代码来源:StoreUtils.java

示例6: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
	AnnotationAttributes attributes = AnnotationAttributes.fromMap(
			metadata.getAnnotationAttributes(ServletComponentScan.class.getName()));
	String[] value = attributes.getStringArray("value");
	String[] basePackages = attributes.getStringArray("basePackages");
	Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
	if (!ObjectUtils.isEmpty(value)) {
		Assert.state(ObjectUtils.isEmpty(basePackages),
				"@ServletComponentScan basePackages and value attributes are"
						+ " mutually exclusive");
	}
	Set<String> packagesToScan = new LinkedHashSet<String>();
	packagesToScan.addAll(Arrays.asList(value));
	packagesToScan.addAll(Arrays.asList(basePackages));
	for (Class<?> basePackageClass : basePackageClasses) {
		packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
	}
	if (packagesToScan.isEmpty()) {
		return Collections
				.singleton(ClassUtils.getPackageName(metadata.getClassName()));
	}
	return packagesToScan;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:24,代码来源:ServletComponentScanRegistrar.java

示例7: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
protected Set<String> getPackagesToScan(AnnotationMetadata metadata) {
	AnnotationAttributes attributes = AnnotationAttributes
			.fromMap(metadata.getAnnotationAttributes(this.annotationType.getName()));
	String[] value = attributes.getStringArray("value");
	String[] basePackages = attributes.getStringArray("basePackages");
	Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
	if (!ObjectUtils.isEmpty(value)) {
		Assert.state(ObjectUtils.isEmpty(basePackages),
				String.format(
						"@%s basePackages and value attributes are mutually exclusive",
						this.annotationType.getSimpleName()));
	}
	Set<String> packagesToScan = new LinkedHashSet<String>();
	packagesToScan.addAll(Arrays.asList(value));
	packagesToScan.addAll(Arrays.asList(basePackages));
	for (Class<?> basePackageClass : basePackageClasses) {
		packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
	}
	if (packagesToScan.isEmpty()) {
		return Collections
				.singleton(ClassUtils.getPackageName(metadata.getClassName()));
	}
	return packagesToScan;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:25,代码来源:AbstractEntityScanRegistrar.java

示例8: AbstractTemplateProvider

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
public AbstractTemplateProvider(AnnotationAttributes attributes) {
    Assert.notNull(attributes, "AnnotationAttributes must not be null!");
    this.excludeClasses = attributes.getClassArray(getExcludeClasses());
    this.postfix = attributes.getString(getPostfix());
    this.debug = attributes.getBoolean("debug");
    this.overwrite = attributes.getBoolean("overwrite");
    if (excludeClasses.length > 0 && debug) {
        SDLogger.debug(String.format("Exclude %s %s in the %s generator", excludeClasses.length, excludeClasses.length == 1 ? "entity":"entities", postfix));
    }
}
 
开发者ID:cmeza20,项目名称:spring-data-generator,代码行数:11,代码来源:AbstractTemplateProvider.java

示例9: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private static Set<String> getPackagesToScan(AnnotationAttributes attributes) {
	String[] basePackages = attributes.getStringArray("basePackages");
	Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
	Set<String> packagesToScan = new LinkedHashSet<>();
	packagesToScan.addAll(Arrays.asList(basePackages));
	for (Class<?> basePackageClass : basePackageClasses) {
		packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
	}
	return packagesToScan;
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:11,代码来源:JpaEntityScanPackages.java

示例10: registerBeanDefinitions

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Override
	public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
		AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableSpringSeedJpa.class.getName()));
		String propertyPrefix = attributes.getString("propertyPrefix");
		String beanNamePrefix =  attributes.getString("beanNamePrefix");
		Class<?>[] entityPackages = attributes.getClassArray("baseEntityClasses");

/*
		//There are two ways to register bean dynamically in Spring.
 		DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)this.beanFactory;

		DataSource dataSource = JpaBuilderUtil.newDataSource(environment, prefix);
		beanFactory.registerSingleton(prefix + DataSource.class.getSimpleName(), dataSource);

		EntityManagerFactory entityManagerFactory = JpaBuilderUtil.newEntityManagerFactory(dataSource, entityPackages);
		beanFactory.registerSingleton(prefix + "entityManager", entityManagerFactory);

		PlatformTransactionManager platformTransactionManager = JpaBuilderUtil.newPlatformTransactionManager(entityManagerFactory);
		beanFactory.registerSingleton(prefix + "transactionManager", platformTransactionManager);
*/

		BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Dbcp2DataSourceFactoryBean.class)
			.addPropertyValue("prefix", propertyPrefix)
			.addPropertyValue("environment", this.environment)
			.setDestroyMethodName("close");
		String dataSourceName = beanNamePrefix.isEmpty()? "dataSource": beanNamePrefix + "DataSource";
		registry.registerBeanDefinition(dataSourceName, builder.getBeanDefinition());

		BeanDefinitionBuilder builderEntity = BeanDefinitionBuilder.genericBeanDefinition(EntityManagerFactoryFactoryBean.class)
			.addPropertyReference("dataSource", dataSourceName)
			.addPropertyValue("entityPackages", entityPackages);
		String entityManagerFactoryName = beanNamePrefix.isEmpty()? "entityManagerFactory": beanNamePrefix + "EntityManagerFactory";
		registry.registerBeanDefinition(entityManagerFactoryName, builderEntity.getBeanDefinition());

		BeanDefinitionBuilder builderTrans = BeanDefinitionBuilder.genericBeanDefinition(JpaTransactionManagerFactoryBean.class)
			.addPropertyReference("entityManagerFactory",entityManagerFactoryName);
		String transactionManagerName = beanNamePrefix.isEmpty()? "transactionManager": beanNamePrefix + "TransactionManager";
		registry.registerBeanDefinition(transactionManagerName, builderTrans.getBeanDefinition());
	}
 
开发者ID:profullstack,项目名称:spring-seed,代码行数:40,代码来源:SpringSeedJpa.java

示例11: addBasePakcages

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private String[] addBasePakcages(AnnotationMetadata metadata,
                                 AnnotationAttributes attrs) {
    List<String> basePkgs = new ArrayList<String>();
    addBasePackages(attrs, basePkgs, "value");
    addBasePackages(attrs, basePkgs, "basePackages");
    for (val clz : attrs.getClassArray("basePackageClasses")) {
        basePkgs.add(ClassUtils.getPackageName(clz));
    }

    if (basePkgs.isEmpty()) {
        basePkgs.add(ClassUtils.getPackageName(metadata.getClassName()));
    }

    return StringUtils.toStringArray(basePkgs);
}
 
开发者ID:bingoohuang,项目名称:westcache,代码行数:16,代码来源:WestCacheableScannerRegistrar.java

示例12: directlyAnnotatedWithImport

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
@Test
public void directlyAnnotatedWithImport() {
	AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
	ctx.register(ImportingConfig.class);
	ctx.refresh();
	assertNotNull(ctx.getBean("importedConfigBean"));

	ImportedConfig importAwareConfig = ctx.getBean(ImportedConfig.class);
	AnnotationMetadata importMetadata = importAwareConfig.importMetadata;
	assertThat("import metadata was not injected", importMetadata, notNullValue());
	assertThat(importMetadata.getClassName(), is(ImportingConfig.class.getName()));
	AnnotationAttributes importAttribs = AnnotationConfigUtils.attributesFor(importMetadata, Import.class);
	Class<?>[] importedClasses = importAttribs.getClassArray("value");
	assertThat(importedClasses[0].getName(), is(ImportedConfig.class.getName()));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ImportAwareTests.java

示例13: assertMetaAnnotationOverrides

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
private void assertMetaAnnotationOverrides(AnnotationMetadata metadata) {
	AnnotationAttributes attributes = (AnnotationAttributes) metadata.getAnnotationAttributes(
			TestComponentScan.class.getName(), false);
	String[] basePackages = attributes.getStringArray("basePackages");
	assertThat("length of basePackages[]", basePackages.length, is(1));
	assertThat("basePackages[0]", basePackages[0], is("org.example.componentscan"));
	String[] value = attributes.getStringArray("value");
	assertThat("length of value[]", value.length, is(0));
	Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
	assertThat("length of basePackageClasses[]", basePackageClasses.length, is(0));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:AnnotationMetadataTests.java

示例14: getPackagesToScan

import org.springframework.core.annotation.AnnotationAttributes; //导入方法依赖的package包/类
/**
 * Inspects the packages to be scanned for {@link RetrofitService} interfaces from the {@link RetrofitServiceScan}
 * import annotation.
 *
 * @param metadata the annotation metadata.
 * @return a set of packages to be scanned for {@link RetrofitService} candidates.
 */
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(RetrofitServiceScan.class.getName()));

    String[] value = attributes.getStringArray("value");
    String[] basePackages = attributes.getStringArray("basePackages");
    Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");

    if (!ObjectUtils.isEmpty(value)) {
        Assert.state(ObjectUtils.isEmpty(basePackages),
                "@RetrofitServiceScan basePackages and value attributes are mutually exclusive");
    }

    Set<String> packagesToScan = new LinkedHashSet<String>();
    packagesToScan.addAll(Arrays.asList(value));
    packagesToScan.addAll(Arrays.asList(basePackages));

    for (Class<?> basePackageClass : basePackageClasses) {
        packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
    }

    if (packagesToScan.isEmpty()) {
        return Collections.singleton(ClassUtils.getPackageName(metadata.getClassName()));
    }

    return packagesToScan;
}
 
开发者ID:troinine,项目名称:spring-boot-square-oss-support,代码行数:35,代码来源:RetrofitServiceFactoryBeanRegistrar.java

示例15: 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


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