本文整理匯總了Java中org.springframework.core.annotation.AnnotationAttributes.getAnnotationArray方法的典型用法代碼示例。如果您正苦於以下問題:Java AnnotationAttributes.getAnnotationArray方法的具體用法?Java AnnotationAttributes.getAnnotationArray怎麽用?Java AnnotationAttributes.getAnnotationArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.core.annotation.AnnotationAttributes
的用法示例。
在下文中一共展示了AnnotationAttributes.getAnnotationArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setImportMetadata
import org.springframework.core.annotation.AnnotationAttributes; //導入方法依賴的package包/類
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
AnnotationAttributes attributes = AnnotationAttributes.fromMap(importMetadata.getAnnotationAttributes(EnableSpringSeedRedis.class.getName()));
this.defaultExpiration = attributes.getNumber("defaultExpiration").longValue();
this.propertyPrefix = attributes.getString("propertyPrefix");
AnnotationAttributes[] annotationAttributes = attributes.getAnnotationArray("cacheExpirations");
for(AnnotationAttributes a: annotationAttributes){
expiresMap.put(a.getString("value"), a.getNumber("expiration").longValue());
}
this.clearBeforeStart = attributes.getBoolean("clearBeforeStart");
}
示例2: parseFilters
import org.springframework.core.annotation.AnnotationAttributes; //導入方法依賴的package包/類
private Set<TypeFilter> parseFilters(AnnotationMetadata annotation,
String attributeName) {
Set<TypeFilter> result = new HashSet<TypeFilter>();
AnnotationAttributes attributes = new AnnotationAttributes(
annotation.getAnnotationAttributes(GuiceModule.class.getName()));
AnnotationAttributes[] filters = attributes.getAnnotationArray(attributeName);
for (AnnotationAttributes filter : filters) {
result.addAll(typeFiltersFor(filter));
}
return result;
}
示例3: initMongoDataSource
import org.springframework.core.annotation.AnnotationAttributes; //導入方法依賴的package包/類
private void initMongoDataSource(AnnotationAttributes attributes) {
AnnotationAttributes[] dataSources = attributes.getAnnotationArray(DATA_SOURCE_ATTRIBUTE_NAME);
if (null == dataSources || dataSources.length == 0) {
throw new CannotGetMongoDbConnectionException("can't find any datasource!");
}
String defaultMongoURIBeanName = "";
List<String> mongoURIBeanNames = new ArrayList<>(dataSources.length);
for (int i = 0; i < dataSources.length; i++) {
AnnotationAttributes attr = dataSources[i];
String name = attr.getString("value");
BeanDefinition dsBeanDefinition = new MongoDataSourceBeanDefinitionFactory(name).build();
if (i == 0) {
defaultMongoURIBeanName = name;
}
BEAN_DEFINITION_MAP.put(name, dsBeanDefinition);
mongoURIBeanNames.add(name);
}
BeanDefinitionBuilder dynamicMongoConnection = BeanDefinitionBuilder.genericBeanDefinition(DynamicMongoConnection.class);
dynamicMongoConnection.addConstructorArgValue(mongoURIBeanNames);
dynamicMongoConnection.addConstructorArgValue(defaultMongoURIBeanName);
BEAN_DEFINITION_MAP.put(DATA_SOURCE_BEAN_NAME, dynamicMongoConnection.getBeanDefinition());
}
示例4: findMyBatisBeanDefinitions
import org.springframework.core.annotation.AnnotationAttributes; //導入方法依賴的package包/類
private Map<String, BeanDefinition> findMyBatisBeanDefinitions() {
String[] enumsLocations = attributes.getStringArray(Constant.ENUMS_LOCATIONS_ATTRIBUTE_NAME);
String[] basePackages = attributes.getStringArray(Constant.BASE_PACKAGES_ATTRIBUTE_NAME);
AnnotationAttributes[] plugins = attributes.getAnnotationArray(Constant.PLUGINS_ATTRIBUTE_NAME);
if (ArrayUtils.isEmpty(enumsLocations)) {
enumsLocations = findDefaultPackage(metadata);
}
if (ArrayUtils.isEmpty(basePackages)) {
basePackages = findDefaultPackage(metadata);
}
Map<String, BeanDefinition> beanDefinitions = new HashMap<>(16);
BeanDefinitionBuilder sqlSessionFactoryBean = BeanDefinitionBuilder.genericBeanDefinition(SqlSessionFactoryBean.class);
if (useFlyway) {
sqlSessionFactoryBean.addDependsOn(Constant.FLYWAY_BEAN_NAME);
}
sqlSessionFactoryBean.addPropertyReference("dataSource", Constant.DATA_SOURCE_BEAN_NAME);
sqlSessionFactoryBean.addPropertyValue("mapperLocations", "classpath*:/META-INF/mybatis/**/*Mapper.xml");
sqlSessionFactoryBean.addPropertyValue("configLocation", "classpath:/META-INF/mybatis/mybatis.xml");
TypeHandlerScanner scanner = new TypeHandlerScanner();
sqlSessionFactoryBean.addPropertyValue("typeHandlers", scanner.find(StringUtils.join(enumsLocations, ",")));
List<Interceptor> pluginsList = new ArrayList<>(plugins.length);
List<Class<? extends Interceptor>> clazz = new ArrayList<>(plugins.length);
for (AnnotationAttributes plugin : plugins) {
Class<? extends Interceptor> pluginClass = plugin.getClass("value");
AnnotationAttributes[] params = plugin.getAnnotationArray("params");
clazz.add(pluginClass);
Interceptor interceptor = BeanUtils.instantiate(pluginClass);
BeanWrapper beanWrapper = new BeanWrapperImpl(interceptor);
for (AnnotationAttributes param : params) {
String key = param.getString("key");
String value = param.getString("value");
PropertyDescriptor descriptor = beanWrapper.getPropertyDescriptor(key);
Method writeMethod = descriptor.getWriteMethod();
Method readMethod = descriptor.getReadMethod();
writeMethod.setAccessible(true);
try {
Class<?> returnType = readMethod.getReturnType();
Object valueObject = value;
if (Integer.class.equals(returnType) || int.class.equals(returnType)) {
valueObject = Integer.valueOf(value);
} else if (Long.class.equals(returnType) || long.class.equals(returnType)) {
valueObject = Long.valueOf(value);
} else if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) {
valueObject = Boolean.valueOf(value);
} else if (Double.class.equals(returnType) || double.class.equals(returnType)) {
valueObject = Double.valueOf(value);
}
writeMethod.invoke(interceptor, valueObject);
} catch (Exception e) {
e.printStackTrace();
}
}
pluginsList.add(interceptor);
}
if (!clazz.contains(PaginationInterceptor.class)) {
pluginsList.add(BeanUtils.instantiate(PaginationInterceptor.class));
}
sqlSessionFactoryBean.addPropertyValue("plugins", pluginsList);
BeanDefinitionBuilder scannerConfigurerBean = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
scannerConfigurerBean.addPropertyValue("basePackage", StringUtils.join(basePackages, ","));
scannerConfigurerBean.addPropertyValue("annotationClass", Repository.class);
scannerConfigurerBean.addPropertyValue("sqlSessionFactoryBeanName", "sqlSessionFactory");
beanDefinitions.put("sqlSessionFactory", sqlSessionFactoryBean.getBeanDefinition());
beanDefinitions.put("mapperScannerConfigurer", scannerConfigurerBean.getBeanDefinition());
return beanDefinitions;
}