protected CommandContext createCommandContext(HttpServletRequest req, HttpServletResponse res) { CommandContext cc = new CommandContext(); cc.put(HttpServletRequest.class.getName(), req); cc.put(HttpServletResponse.class.getName(), res); return cc; }
protected final ResponsibleMessage handleRequest(HttpServletRequest req, HttpServletResponse res) throws Exception { getLogger().debug("Start Handle Command now."); CommandContext cc = createCommandContext(req, res); Command eCommand = null; try { eCommand = getCommand(req, res); Object result = this.cHandler.handle(cc, eCommand); return createSuccessResponsibleMessage(result); } catch (CommandHandleException eh) { getLogger().trace(eh); return createErrorResponsibleMessage(eh.getErrorCode(), eh.getMessage()); } catch (RuntimeException eh) { getLogger().trace(eh); return createErrorResponsibleMessage(500, eh.getMessage()); } catch (Exception eh) { final ResponsibleMessage localResponsibleMessage; getLogger().trace(eh); return createErrorResponsibleMessage(500, eh.getMessage()); } finally { cc.clear(); } }