private void endChunk() throws IOException { conduit.endChunk(); // Flush and check errors out.flush(); if (out.checkError()) { throw new IOException("Stream write error"); } response.flushBuffer(); }
private void endStreamAndChunk() throws Exception { conduit.endStreamAndChunk(); }
/** * Marshall a Script without worrying about MarshallExceptions */ public void addScriptHandleExceptions(ScriptConduit conduit, ScriptBuffer script) throws IOException { try { conduit.sendScript(ScriptBufferUtil.createOutput(script, converterManager, jsonOutput)); } catch (ConversionException ex) { log.warn("Error marshalling exception. Is the exception converter configured?", ex); } }
response.setContentType(conduit.getOutboundMimeType()); if (passiveReverseAjax) conduit.beginStreamAndChunk(); conduit.sendScript(EnginePrivate.getRemoteHandleReverseAjaxScript(script.getIndex(), "")); nextScriptIndex = script.getIndex() + 1; script = scriptSession.getScript(nextScriptIndex); if (script != null && script.getScript() instanceof String) { conduit.sendScript(EnginePrivate.getRemoteHandleReverseAjaxScript(script.getIndex(), (String) script.getScript())); nextScriptIndex = script.getIndex() + 1; } else { scriptBuf = EnginePrivate.getRemoteHandleCallbackScript(batchId, callId, data); conduit.sendScript(ScriptBufferUtil.createOutput(scriptBuf, converterManager, jsonOutput)); conduit.endStreamAndChunk();
public void marshallException(HttpServletRequest request, HttpServletResponse response, ScriptConduit conduit, Exception ex, boolean sendPrefix) throws IOException { String batchId = null; String instanceId = "0"; String documentDomain = null; Batch batch = (Batch) request.getAttribute(ATTRIBUTE_BATCH); if (batch != null) { batchId = batch.getBatchId(); instanceId = batch.getInstanceId(); documentDomain = batch.getDocumentDomain(); } PrintWriter out = response.getWriter(); if (conduit == null) { conduit = createScriptConduit(out, instanceId, batchId, documentDomain); } response.setContentType(conduit.getOutboundMimeType()); if (sendPrefix) { conduit.beginStreamAndChunk(); } String script = EnginePrivate.getRemoteHandleBatchExceptionScript(batchId, ex); out.println(script); conduit.endStreamAndChunk(); }
private void beginStreamAndChunk() throws Exception { response.setContentType(conduit.getOutboundMimeType()); // If there is a runnable for beginning of response then run it RealScriptSession.Script script = scriptSession.getScript(nextScriptIndex); boolean beginningRunnable = false; if (script != null && script.getScript() instanceof Runnable) { try { ((Runnable) script.getScript()).run(); } catch(Exception ex) { log.error("Exception when executing Script Runnable.", ex); } beginningRunnable = true; } // Send stream prefix conduit.beginStreamAndChunk(); // Send confirmation for the runnable to client after stream prefix if (beginningRunnable) { conduit.sendScript(EnginePrivate.getRemoteHandleReverseAjaxScript(script.getIndex(), "")); nextScriptIndex = script.getIndex() + 1; } }
private void sendPollReply() throws ConversionException, IOException { ScriptBuffer script = EnginePrivate.getRemoteHandleCallbackScript(batchId, "0", disconnectedTime); conduit.sendScript(ScriptBufferUtil.createOutput(script, converterManager, jsonOutput)); }
private void sendNewChunkScripts() throws Exception { // Scripts while(true) { RealScriptSession.Script script = scriptSession.getScript(nextScriptIndex); if (script != null && script.getScript() instanceof String) { conduit.sendScript(EnginePrivate.getRemoteHandleReverseAjaxScript(script.getIndex(), (String) script.getScript())); nextScriptIndex = script.getIndex() + 1; } else { break; } } }