1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.logic.interceptor;
17
18 import java.util.Iterator;
19 import java.util.Map;
20
21 import org.aopalliance.intercept.MethodInterceptor;
22 import org.aopalliance.intercept.MethodInvocation;
23 import org.seasar.tuigwaa.logic.TgwFunction;
24 import org.seasar.tuigwaa.util.TgwContext;
25
26 import com.isenshi.util.TableMap;
27
28 public class PageViewInterceptorImpl implements PageViewInterceptor,
29 MethodInterceptor {
30
31 private TableMap functionTableMap = new TableMap();
32
33 public void deregisterAction(String siteName, String pageName,
34 String logicName) {
35 functionTableMap.remove(siteName + "/" + pageName, logicName);
36 }
37
38 public void registerAction(String siteName, String pageName,
39 String logicName, TgwFunction tfunction) {
40 functionTableMap.put(tfunction, siteName + "/" + pageName, logicName);
41 }
42
43 public Object invoke(MethodInvocation invocation) throws Throwable {
44
45 String siteName = TgwContext.getSiteName();
46 String pageName = TgwContext.getPageName();
47 String path = siteName + "/" + pageName;
48
49 Map funcMap = functionTableMap.getSubMap(path);
50
51 if (funcMap != null) {
52 for(Iterator i=funcMap.values().iterator();i.hasNext();){
53 TgwFunction func = (TgwFunction)i.next();
54 func.run(null);
55 }
56 }
57 return invocation.proceed();
58 }
59 }