mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-22 22:26:06 +00:00
feat[graalvm]: add Reflective annotation to storage
This commit is contained in:
@@ -253,16 +253,10 @@ public class StorageManager implements IStorageManager {
|
||||
private Resource scanResourceFile(Class<?> clazz) {
|
||||
var resourcePatternResolver = new PathMatchingResourcePatternResolver();
|
||||
var metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
|
||||
String fileName;
|
||||
if (clazz.getAnnotation(com.zfoo.storage.model.anno.Resource.class).value().equals("")
|
||||
&& clazz.getAnnotation(com.zfoo.storage.model.anno.Resource.class).alias().equals("")) {
|
||||
fileName = clazz.getSimpleName();
|
||||
} else {
|
||||
if (clazz.getAnnotation(com.zfoo.storage.model.anno.Resource.class).value().equals(""))
|
||||
fileName = clazz.getAnnotation(com.zfoo.storage.model.anno.Resource.class).alias();
|
||||
else
|
||||
fileName = clazz.getAnnotation(com.zfoo.storage.model.anno.Resource.class).value();
|
||||
}
|
||||
|
||||
var annoAlias = clazz.getAnnotation(com.zfoo.storage.model.anno.Resource.class).alias();
|
||||
var fileName = StringUtils.isEmpty(annoAlias) ? clazz.getSimpleName() : annoAlias;
|
||||
|
||||
try {
|
||||
// 一个class类只能匹配一个资源文件,如果匹配多个则会有歧义
|
||||
var resourceSet = new HashSet<Resource>();
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
package com.zfoo.storage.model.anno;
|
||||
|
||||
import org.springframework.aot.hint.annotation.Reflective;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
@@ -25,6 +27,7 @@ import java.lang.annotation.*;
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
@Reflective
|
||||
public @interface ResInjection {
|
||||
|
||||
String value() default "";
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.zfoo.storage.model.anno;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.aot.hint.annotation.Reflective;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -28,11 +28,7 @@ import java.lang.annotation.*;
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Reflective
|
||||
public @interface Resource {
|
||||
@AliasFor("alias")
|
||||
String value() default "";
|
||||
|
||||
|
||||
@AliasFor("value")
|
||||
String alias() default "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user