12
12
import org .nlpcn .jcoder .run .mvc .cache .CacheEntry ;
13
13
import org .nlpcn .jcoder .scheduler .ThreadManager ;
14
14
import org .nlpcn .jcoder .util .DateUtils ;
15
+ import org .nlpcn .jcoder .util .Restful ;
15
16
import org .nlpcn .jcoder .util .StaticValue ;
16
17
import org .nutz .lang .Lang ;
17
18
import org .nutz .mvc .ActionContext ;
@@ -34,30 +35,32 @@ public void init(NutConfig config, ActionInfo ai) throws Throwable {
34
35
}
35
36
36
37
public void process (ActionContext ac ) throws Throwable {
37
-
38
- if (ac .getRequest ().getParameter ("_clean_cache" ) != null ){
39
- cacheEntry = null ;
38
+
39
+ if (ac .getRequest ().getParameter ("_clean_cache" ) != null ) {
40
+ ac .setMethodReturn (Restful .OK );
41
+ cacheEntry = null ;
42
+ doNext (ac );
43
+ return ;
40
44
}
41
45
42
46
if (ac .getRequest ().getParameter ("_rpc_init" ) != null ) {
43
47
ac .setMethodReturn (StaticValue .okMessage ("rpc init ok" ));
44
48
doNext (ac );
45
49
return ;
46
50
}
47
-
51
+
48
52
String threadName = null ;
49
53
Task module = (Task ) ac .getModule ();
50
54
Method method = ac .getMethod ();
51
55
Object [] args = ac .getMethodArgs ();
52
-
53
-
54
56
55
57
if (!module .codeInfo ().getExecuteMethod (method .getName ()).isRestful ()) {
56
58
throw new IllegalAccessException (module .getName () + "/" + method .getName () + " is not public by restful" );
57
59
}
58
-
60
+
59
61
try {
60
- threadName = module .getName () + "@" + method .getName () + "@" + ac .getRequest ().getRemoteAddr () + "@" + DateUtils .formatDate (new Date (), "yyyyMMddHHmmss" ) + "@" + al .getAndIncrement ();
62
+ threadName = module .getName () + "@" + method .getName () + "@" + ac .getRequest ().getRemoteAddr () + "@" + DateUtils .formatDate (new Date (), "yyyyMMddHHmmss" ) + "@"
63
+ + al .getAndIncrement ();
61
64
ThreadManager .add2ActionTask (threadName , Thread .currentThread ());
62
65
Object result = executeByCache (module , method , args );
63
66
ac .setMethodReturn (result );
@@ -75,6 +78,7 @@ public void process(ActionContext ac) throws Throwable {
75
78
76
79
/**
77
80
* 执行一个task,利用缓存,rpc框架也调用这个
81
+ *
78
82
* @param task
79
83
* @param method
80
84
* @param args
0 commit comments