| 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.Method; |
| 19 | |
import java.util.Map; |
| 20 | |
|
| 21 | |
import org.seasar.framework.beans.BeanDesc; |
| 22 | |
import org.seasar.framework.container.ComponentDef; |
| 23 | |
import org.seasar.framework.container.S2Container; |
| 24 | |
import org.seasar.framework.util.tiger.CollectionsUtil; |
| 25 | |
import org.seasar.teeda.extension.annotation.transition.Redirect; |
| 26 | |
import org.seasar.teeda.extension.html.RedirectDesc; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 2 | public class TigerRedirectDescAnnotationHandler extends |
| 33 | |
ConstantRedirectDescAnnotationHandler { |
| 34 | |
|
| 35 | |
@SuppressWarnings("unchecked") |
| 36 | |
@Override |
| 37 | |
protected Map getRedirectDescs(final S2Container container, |
| 38 | |
final ComponentDef componentDef, final Class componentClass, |
| 39 | |
final String componentName, final BeanDesc beanDesc) { |
| 40 | 1 | final Map<String, RedirectDesc> ret = CollectionsUtil.newHashMap(); |
| 41 | 14 | for (final Method method : componentClass.getMethods()) { |
| 42 | 13 | if (method.isBridge() || method.isSynthetic()) { |
| 43 | 0 | continue; |
| 44 | |
} |
| 45 | 13 | final String methodName = method.getName(); |
| 46 | 13 | if (!methodName.equals("initialize") |
| 47 | |
&& !methodName.equals("prerender") |
| 48 | |
&& !methodName.startsWith("do")) { |
| 49 | 9 | continue; |
| 50 | |
} |
| 51 | 4 | final Redirect redirect = method.getAnnotation(Redirect.class); |
| 52 | 4 | if (redirect == null) { |
| 53 | 0 | continue; |
| 54 | |
} |
| 55 | 4 | final RedirectDesc redirectDesc = createRedirectDesc(redirect |
| 56 | |
.protocol().getExternalForm(), redirect.port()); |
| 57 | 4 | ret.put(methodName, redirectDesc); |
| 58 | |
} |
| 59 | 1 | final Map<String, RedirectDesc> m = super.getRedirectDescs(container, |
| 60 | |
componentDef, componentClass, componentName, beanDesc); |
| 61 | 1 | if (!m.isEmpty()) { |
| 62 | 1 | ret.putAll(m); |
| 63 | |
} |
| 64 | 1 | return ret; |
| 65 | |
} |
| 66 | |
} |