ctx.setInterceptors(config.getInterceptors(LifecycleStage.HandlerResolution));
return ctx.wrap( new Interceptor() {
public Resolution intercept(ExecutionContext ctx) throws Exception {
ActionBean bean = ctx.getActionBean();
ActionBeanContext context = ctx.getActionBeanContext();
ActionResolver resolver = config.getActionResolver();
// Then lookup the event name and handler method etc.
String eventName = resolver.getEventName(bean.getClass(), context);
context.setEventName(eventName);
final Method handler;
if (eventName != null) {
handler = resolver.getHandler(bean.getClass(), eventName);
}
else {
handler = resolver.getDefaultHandler(bean.getClass());
if (handler != null) {
context.setEventName(resolver.getHandledEvent(handler));
}
}
// Insist that we have a handler
if (handler == null) {
throw new StripesServletException(
"No handler method found for request with ActionBean [" +
bean.getClass().getName() + "] and eventName [ " + eventName + "]");
}
log.debug("Resolved event: ", context.getEventName(), "; will invoke: ",
bean.getClass().getSimpleName(), ".", handler.getName(), "()");
ctx.setHandler(handler);
return null;
}