1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.extension.annotation.handler; |
17 | |
|
18 | |
import java.lang.reflect.Field; |
19 | |
import java.util.Map; |
20 | |
|
21 | |
import org.seasar.framework.beans.BeanDesc; |
22 | |
import org.seasar.teeda.extension.ExtensionConstants; |
23 | |
import org.seasar.teeda.extension.annotation.scope.PageScope; |
24 | |
import org.seasar.teeda.extension.annotation.scope.RedirectScope; |
25 | |
import org.seasar.teeda.extension.annotation.scope.SubapplicationScope; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 2 | public class TigerScopeAnnotationHandler extends ConstantScopeAnnotationHandler { |
32 | |
|
33 | |
@Override |
34 | |
@SuppressWarnings("unchecked") |
35 | |
public void setupPropertyScopes(BeanDesc beanDesc, Map scopes) { |
36 | 4 | for (int i = 0; i < beanDesc.getFieldSize(); ++i) { |
37 | 3 | Field field = beanDesc.getField(i); |
38 | 3 | handlePageScope(field, scopes); |
39 | 3 | handleRedirectScope(field, scopes); |
40 | 3 | handleSubapplicationScope(field, scopes); |
41 | |
} |
42 | 1 | super.setupPropertyScopes(beanDesc, scopes); |
43 | 1 | } |
44 | |
|
45 | |
protected void handlePageScope(Field field, Map<String, Integer> scopes) { |
46 | 3 | PageScope pageScope = field.getAnnotation(PageScope.class); |
47 | 3 | if (pageScope != null) { |
48 | 1 | scopes.put(field.getName(), ExtensionConstants.PAGE_SCOPE); |
49 | |
} |
50 | 3 | } |
51 | |
|
52 | |
protected void handleRedirectScope(Field field, Map<String, Integer> scopes) { |
53 | 3 | RedirectScope redirectScope = field.getAnnotation(RedirectScope.class); |
54 | 3 | if (redirectScope != null) { |
55 | 1 | scopes.put(field.getName(), ExtensionConstants.REDIRECT_SCOPE); |
56 | |
} |
57 | 3 | } |
58 | |
|
59 | |
protected void handleSubapplicationScope(Field field, |
60 | |
Map<String, Integer> scopes) { |
61 | 3 | SubapplicationScope subapplicationScope = field |
62 | |
.getAnnotation(SubapplicationScope.class); |
63 | 3 | if (subapplicationScope != null) { |
64 | 1 | scopes.put(field.getName(), ExtensionConstants.SUBAPP_SCOPE); |
65 | |
} |
66 | 3 | } |
67 | |
|
68 | |
} |