/** * Handles this context with handlers. */ public void handle() { try { for (handleIndex++; handleIndex < handlers.size(); handleIndex++) { handlers.get(handleIndex).handle(this); } } catch (final Exception e) { final String requestLog = Requests.getLog(request); LOGGER.log(Level.ERROR, "Handler process failed: " + requestLog, e); setRenderer(new Http500Renderer(e)); } }
/** * Gets the remote address of request. * * @return remote address */ public String remoteAddr() { return Requests.getRemoteAddr(request); }
/** * Builds pagination request with the specified path. * * @param path the specified path, see {@link #PAGINATION_PATH_PATTERN} * for the details * @return pagination request json object, for example, * <pre> * { * "paginationCurrentPageNum": int, * "paginationPageSize": int, * "paginationWindowSize": int * } * </pre> * @see #PAGINATION_PATH_PATTERN */ public static JSONObject buildPaginationRequest(final String path) { final Integer currentPageNum = getCurrentPageNum(path); final Integer pageSize = getPageSize(path); final Integer windowSize = getWindowSize(path); final JSONObject ret = new JSONObject(); ret.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, currentPageNum); ret.put(Pagination.PAGINATION_PAGE_SIZE, pageSize); ret.put(Pagination.PAGINATION_WINDOW_SIZE, windowSize); return ret; }
/** * Logs the specified request with the specified level and logger. * <p> * Logging information of the specified request includes: * <ul> * <li>method</li> * <li>URL</li> * <li>content type</li> * <li>character encoding</li> * <li>local (address, port, name)</li> * <li>remote (address, port, host)</li> * <li>headers</li> * </ul> * * @param httpServletRequest the specified HTTP servlet request * @param level the specified logging level * @param logger the specified logger */ public static void log(final HttpServletRequest httpServletRequest, final Level level, final Logger logger) { if (!logger.isLoggable(level)) { return; } logger.log(level, getLog(httpServletRequest)); }
logBuilder.append(indents).append(indents).append("name=").append(httpServletRequest.getLocalName()).append("],").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append("remote=[").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append(indents).append("addr=").append(getRemoteAddr(httpServletRequest)).append(",").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append(indents).append("port=").append(httpServletRequest.getRemotePort()).append(",").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append(indents).append("host=").append(httpServletRequest.getRemoteHost()).append("],").append(Strings.LINE_SEPARATOR);
final String requestLog = Requests.getLog(request); LOGGER.log(Level.ERROR, "Renders template [" + templateName + "] failed [" + requestLog + "]", e);
/** * Gets the remote address of request. * * @return remote address */ public String remoteAddr() { return Requests.getRemoteAddr(request); }
/** * nextHandler. */ public void nextHandler() { if (ihandlerIterable.hasNext()) { try { ihandlerIterable.next().handle(httpRequestContext, this); } catch (final Exception e) { final HttpServletRequest request = httpRequestContext.getRequest(); final String log = Requests.getLog(request); LOGGER.log(Level.ERROR, log + " processing failed ", e); } } } }
logBuilder.append(indents).append(indents).append("name=").append(httpServletRequest.getLocalName()).append("],").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append("remote=[").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append(indents).append("addr=").append(getRemoteAddr(httpServletRequest)).append(",").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append(indents).append("port=").append(httpServletRequest.getRemotePort()).append(",").append(Strings.LINE_SEPARATOR); logBuilder.append(indents).append(indents).append("host=").append(httpServletRequest.getRemoteHost()).append("],").append(Strings.LINE_SEPARATOR);
/** * Logs the specified request with the specified level and logger. * <p> * Logging information of the specified request includes: * <ul> * <li>method</li> * <li>URL</li> * <li>content type</li> * <li>character encoding</li> * <li>local (address, port, name)</li> * <li>remote (address, port, host)</li> * <li>headers</li> * </ul> * * @param httpServletRequest the specified HTTP servlet request * @param level the specified logging level * @param logger the specified logger */ public static void log(final HttpServletRequest httpServletRequest, final Level level, final Logger logger) { if (!logger.isLoggable(level)) { return; } logger.log(level, getLog(httpServletRequest)); }
final String requestLog = Requests.getLog(request); LOGGER.log(Level.ERROR, "Renders template [" + templateName + "] failed [" + requestLog + "]", e);