org.directwebremoting.dwrp
Class BaseCallMarshaller

java.lang.Object
  extended by org.directwebremoting.dwrp.BaseCallMarshaller
All Implemented Interfaces:
Marshaller
Direct Known Subclasses:
HtmlCallMarshaller, PlainCallMarshaller

public abstract class BaseCallMarshaller
extends java.lang.Object
implements Marshaller

A Marshaller that output plain Javascript. This marshaller can be tweaked to output Javascript in an HTML context. This class works in concert with CallScriptConduit, they should be considered closely related and it is important to understand what one does while editing the other.

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

Nested Class Summary
protected  class BaseCallMarshaller.CallScriptConduit
          A ScriptConduit that works with the parent Marshaller.
 
Field Summary
protected  AccessControl accessControl
          The security manager
protected static java.lang.String ATTRIBUTE_BATCH
          How we stash away the results of the request parse
protected static java.lang.String ATTRIBUTE_CONDUIT
          How we stash away the conduit
protected static java.lang.String ATTRIBUTE_REQUEST
          How we stash away the request
protected  ConverterManager converterManager
          How we convert parameters
protected  CreatorManager creatorManager
          How we create new beans
protected  boolean crossDomainSessionSecurity
          To we perform cross-domain session security checks?
protected static Logger log
          The log stream
protected  PageNormalizer pageNormalizer
          How we turn pages into the canonical form.
protected  java.lang.String sessionCookieName
          The session cookie name
 
Constructor Summary
BaseCallMarshaller()
           
 
Method Summary
protected abstract  java.lang.String getOutboundMimeType()
          What mime type should we send to the browser for this data?
 boolean isConvertable(java.lang.Class paramType)
          Check if we can coerce the given type
 void marshallException(HttpServletRequest request, HttpServletResponse response, java.lang.Exception ex)
          Try to find a batchId to send to the client so it knows what broke
 Calls marshallInbound(HttpServletRequest request, HttpServletResponse response)
          Marshall an incomming HttpRequest into an abstract Calls POJO that defines the functions that we need to call.
 void marshallOutbound(Replies replies, HttpServletRequest request, HttpServletResponse response)
          Marshall the return values from executing this batch of requests.
protected abstract  void sendOutboundScriptPrefix(java.io.PrintWriter out, java.lang.String batchId)
          iframe mode starts as HTML, so get into script mode
protected abstract  void sendOutboundScriptSuffix(java.io.PrintWriter out, java.lang.String batchId)
          iframe mode needs to get out of script mode
protected abstract  void sendScript(java.io.PrintWriter out, java.lang.String script)
          Send a script to the browser
 void setAccessControl(AccessControl accessControl)
          Accessor for the security manager
 void setAllowGetForSafariButMakeForgeryEasier(boolean allowGetForSafariButMakeForgeryEasier)
           
 void setConverterManager(ConverterManager converterManager)
          Accessor for the DefaultCreatorManager that we configure
 void setCreatorManager(CreatorManager creatorManager)
          Accessor for the DefaultCreatorManager that we configure
 void setCrossDomainSessionSecurity(boolean crossDomainSessionSecurity)
          To we perform cross-domain session security checks?
 void setPageNormalizer(PageNormalizer pageNormalizer)
          Accessor for the PageNormalizer.
 void setSessionCookieName(java.lang.String sessionCookieName)
          Alter the session cookie name from the default JSESSIONID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionCookieName

protected java.lang.String sessionCookieName
The session cookie name


crossDomainSessionSecurity

protected boolean crossDomainSessionSecurity
To we perform cross-domain session security checks?


pageNormalizer

protected PageNormalizer pageNormalizer
How we turn pages into the canonical form.


converterManager

protected ConverterManager converterManager
How we convert parameters


creatorManager

protected CreatorManager creatorManager
How we create new beans


accessControl

protected AccessControl accessControl
The security manager


ATTRIBUTE_REQUEST

protected static final java.lang.String ATTRIBUTE_REQUEST
How we stash away the request

See Also:
Constant Field Values

ATTRIBUTE_CONDUIT

protected static final java.lang.String ATTRIBUTE_CONDUIT
How we stash away the conduit

See Also:
Constant Field Values

ATTRIBUTE_BATCH

protected static final java.lang.String ATTRIBUTE_BATCH
How we stash away the results of the request parse

See Also:
Constant Field Values

log

protected static final Logger log
The log stream

