org.directwebremoting.extend
Class ScriptConduit

java.lang.Object
  extended by org.directwebremoting.extend.ScriptConduit
All Implemented Interfaces:
java.lang.Comparable<ScriptConduit>
Direct Known Subclasses:
BaseScriptConduit, BayeuxScriptConduit

public abstract class ScriptConduit
extends java.lang.Object
implements java.lang.Comparable<ScriptConduit>

While a Marshaller is processing a request it can register a ScriptConduit with the ScriptSession to say - pass scripts straight to me and bypass the temporary storage area. This interface allows this to happen.

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

Field Summary
static int RANK_FAST
          Indicates that this ScriptConduit is a very good way of getting scripts to the client and should be used as a preferred method
static int RANK_PROCEDURAL
          Indicates that this ScriptConduit is used for control-flow and will probably not actually convey the script, but does need to tell someone else about it
static int RANK_SLOW
          Indicates that this ScriptConduit is a poor way of getting scripts to the client and should only be used as a last resort.
 
Constructor Summary
ScriptConduit(int rank, boolean holdingConnectionToBrowser)
          All ScriptConduit need a rank
 
Method Summary
abstract  boolean addScript(ScriptBuffer script)
          Add a script to the list bound for remote execution.
 int compareTo(ScriptConduit that)
           
 boolean equals(java.lang.Object obj)
           
 int getRank()
          ScriptConduits have a rank that indicates the priority order in which we should send scripts to them.
 int hashCode()
           
 boolean isHoldingConnectionToBrowser()
          Is this conduit a fake one for tracking things, or does it represent a real long term open connection?
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RANK_PROCEDURAL

public static final int RANK_PROCEDURAL
Indicates that this ScriptConduit is used for control-flow and will probably not actually convey the script, but does need to tell someone else about it

See Also:
Constant Field Values

RANK_FAST

public static final int RANK_FAST
Indicates that this ScriptConduit is a very good way of getting scripts to the client and should be used as a preferred method

See Also:
Constant Field Values

RANK_SLOW

public static final int RANK_SLOW
Indicates that this ScriptConduit is a poor way of getting scripts to the client and should only be used as a last resort.

See Also:
Constant Field Values
Constructor Detail

ScriptConduit

public ScriptConduit(int rank,
                     boolean holdingConnectionToBrowser)
All ScriptConduit need a rank

Parameters:
rank - How does this ScriptConduit sort
holdingConnectionToBrowser - Is this conduit a fake one for tracking things, or does it represent a real long term open connection?
Method Detail

getRank

public int getRank()
ScriptConduits have a rank that indicates the priority order in which we should send scripts to them. The rank is a number from 1 to 10, and should only be one of the defined values: ScriptConduit.RANK_*.

Returns:
The rank of this ScriptConduit
See Also:
RANK_PROCEDURAL, RANK_FAST, RANK_SLOW

addScript

public abstract boolean addScript(ScriptBuffer script)
                           throws java.io.IOException,
                                  ConversionException
Add a script to the list bound for remote execution.

It is not an error to refuse to handle the script and return false, it just indicates that this ScriptConduit did not accept the script. If the ScriptConduit can no longer function then it should throw an exception and it will be assumed to be no longer useful. If you want to implement this method then you will probably be doing something like calling ServletOutputStream.print(String) and passing in the results of calling ScriptBufferUtil.createOutput().

Parameters:
script - The script to execute
Returns:
true if this ScriptConduit handled the script.
Throws:
java.io.IOException - If this conduit is broken and should not be used
ConversionException - If objects in the script can not be marshalled

isHoldingConnectionToBrowser

public boolean isHoldingConnectionToBrowser()
Is this conduit a fake one for tracking things, or does it represent a real long term open connection?


compareTo

public int compareTo(ScriptConduit that)
Specified by:
compareTo in interface java.lang.Comparable<ScriptConduit>

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2008