1 16 package org.directwebremoting.dwrp; 17 18 import java.io.IOException ; 19 20 import javax.servlet.http.HttpServletResponse ; 21 22 import org.directwebremoting.ScriptBuffer; 23 import org.directwebremoting.extend.ConverterManager; 24 import org.directwebremoting.extend.EnginePrivate; 25 import org.directwebremoting.extend.MarshallException; 26 import org.directwebremoting.extend.ScriptBufferUtil; 27 import org.directwebremoting.util.MimeConstants; 28 29 33 public class Html4kScriptConduit extends BaseScriptConduit 34 { 35 43 public Html4kScriptConduit(HttpServletResponse response, int partialResponse, String batchId, ConverterManager converterManager) throws IOException 44 { 45 super(response, batchId, converterManager); 46 this.partialResponse = partialResponse; 47 } 48 49 52 protected String getOutboundMimeType() 53 { 54 return MimeConstants.MIME_HTML; 55 } 56 57 60 public void beginStream() 61 { 62 synchronized (out) 63 { 64 out.println("<html><body><pre>"); 65 out.println(ProtocolConstants.SCRIPT_START_MARKER); 66 out.println(EnginePrivate.remoteBeginIFrameResponse(batchId, false)); 67 out.println(ProtocolConstants.SCRIPT_END_MARKER); 68 } 69 } 70 71 74 public void endStream() 75 { 76 synchronized (out) 77 { 78 out.println(EnginePrivate.remoteEndIFrameResponse(batchId, false)); 79 out.println(ProtocolConstants.SCRIPT_START_MARKER); 80 out.println("</pre></body></html>"); 81 out.println(ProtocolConstants.SCRIPT_END_MARKER); 82 } 83 } 84 85 88 public boolean addScript(ScriptBuffer scriptBuffer) throws IOException , MarshallException 89 { 90 String script = ScriptBufferUtil.createOutput(scriptBuffer, converterManager); 91 92 synchronized (out) 93 { 94 out.println(ProtocolConstants.SCRIPT_START_MARKER); 95 out.println(script); 96 out.println(ProtocolConstants.SCRIPT_END_MARKER); 97 98 if (partialResponse == PollHandler.PARTIAL_RESPONSE_FLUSH) 99 { 100 out.print(fourKFlushData); 101 } 102 103 return flush(); 104 } 105 } 106 107 110 protected final int partialResponse; 111 } 112 | Popular Tags |