Constructor Detail

BaseCallMarshaller

public BaseCallMarshaller()
Method Detail

marshallInbound

public Calls marshallInbound(HttpServletRequest request,
                             HttpServletResponse response)
                      throws java.io.IOException,
                             ServerException
Description copied from interface: Marshaller
Marshall an incomming HttpRequest into an abstract Calls POJO that defines the functions that we need to call.

Specified by:
marshallInbound in interface Marshaller
Parameters:
request - The incoming Http request
response - An Ajax response, XML, JSON, Javascript, etc.
Returns:
Data specifying the methods to call
Throws:
java.io.IOException - If the connection breaks
ServerException - If an error occurs during parsing

marshallOutbound

public void marshallOutbound(Replies replies,
                             HttpServletRequest request,
                             HttpServletResponse response)
                      throws java.io.IOException
Description copied from interface: Marshaller
Marshall the return values from executing this batch of requests.

Specified by:
marshallOutbound in interface Marshaller
Parameters:
replies - The objects to convert into a reply
request - The incoming Http request
response - An Ajax response, XML, JSON, Javascript, etc.
Throws:
java.io.IOException - If the connection breaks

marshallException

public void marshallException(HttpServletRequest request,
                              HttpServletResponse response,
                              java.lang.Exception ex)
                       throws java.io.IOException
Description copied from interface: Marshaller
Try to find a batchId to send to the client so it knows what broke

Specified by:
marshallException in interface Marshaller
Parameters:
request - The incoming Http request
response - An Ajax response, XML, JSON, Javascript, etc.
ex - The exception that we wish to propogate to the client
Throws:
java.io.IOException - If writing to the output stream fails

sendScript

protected abstract void sendScript(java.io.PrintWriter out,
                                   java.lang.String script)
                            throws java.io.IOException
Send a script to the browser

Parameters:
out - The stream to write to
script - The script to send
Throws:
java.io.IOException - If the write fails

getOutboundMimeType

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

Returns:
A mime-type

sendOutboundScriptPrefix

protected abstract void sendOutboundScriptPrefix(java.io.PrintWriter out,
                                                 java.lang.String batchId)
                                          throws java.io.IOException
iframe mode starts as HTML, so get into script mode

Parameters:
out - The stream to write to
batchId - The batch identifier so we can prepare the environment
Throws:
java.io.IOException - If the write fails

sendOutboundScriptSuffix

protected abstract void sendOutboundScriptSuffix(java.io.PrintWriter out,
                                                 java.lang.String batchId)
                                          throws java.io.IOException
iframe mode needs to get out of script mode

Parameters:
out - The stream to write to
batchId - The batch identifier so we can prepare the environment
Throws:
java.io.IOException - If the write fails

isConvertable

public boolean isConvertable(java.lang.Class paramType)
Description copied from interface: Marshaller
Check if we can coerce the given type

Specified by:
isConvertable in interface Marshaller
Parameters:
paramType - The type to check
Returns:
true iff paramType is coercable

setConverterManager

public void setConverterManager(ConverterManager converterManager)
Accessor for the DefaultCreatorManager that we configure

Parameters:
converterManager - The new DefaultConverterManager

setCreatorManager

public void setCreatorManager(CreatorManager creatorManager)
Accessor for the DefaultCreatorManager that we configure

Parameters:
creatorManager - The new DefaultConverterManager

setAccessControl

public void setAccessControl(AccessControl accessControl)
Accessor for the security manager

Parameters:
accessControl - The accessControl to set.

setPageNormalizer

public void setPageNormalizer(PageNormalizer pageNormalizer)
Accessor for the PageNormalizer.

Parameters:
pageNormalizer - The new PageNormalizer

setCrossDomainSessionSecurity

public void setCrossDomainSessionSecurity(boolean crossDomainSessionSecurity)
To we perform cross-domain session security checks?

Parameters:
crossDomainSessionSecurity - the cross domain session security setting

setAllowGetForSafariButMakeForgeryEasier

public void setAllowGetForSafariButMakeForgeryEasier(boolean allowGetForSafariButMakeForgeryEasier)
Parameters:
allowGetForSafariButMakeForgeryEasier - Do we reduce security to help Safari

setSessionCookieName

public void setSessionCookieName(java.lang.String sessionCookieName)
Alter the session cookie name from the default JSESSIONID.

Parameters:
sessionCookieName - the sessionCookieName to set