Skip to content

Commit 33c4c3d

Browse files
@initial 7.0.0-preview.417.2 Allow config not auto save
1 parent 452456c commit 33c4c3d

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/main/java/com/talexframe/frame/core/modules/plugins/adapt/config/json/JSONConfigAdapter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ protected boolean injectWithInstance(PluginScanner scanner, WebPlugin webPlugin,
9797
for( Field field : clz.getDeclaredFields() ) {
9898

9999
TVConfig fieldAnno = field.getAnnotation(TVConfig.class);
100+
if( fieldAnno == null ) continue;
101+
100102
String name = StrUtil.isBlankIfStr(fieldAnno.name()) ? field.getName() : fieldAnno.name();
101103

102104
field.setAccessible(true);
@@ -121,7 +123,8 @@ protected boolean injectWithInstance(PluginScanner scanner, WebPlugin webPlugin,
121123

122124
}
123125

124-
map.put( clz, instance );
126+
if( classAnno == null || !classAnno.disable() )
127+
map.put( clz, instance );
125128

126129
return true;
127130
}
@@ -170,6 +173,9 @@ public boolean logoutInstance(PluginScanner scanner, WebPlugin webPlugin, Class<
170173
for( Field field : clazz.getDeclaredFields() ) {
171174

172175
TVConfig fieldAnno = field.getAnnotation(TVConfig.class);
176+
if( fieldAnno == null ) continue;
177+
if( fieldAnno.disable() ) continue;
178+
173179
String name = StrUtil.isBlankIfStr(fieldAnno.name()) ? field.getName() : fieldAnno.name();
174180

175181
Object value = field.get( config );

src/main/java/com/talexframe/frame/core/modules/plugins/adapt/config/yaml/YamlConfigAdapter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ protected boolean injectWithInstance(PluginScanner scanner, WebPlugin webPlugin,
103103
for( Field field : clz.getDeclaredFields() ) {
104104

105105
TVConfig fieldAnno = field.getAnnotation(TVConfig.class);
106+
if( fieldAnno == null ) continue;
107+
106108
String name = StrUtil.isBlankIfStr(fieldAnno.name()) ? field.getName() : fieldAnno.name();
107109

108110
field.setAccessible(true);
@@ -133,7 +135,8 @@ protected boolean injectWithInstance(PluginScanner scanner, WebPlugin webPlugin,
133135

134136
}
135137

136-
map.put( clz, instance );
138+
if( classAnno == null || !classAnno.disable() )
139+
map.put( clz, instance );
137140

138141
return true;
139142
}
@@ -182,6 +185,10 @@ public boolean logoutInstance(PluginScanner scanner, WebPlugin webPlugin, Class<
182185
for( Field field : clazz.getDeclaredFields() ) {
183186

184187
TVConfig fieldAnno = field.getAnnotation(TVConfig.class);
188+
189+
if( fieldAnno == null ) continue;
190+
if( fieldAnno.disable() ) continue;
191+
185192
String name = StrUtil.isBlankIfStr(fieldAnno.name()) ? field.getName() : fieldAnno.name();
186193

187194
Object value = field.get( config );

src/main/java/com/talexframe/frame/core/pojo/annotations/TVConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,11 @@
2727
*/
2828
boolean ignore() default false;
2929

30+
/**
31+
* 禁止保存
32+
* 是否禁止保存(部分)字段
33+
*
34+
*/
35+
boolean disable() default false;
36+
3037
}

0 commit comments

Comments
 (0)