Actionのカスタマイザーに独自の処理を追加したいときとか
アクションなどで共通で前処理を追加したいときに
この場合はpoint cutするメソッドのアノテーションがExecuteの場合
public class HogeCustomizer extends AbstractCustomizer { private MethodInterceptor interceptor = new MethodInterceptor() { public Object invoke(MethodInvocation invocation) throws Throwable { // 何かしらの共通処理とか return invocation.proceed(); } }; @Override protected void doCustomize(ComponentDef componentDef) { final Class<?> componentClass = componentDef.getComponentClass(); for (final Method method : componentClass.getMethods()) { if (method.isSynthetic() || method.isBridge()) { continue; } if (method.getDeclaringClass() == Object.class) { continue; } final Execute methodExecute = method.getAnnotation(Execute.class); if (methodExecute != null) { componentDef.addAspectDef(AspectDefFactory.createAspectDef(interceptor, method)); } } } } }
customizer.diconとかに
<initMethod name="addCustomizer"> <arg> <component class="HogeCustomizer"/> </arg> </initMethod>