11package act .controller .meta ;
22
3+ import act .app .App ;
4+ import act .app .AppClassLoader ;
35import act .asm .Type ;
46import act .handler .builtin .controller .ControllerAction ;
57import act .handler .builtin .controller .Handler ;
@@ -205,27 +207,63 @@ public HandlerMethodMetaInfo handler(String name) {
205207 return handlerLookup .get (className () + "." + name );
206208 }
207209
208- public List <InterceptorMethodMetaInfo > beforeInterceptors () {
209- return interceptors .beforeList ();
210+ public List <InterceptorMethodMetaInfo > beforeInterceptors (App app ) {
211+ C .List <InterceptorMethodMetaInfo > list = C .newList ();
212+ AppClassLoader cl = app .classLoader ();
213+ for (String with : withList ) {
214+ ControllerClassMetaInfo withInfo = cl .controllerClassMetaInfo (with );
215+ if (null != withInfo ) {
216+ list .addAll (withInfo .beforeInterceptors (app ));
217+ }
218+ }
219+ list .addAll (interceptors .beforeList ());
220+ return list ;
210221 }
211222
212- public List <InterceptorMethodMetaInfo > afterInterceptors () {
213- return interceptors .afterList ();
223+ public List <InterceptorMethodMetaInfo > afterInterceptors (App app ) {
224+ C .List <InterceptorMethodMetaInfo > list = C .newList ();
225+ AppClassLoader cl = app .classLoader ();
226+ for (String with : withList ) {
227+ ControllerClassMetaInfo withInfo = cl .controllerClassMetaInfo (with );
228+ if (null != withInfo ) {
229+ list .addAll (withInfo .afterInterceptors (app ));
230+ }
231+ }
232+ list .addAll (interceptors .afterList ());
233+ return list ;
214234 }
215235
216- public List <CatchMethodMetaInfo > exceptionInterceptors () {
217- return interceptors .catchList ();
236+ public List <CatchMethodMetaInfo > exceptionInterceptors (App app ) {
237+ C .List <CatchMethodMetaInfo > list = C .newList ();
238+ AppClassLoader cl = app .classLoader ();
239+ for (String with : withList ) {
240+ ControllerClassMetaInfo withInfo = cl .controllerClassMetaInfo (with );
241+ if (null != withInfo ) {
242+ list .addAll (withInfo .exceptionInterceptors (app ));
243+ }
244+ }
245+ list .addAll (interceptors .catchList ());
246+ return list ;
218247 }
219248
220- public List <InterceptorMethodMetaInfo > finallyInterceptors () {
221- return interceptors .finallyList ();
249+ public List <InterceptorMethodMetaInfo > finallyInterceptors (App app ) {
250+ C .List <InterceptorMethodMetaInfo > list = C .newList ();
251+ AppClassLoader cl = app .classLoader ();
252+ for (String with : withList ) {
253+ ControllerClassMetaInfo withInfo = cl .controllerClassMetaInfo (with );
254+ if (null != withInfo ) {
255+ list .addAll (withInfo .finallyInterceptors (app ));
256+ }
257+ }
258+ list .addAll (interceptors .finallyList ());
259+ return list ;
222260 }
223261
224- public ControllerClassMetaInfo merge (ControllerClassMetaInfoManager infoBase ) {
225- mergeFromWithList (infoBase );
262+ public ControllerClassMetaInfo merge (ControllerClassMetaInfoManager infoBase , App app ) {
263+ mergeFromWithList (infoBase , app );
226264 mergeIntoActionList ();
227265 buildActionLookup ();
228- buildHandlerLookup ();
266+ buildHandlerLookup (app );
229267 return this ;
230268 }
231269
@@ -258,13 +296,13 @@ private void getAllWithList(Set<String> withList, ControllerClassMetaInfoManager
258296 }
259297 }
260298
261- private void mergeFromWithList (ControllerClassMetaInfoManager infoBase ) {
299+ private void mergeFromWithList (ControllerClassMetaInfoManager infoBase , App app ) {
262300 C .Set <String > withClasses = C .newSet ();
263301 getAllWithList (withClasses , infoBase );
264302 for (String withClass : withClasses ) {
265303 ControllerClassMetaInfo withClassInfo = infoBase .controllerMetaInfo (withClass );
266304 if (null != withClassInfo ) {
267- withClassInfo .merge (infoBase );
305+ withClassInfo .merge (infoBase , app );
268306 interceptors .mergeFrom (withClassInfo .interceptors );
269307 } else {
270308 logger .warn ("Cannot find class info for @With class: %s" , withClass );
@@ -286,19 +324,19 @@ private void buildActionLookup() {
286324 actionLookup = lookup ;
287325 }
288326
289- private void buildHandlerLookup () {
327+ private void buildHandlerLookup (App app ) {
290328 C .Map <String , HandlerMethodMetaInfo > lookup = C .newMap ();
291329 lookup .putAll (actionLookup );
292- for (InterceptorMethodMetaInfo info : beforeInterceptors ()) {
330+ for (InterceptorMethodMetaInfo info : beforeInterceptors (app )) {
293331 lookup .put (info .fullName (), info );
294332 }
295- for (InterceptorMethodMetaInfo info : afterInterceptors ()) {
333+ for (InterceptorMethodMetaInfo info : afterInterceptors (app )) {
296334 lookup .put (info .fullName (), info );
297335 }
298- for (InterceptorMethodMetaInfo info : exceptionInterceptors ()) {
336+ for (InterceptorMethodMetaInfo info : exceptionInterceptors (app )) {
299337 lookup .put (info .fullName (), info );
300338 }
301- for (InterceptorMethodMetaInfo info : finallyInterceptors ()) {
339+ for (InterceptorMethodMetaInfo info : finallyInterceptors (app )) {
302340 lookup .put (info .fullName (), info );
303341 }
304342 handlerLookup = lookup ;
0 commit comments