List of usage examples for org.apache.commons.lang3.mutable MutableObject MutableObject
public MutableObject()
null
. From source file:org.siphon.d2js.D2jsRunner.java
public void run(HttpServletRequest request, HttpServletResponse response, String method) throws ServletException, IOException { String requestPath = getServletPath(request); String jsfile = request.getServletContext().getRealPath(requestPath); ScriptObjectMirror d2js = null;/* w w w . ja v a 2s . c om*/ try { d2js = d2jsManager.getD2js(jsfile, requestPath); if (d2js == null) { response.setStatus(404); PrintWriter out = response.getWriter(); out.print(request.getServletPath() + " not found"); out.flush(); return; } } catch (Exception e3) { logger.error("", e3); throw new ServletException(e3); } JsspRequest jsspRequest = new JsspRequest(request, engine); String params; try { params = getParams(jsspRequest); } catch (Exception e3) { response.setStatus(500); PrintWriter out = response.getWriter(); out.print("{\"error\":{\"message\" : \"params must be json\"}}"); out.flush(); return; } formatter.writeHttpHeader(response); JsspWriter out = null; //Task task = null; MutableObject<Task> taskDocker = new MutableObject<>(); try { out = new JsspWriter(response, engine); JsspSession session = new JsspSession(request.getSession()); // ? native ? JO ScrpiteObjectMirror ??? ((Invocable) engine).invokeFunction("processRequest", jsfile, method, params, jsspRequest, response, session, out, taskDocker); // d2js = (ScriptObjectMirror) d2js.callMember("clone"); // d2js.put("request", jsspRequest); // d2js.put("response", response); // d2js.put("session", session); // d2js.put("out", out); // d2js.put("task", task); // Object result = d2js.callMember(method, params); // if(JsTypeUtil.isNull(result)){ // out.print("{\"success\":true}"); // } else { // out.print(this.json.stringify(result)); // } // Task task = taskDocker.getValue(); if (task != null && task.getCallbacker() != null) { this.completeTask(taskDocker.getValue(), null); } } catch (Exception e) { try { Task task = taskDocker.getValue(); if (task != null && task.getCallbacker() != null) { this.completeTask(taskDocker.getValue(), e); } } catch (Exception e2) { logger.error("", e2); } Object ex = JsEngineUtil.parseJsException(e); if (ex instanceof Throwable == false) { boolean ignore = false; if (ex instanceof ScriptObjectMirror) { ScriptObjectMirror mex = (ScriptObjectMirror) ex; CharSequence name = (CharSequence) mex.get("name"); if ("ValidationError".equals(name) || "MultiError".equals(name)) { ignore = true; } } else if (ex instanceof ScriptObject) { ScriptObject oex = (ScriptObject) ex; CharSequence name = (CharSequence) oex.get("name"); if ("ValidationError".equals(name) || "MultiError".equals(name)) { ignore = true; } } if (!ignore) logger.error(json.tryStringify(ex), e); } else { logger.error("", (Throwable) ex); } try { out.print(formatter.formatException(ex, this.engine)); out.flush(); } catch (Exception e1) { logger.error("", e1); } } finally { out.flush(); } }
From source file:org.statefulj.framework.core.model.impl.StatefulFSMImpl.java
@Override public Object onEvent(T stateful, String event, Object... parms) throws TooBusyException { ArrayList<Object> parmList = new ArrayList<Object>(Arrays.asList(parms)); // Create a Mutable Object and add it to the Parameter List - it will be used // to return the returned value from the Controller as the FSM returns the State ///*www .ja va 2 s .c o m*/ MutableObject<T> returnValue = new MutableObject<T>(); ArrayList<Object> invokeParmlist = new ArrayList<Object>(parms.length + 1); invokeParmlist.add(returnValue); invokeParmlist.addAll(parmList); // Call the FSM // fsm.onEvent(stateful, event, invokeParmlist.toArray()); return returnValue.getValue(); }