2
2
3
3
import lombok .SneakyThrows ;
4
4
import lombok .extern .slf4j .Slf4j ;
5
+ import org .fusesource .jansi .Ansi ;
5
6
import org .springframework .boot .ApplicationArguments ;
6
7
import org .springframework .boot .ApplicationRunner ;
7
8
import org .springframework .core .annotation .Order ;
26
27
import java .util .*;
27
28
import java .util .concurrent .atomic .AtomicInteger ;
28
29
30
+ import static org .fusesource .jansi .Ansi .ansi ;
31
+
29
32
/**
30
33
* @author YuePeng
31
34
* date 9/28/18.
@@ -54,7 +57,7 @@ public static EruptModel getErupt(String eruptName) {
54
57
if (null == ERUPTS .get (eruptName )) {
55
58
return null ;
56
59
} else {
57
- return EruptCoreService .initEruptModel (ERUPTS .get (eruptName ).getClazz ());
60
+ return EruptCoreService .initEruptModel (ERUPTS .get (eruptName ).getClazz (), false );
58
61
}
59
62
} else {
60
63
return ERUPTS .get (eruptName );
@@ -66,7 +69,7 @@ public static void registerErupt(Class<?> eruptClazz) {
66
69
if (ERUPTS .containsKey (eruptClazz .getSimpleName ())) {
67
70
throw new RuntimeException (eruptClazz .getSimpleName () + " conflict !" );
68
71
}
69
- EruptModel eruptModel = initEruptModel (eruptClazz );
72
+ EruptModel eruptModel = initEruptModel (eruptClazz , true );
70
73
ERUPTS .put (eruptClazz .getSimpleName (), eruptModel );
71
74
ERUPT_LIST .add (eruptModel );
72
75
}
@@ -91,15 +94,15 @@ public static EruptModel getEruptView(String eruptName) {
91
94
return em ;
92
95
}
93
96
94
- private static EruptModel initEruptModel (Class <?> clazz ) {
97
+ private static EruptModel initEruptModel (Class <?> clazz , boolean starting ) {
95
98
// erupt class data to memory
96
99
EruptModel eruptModel = new EruptModel (clazz );
97
100
// erupt field data to memory
98
101
eruptModel .setEruptFieldModels (new ArrayList <>());
99
102
eruptModel .setEruptFieldMap (new LinkedCaseInsensitiveMap <>());
100
103
ReflectUtil .findClassAllFields (clazz , field -> Optional .ofNullable (field .getAnnotation (EruptField .class ))
101
104
.ifPresent (ignore -> {
102
- EruptFieldModel eruptFieldModel = new EruptFieldModel (field );
105
+ EruptFieldModel eruptFieldModel = new EruptFieldModel (field , starting );
103
106
eruptModel .getEruptFieldModels ().add (eruptFieldModel );
104
107
if (!eruptModel .getEruptFieldMap ().containsKey (field .getName ())) {
105
108
eruptModel .getEruptFieldMap ().put (field .getName (), eruptFieldModel );
@@ -119,20 +122,19 @@ public void run(ApplicationArguments args) {
119
122
EruptSpringUtil .scannerPackage (EruptApplication .getScanPackage (), new TypeFilter []{
120
123
new AnnotationTypeFilter (Erupt .class )
121
124
}, clazz -> {
122
- EruptModel eruptModel = initEruptModel (clazz );
125
+ EruptModel eruptModel = initEruptModel (clazz , true );
123
126
ERUPTS .put (clazz .getSimpleName (), eruptModel );
124
127
ERUPT_LIST .add (eruptModel );
125
128
});
126
- log .info ("<" + repeat ("===" , 20 ) + ">" );
129
+ log .info ("<{}>" , repeat ("===" , 20 ));
127
130
AtomicInteger moduleMaxCharLength = new AtomicInteger ();
128
131
EruptModuleInvoke .invoke (it -> {
129
132
int length = it .info ().getName ().length ();
130
133
if (length > moduleMaxCharLength .get ()) moduleMaxCharLength .set (length );
131
134
});
132
- // if (eruptProp.isHotBuild()) {
133
- // hotBuild = eruptProp.isHotBuild();
134
- // log.info(ansi().fg(Ansi.Color.RED).a("Erupt Hot Build").reset().toString());
135
- // }
135
+ if (EruptSpringUtil .getBean (EruptProp .class ).isHotBuild ()) {
136
+ log .warn (ansi ().fg (Ansi .Color .RED ).a ("Open erupt hot build" ).reset ().toString ());
137
+ }
136
138
EruptModuleInvoke .invoke (it -> {
137
139
it .run ();
138
140
MODULES .add (it .info ().getName ());
@@ -143,7 +145,7 @@ public void run(ApplicationArguments args) {
143
145
log .info ("Erupt modules : {}" , MODULES .size ());
144
146
log .info ("Erupt classes : {}" , ERUPTS .size ());
145
147
log .info ("Erupt Framework initialization completed in {}ms" , totalRecorder .recorder ());
146
- log .info ("<" + repeat ("===" , 20 ) + ">" );
148
+ log .info ("<{}>" , repeat ("===" , 20 ));
147
149
}
148
150
149
151
private String fillCharacter (String character , int targetWidth ) {
0 commit comments