org.directwebremoting.dwrp
Class BaseScriptConduit

java.lang.Object
  extended by org.directwebremoting.extend.ScriptConduit
      extended by org.directwebremoting.dwrp.BaseScriptConduit
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
Html4kScriptConduit, HtmlScriptConduit, PlainScriptConduit

public abstract class BaseScriptConduit
extends ScriptConduit

A ScriptConduit that works with the parent Marshaller. In some ways this is nasty because it has access to essentially private parts of PollHandler, however there is nowhere sensible to store them within that class, so this is a hacky simplification.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
protected  BasicAlarm alarm
          An Alarm that goes off if something is badly broken
protected  java.lang.String batchId
          What is the ID of the request that we are responding to?
protected  ConverterManager converterManager
          How we convert parameters
protected  java.io.PrintWriter out
          The PrintWriter to send output to, and that we should synchronize against
protected  HttpServletResponse response
          Used to flush data to the output stream
 
Fields inherited from class org.directwebremoting.extend.ScriptConduit
RANK_FAST, RANK_PROCEDURAL, RANK_SLOW
 
Constructor Summary
BaseScriptConduit(HttpServletResponse response, java.lang.String batchId, ConverterManager converterManager)
          Simple ctor
 
Method Summary
protected abstract  void beginStream()
          Called when we are initially setting up the stream.
 void close(int timetoNextPoll)
          A poll has finished, get the client to call us back
protected abstract  void endStream()
          Called when we are shutting the stream down.
protected  boolean flush()
          Ensure that output we have done is written to the client
 org.directwebremoting.dwrp.Alarm getErrorAlarm()
           
protected abstract  java.lang.String getOutboundMimeType()
          What mime type should we send to the browser for this data?
 
Methods inherited from class org.directwebremoting.extend.ScriptConduit
addScript, compareTo, equals, getRank, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

converterManager

protected ConverterManager converterManager
How we convert parameters


response

protected final HttpServletResponse response
Used to flush data to the output stream


out

protected final java.io.PrintWriter out
The PrintWriter to send output to, and that we should synchronize against


batchId

protected final java.lang.String batchId
What is the ID of the request that we are responding to?


alarm

protected BasicAlarm alarm
An Alarm that goes off if something is badly broken

Constructor Detail

BaseScriptConduit

public BaseScriptConduit(HttpServletResponse response,
                         java.lang.String batchId,
                         ConverterManager converterManager)
                  throws java.io.IOException
Simple ctor

Parameters:
response - Used to flush output
batchId - The id of the batch that we are responding to
converterManager - How we convert objects to script
Throws:
java.io.IOException - If stream ops fail
Method Detail

getOutboundMimeType

protected abstract java.lang.String getOutboundMimeType()
What mime type should we send to the browser for this data?

Returns:
A mime-type

beginStream

protected abstract void beginStream()
Called when we are initially setting up the stream. This does not send any data to the client, just sets it up for data.

This method is always called exactly once in the lifetime of a conduit, after #preStreamSetup() and before any scripts are sent.


endStream

protected abstract void endStream()
Called when we are shutting the stream down.

This method is always called exactly once in the lifetime of a conduit, just before the stream is closed.


close

public void close(int timetoNextPoll)
           throws java.io.IOException
A poll has finished, get the client to call us back

Parameters:
timetoNextPoll - How long before we tell the browser to come back?
Throws:
java.io.IOException

flush

protected boolean flush()
Ensure that output we have done is written to the client

Returns:
true/false depending on the write status

getErrorAlarm

public org.directwebremoting.dwrp.Alarm getErrorAlarm()
Returns:
The Alarm that goes off if something is badly broken