public Geometry run() throws ProofFailureException { if (!geometries.isEmpty()) { try { init(); Operation operator; Geometry rhs = geometries .pop(); // the far rhs of the geometry / the basis of the OperationalGeometry. Order // Shouldn't matter though while (!running_geometries.isEmpty()) { rhs = running_geometries.pop(); if (!running_operations.isEmpty()) { operator = running_operations.pop(); Geometry lhs = running_geometries.pop(); Action a = actions.get(operator); rhs = a.act(lhs, rhs); } else throw new ProofFailureException("INTERNAL: Mismatched Operator and Geometry Tables"); } flush(); return rhs; } catch (GeometricFailure e) { throw new ProofFailureException("Inter"); } } else throw new ProofFailureException("INTERNAL: This Machine Contains No Geometry."); }
/** * Updates the actor based on time. Typically this is called each frame by {@link * Stage#act(float)}. * * <p>The default implementation calls {@link Action#act(float)} on each action and removes * actions that are complete. * * @param delta Time in seconds since the last frame. */ public void act(float delta) { for (int i = 0, n = actions.size; i < n; i++) { Action action = actions.get(i); if (action.act(delta)) { actions.removeIndex(i); action.setActor(null); i--; n--; } } }
/** @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; // 全程使用utf-8 setCharset("utf-8", req, resp); String requrl = req.getRequestURI(); // requrl = (requrl == null) ? "" : requrl.substring(1); String[] pathArr = requrl.split("\\/"); int rn = rootNum + 1; // [root]为默认Action String actName = (pathArr.length <= rn) ? "[root]" : pathArr[rn]; // TODO 过滤静态请求,此处如果配合前端的web server过滤可省去 if (staticPath.containsKey(actName)) { // String encoding = req.getHeader("Accept-Encoding"); // if (encoding != null && encoding.indexOf("gzip") != -1){ // HttpServletResponseWrapper wrapper = new GZIPServletResponseWrapper(resp); // chain.doFilter(req, wrapper); // wrapper.getOutputStream().close(); // }else{ // chain.doFilter(request, response); // } chain.doFilter(request, response); return; } if (isStop) { // FIXME 穿透控制,注意这里一定要加ip控制 if (req.getParameter("keelcontrolsall") == null) { resp.setStatus(500); resp.getWriter().print("System under maintenance, please come back later."); return; } } // chain.doFilter(request, response); try { // pathArr[0]为域名,pathArr[1]为第一个路径,后面继续为路径,最后面为参数 // String[] pathArr = requrl.substring(requrl.indexOf("//")+2).split("\\/"); // int rn = 1+rootNum; // String actName = (pathArr.length <= rn) ? "" : pathArr[rn]; ActionMsg msg = new HttpActionMsg(actName, req, resp); Action action = ActionManager.findAction(actName); if (action == null) { // 如果存在以*为name的Action,则此Action为默认Action,可匹配所有未匹配到的Action请求 if (hasDefaultAction) { // 加入actName,以便defaultAction使用 msg.addData("[actName]", actName); action = this.defaultAction; } else { resp.setStatus(404); resp.getWriter().print("404 - 2"); return; } } msg.addData("[pathArr]", pathArr); // msg.addData("[prefix]", staticPrefix); // 执行action msg = action.act(msg); // 不处理 if (msg.getData("[none]") != null) { return; } // 是否打印 else if (msg.getData("[print]") != null) { resp.getWriter().print(msg.getData("[print]")); return; } // 是否发向JSP else if (msg.getData("[jsp]") != null) { String to = (String) msg.getData("[jsp]"); // Object o = msg.getData("[jspAttr]"); // if (o != null) { // req.setAttribute("[jspAttr]", o); // } req.setAttribute("[jspAttr]", msg); RequestDispatcher rd = req.getRequestDispatcher(to); rd.forward(req, resp); return; } // 是否本地跳转 else if (msg.getData("[redirect]") != null) { String redirect = KFilter.getPrefix() + (String) msg.getData("[redirect]"); resp.sendRedirect(redirect); return; } // 是否直接跳转 else if (msg.getData("[goto]") != null) { String link = (String) msg.getData("[goto]"); resp.sendRedirect(link); return; } // 继续走chain // else if(msg.getData("[chain]") != null){ // chain.doFilter(request, response); // return; // } else { resp.setStatus(404); // resp.getWriter().print("404 - 3"); return; } } catch (Exception e) { log.error("KFilter error!", e); resp.setStatus(404); resp.getWriter().print("500 - Error! please contact [email protected] "); return; } }