20
20
import java .nio .file .Path ;
21
21
import java .nio .file .SimpleFileVisitor ;
22
22
import java .nio .file .attribute .BasicFileAttributes ;
23
- import java .util .*;
23
+ import java .util .ArrayList ;
24
+ import java .util .Date ;
25
+ import java .util .HashMap ;
26
+ import java .util .HashSet ;
27
+ import java .util .List ;
28
+ import java .util .Map ;
29
+ import java .util .Set ;
24
30
import java .util .concurrent .ConcurrentHashMap ;
25
31
import java .util .function .Function ;
26
32
import java .util .stream .Collectors ;
@@ -75,10 +81,6 @@ public static void regediter(String groupName) {
75
81
76
82
/**
77
83
* 创建监控
78
- *
79
- * @param file
80
- * @param groupFileListener
81
- * @return
82
84
*/
83
85
private static FileAlterationMonitor createMonitor (File file , GroupFileListener groupFileListener ) {
84
86
FileAlterationObserver observer = new FileAlterationObserver (file , null , null );
@@ -270,22 +272,22 @@ private synchronized void createTask(File file) throws CodeException {
270
272
this .onFileChange (file );
271
273
} else {
272
274
273
- ClassDoc parse = null ;
275
+ ClassDoc parse = null ;
274
276
275
277
try {
276
278
parse = JavaDocUtil .parse (content );
277
279
} catch (Exception e ) {
278
- throw new CodeException (e ) ;
280
+ throw new CodeException (e );
279
281
}
280
282
281
283
task = new Task ();
282
284
task .setCode (content );
283
285
task .setCreateUser ("admin" );
284
286
285
- if (parse .getScheduleStr ()!= null ){
287
+ if (parse .getScheduleStr () != null ) {
286
288
task .setType (2 );
287
289
task .setScheduleStr (parse .getScheduleStr ());
288
- }else {
290
+ } else {
289
291
task .setType (1 );
290
292
}
291
293
@@ -340,6 +342,13 @@ public void onFileChange(File file) {
340
342
return ;
341
343
}
342
344
345
+ try {
346
+ JavaDocUtil .compile (fCode .replace ((char )65307 ,'错' )) ;
347
+ }catch (Exception e ){
348
+ printLog (String .format ("path:%s className:%s can not to compile, so skip save:%s..................................................................." , file .getAbsoluteFile (), task .getName (), fileName ));
349
+ return ;
350
+ }
351
+
343
352
StaticValue .getSystemIoc ().get (TaskService .class , "taskService" ).saveOrUpdate (task );
344
353
flush (task .getName ());
345
354
taskFileMap .put (fileName , file );
@@ -356,9 +365,6 @@ public void onFileChange(File file) {
356
365
357
366
/**
358
367
* 刷新這個類
359
- *
360
- * @param taskName
361
- * @throws Exception
362
368
*/
363
369
private void flush (String taskName ) {
364
370
Set <String > taskNames = new HashSet <>(1 );
0 commit comments