use of org.springframework.core.annotation.AnnotationAttributes in project dubbo-faker by moyada.
the class MonitorRegistrar method getBasePackages.
private String[] getBasePackages(AnnotationMetadata metadata) {
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableSharinganMonitor.class.getName()));
if (null == attributes) {
return null;
}
Set<String> packages = new HashSet<>();
String[] values = attributes.getStringArray("value");
for (String value : values) {
add(packages, value);
}
String[] basePackages = attributes.getStringArray("basePackages");
for (String basePackage : basePackages) {
add(packages, basePackage);
}
Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
for (Class<?> basePackageClass : basePackageClasses) {
add(packages, ClassUtils.getPackageName(basePackageClass));
}
if (packages.isEmpty()) {
add(packages, ClassUtils.getPackageName(metadata.getClassName()));
}
return packages.toArray(new String[0]);
}
use of org.springframework.core.annotation.AnnotationAttributes in project commons by terran4j.
the class DsqlRepositoryConfigRegistrar method registerBeanDefinitions.
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableDsqlRepositories.class.getName()));
Class<?>[] basePackageClasses = attributes.getClassArray("value");
if (basePackageClasses == null || basePackageClasses.length == 0) {
basePackageClasses = attributes.getClassArray("basePackageClasses");
}
if (registry instanceof DefaultListableBeanFactory) {
DefaultListableBeanFactory factory = (DefaultListableBeanFactory) registry;
if (beanFactory == null) {
// 缓存 beanFactory 对象。
beanFactory = factory;
}
registerBeanDefinitions(factory, basePackageClasses);
} else {
String msg = String.format("Current registry %s is NOT the class: %s, " + "maybe the Spring Version is incompatible.", registry.getClass(), DefaultListableBeanFactory.class);
throw new UnsupportedOperationException(msg);
}
}
use of org.springframework.core.annotation.AnnotationAttributes in project redisson by redisson.
the class RedissonWebSessionConfiguration method setImportMetadata.
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableRedissonWebSession.class.getName());
AnnotationAttributes attrs = AnnotationAttributes.fromMap(map);
keyPrefix = attrs.getString("keyPrefix");
maxInactiveIntervalInSeconds = attrs.getNumber("maxInactiveIntervalInSeconds");
}
use of org.springframework.core.annotation.AnnotationAttributes in project redisson by redisson.
the class RedissonHttpSessionConfiguration method setImportMetadata.
@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");
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-security by spring-projects.
the class GlobalMethodSecuritySelector method selectImports.
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
Class<EnableGlobalMethodSecurity> annoType = EnableGlobalMethodSecurity.class;
Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(annoType.getName(), false);
AnnotationAttributes attributes = AnnotationAttributes.fromMap(annotationAttributes);
Assert.notNull(attributes, () -> String.format("@%s is not present on importing class '%s' as expected", annoType.getSimpleName(), importingClassMetadata.getClassName()));
// TODO would be nice if could use BeanClassLoaderAware (does not work)
Class<?> importingClass = ClassUtils.resolveClassName(importingClassMetadata.getClassName(), ClassUtils.getDefaultClassLoader());
boolean skipMethodSecurityConfiguration = GlobalMethodSecurityConfiguration.class.isAssignableFrom(importingClass);
AdviceMode mode = attributes.getEnum("mode");
boolean isProxy = AdviceMode.PROXY == mode;
String autoProxyClassName = isProxy ? AutoProxyRegistrar.class.getName() : GlobalMethodSecurityAspectJAutoProxyRegistrar.class.getName();
boolean jsr250Enabled = attributes.getBoolean("jsr250Enabled");
List<String> classNames = new ArrayList<>(4);
if (isProxy) {
classNames.add(MethodSecurityMetadataSourceAdvisorRegistrar.class.getName());
}
classNames.add(autoProxyClassName);
if (!skipMethodSecurityConfiguration) {
classNames.add(GlobalMethodSecurityConfiguration.class.getName());
}
if (jsr250Enabled) {
classNames.add(Jsr250MetadataSourceConfiguration.class.getName());
}
return classNames.toArray(new String[0]);
}
Aggregations