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