com.vaadin.terminal.gwt.server.
Class AbstractCommunicationManager
java.lang.Object
com.vaadin.terminal.gwt.server.AbstractCommunicationManager
All Implemented Interfaces:
Direct Known Subclasses:
- extends Object
- implements Paintable.RepaintRequestListener, Serializable
public abstract class AbstractCommunicationManager
This is a common base class for the server-side implementations of the
communication system between the client code (compiled with GWT into
JavaScript) and the server side components. Its client side counterpart is
ApplicationConnection
.
A server side component sends its state to the client in a paint request (see
Paintable
and PaintTarget
on the server side). The client
widget receives these paint requests as calls to
com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL()
. The client
component communicates back to the server by sending a list of variable
changes (see ApplicationConnection#updateVariable()
and
VariableOwner.changeVariables(Object, Map)
).
TODO Document better!
See Also:
Nested Class Summary | |
---|---|
static interface |
AbstractCommunicationManager.Callback
TODO Document me! |
class |
AbstractCommunicationManager.ErrorHandlerErrorEvent
|
protected class |
AbstractCommunicationManager.InvalidUIDLSecurityKeyException
|
static interface |
AbstractCommunicationManager.Request
Generic interface of a (HTTP or Portlet) request to the application. |
static interface |
AbstractCommunicationManager.Response
Generic interface of a (HTTP or Portlet) response from the application. |
protected static interface |
AbstractCommunicationManager.Session
Generic wrapper interface for a (HTTP or Portlet) session. |
static class |
AbstractCommunicationManager.SimpleMultiPartInputStream
Stream that extracts content from another stream until the boundary string is encountered. |
class |
AbstractCommunicationManager.URIHandlerErrorImpl
Implementation of URIHandler.ErrorEvent interface. |
Field Summary | |
---|---|
static char |
VAR_ARRAYITEM_SEPARATOR
|
static char |
VAR_BURST_SEPARATOR
|
static char |
VAR_ESCAPE_CHARACTER
|
Constructor Summary | |
---|---|
AbstractCommunicationManager(Application application)
TODO New constructor - document me! |
Method Summary | |
---|---|
protected void |
changeVariables(Object source,
VariableOwner owner,
Map<String,Object> m)
|
protected abstract void |
cleanStreamVariable(VariableOwner owner,
String name)
|
protected void |
closeJsonMessage(PrintWriter outWriter)
|
protected String |
decodeVariableValue(String encodedValue)
Decode encoded burst, record, field and array item separator characters in a variable value String received from the client. |
protected Window |
doGetApplicationWindow(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Callback callback,
Application application,
Window assumedWindow)
TODO New method - document me! |
protected void |
doHandleSimpleMultipartFileUpload(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
StreamVariable streamVariable,
String variableName,
VariableOwner owner,
String boundary)
Method used to stream content from a multipart request (either from servlet or portlet request) to given StreamVariable |
protected void |
doHandleUidlRequest(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
AbstractCommunicationManager.Callback callback,
Window window)
Internally process a UIDL request from the client. |
protected void |
doHandleXhrFilePost(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
StreamVariable streamVariable,
String variableName,
VariableOwner owner,
int contentLength)
Used to stream plain file post (aka XHR2.post(File)) |
protected Application |
getApplication()
|
String |
getPaintableId(Paintable paintable)
Gets the Paintable Id. |
protected String |
getRequestPayload(AbstractCommunicationManager.Request request)
Reads the request data from the Request and returns it converted to an UTF-8 string. |
protected VariableOwner |
getVariableOwner(String string)
|
protected DownloadStream |
handleURI(Window window,
AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
AbstractCommunicationManager.Callback callback)
Calls the Window URI handler for a request and returns the DownloadStream returned by the handler. |
boolean |
handleVariableBurst(Object source,
Application app,
boolean success,
String burst)
|
boolean |
hasPaintableId(Paintable paintable)
|
protected void |
highlightPaintable(Paintable highLightedPaintable2)
|
boolean |
isProductionMode()
|
void |
makeAllPaintablesDirty(Window window)
|
protected void |
openJsonMessage(PrintWriter outWriter,
AbstractCommunicationManager.Response response)
Writes the opening of JSON message to be sent to client. |
protected void |
printHighlightedComponentHierarchy(StringBuilder sb,
AbstractComponent component)
|
void |
repaintRequested(Paintable.RepaintRequestEvent event)
Receives repaint request events. |
void |
requireLocale(String value)
Queues a locale to be sent to the client (browser) for date and time entry etc. |
protected void |
sendUploadResponse(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response)
TODO document |
void |
setProductionMode(boolean productionMode)
|
protected boolean |
streamToReceiver(InputStream in,
StreamVariable streamVariable,
String filename,
String type,
int contentLength)
|
protected void |
unregisterPaintable(Component p)
Called when communication manager stops listening for repaints for given component. |
void |
writeUidlResponce(AbstractCommunicationManager.Callback callback,
boolean repaintAll,
PrintWriter outWriter,
Window window,
boolean analyzeLayouts)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
VAR_BURST_SEPARATOR
public static final char VAR_BURST_SEPARATOR
See Also:
VAR_ARRAYITEM_SEPARATOR
public static final char VAR_ARRAYITEM_SEPARATOR
See Also:
VAR_ESCAPE_CHARACTER
public static final char VAR_ESCAPE_CHARACTER
See Also:
Constructor Detail |
---|
AbstractCommunicationManager
public AbstractCommunicationManager(Application application)
- Parameters:
application
-
TODO New constructor - document me!
Method Detail |
---|
getApplication
protected Application getApplication()
doHandleSimpleMultipartFileUpload
protected void doHandleSimpleMultipartFileUpload(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
StreamVariable streamVariable,
String variableName,
VariableOwner owner,
String boundary)
throws IOException
- Parameters:
request
-response
-streamVariable
-owner
-boundary
-- Throws:
IOException
Method used to stream content from a multipart request (either from servlet or portlet request) to given StreamVariable
doHandleXhrFilePost
protected void doHandleXhrFilePost(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
StreamVariable streamVariable,
String variableName,
VariableOwner owner,
int contentLength)
throws IOException
- Parameters:
request
-response
-streamVariable
-owner
-contentLength
-- Throws:
IOException
Used to stream plain file post (aka XHR2.post(File))
streamToReceiver
protected final boolean streamToReceiver(InputStream in,
StreamVariable streamVariable,
String filename,
String type,
int contentLength)
throws UploadException
- Parameters:
in
-streamVariable
-filename
-type
-contentLength
-- Returns:
- true if the streamvariable has informed that the terminal can forget this variable
- Throws:
UploadException
sendUploadResponse
protected void sendUploadResponse(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response)
throws IOException
- Parameters:
request
-response
-- Throws:
IOException
TODO document
doHandleUidlRequest
protected void doHandleUidlRequest(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
AbstractCommunicationManager.Callback callback,
Window window)
throws IOException,
AbstractCommunicationManager.InvalidUIDLSecurityKeyException
- Parameters:
request
-response
-callback
-window
- target window for the UIDL request, can be null if target not found- Throws:
IOException
AbstractCommunicationManager.InvalidUIDLSecurityKeyException
Internally process a UIDL request from the client.
This method calls
handleVariables(Request, Response, Callback, Application, Window)
to process any changes to variables by the client and then repaints
affected components using #paintAfterVariableChanges()
.
Also, some cleanup is done when a request arrives for an application that
has already been closed.
The method handleUidlRequest(...) in subclasses should call this method.
TODO better documentation
highlightPaintable
protected void highlightPaintable(Paintable highLightedPaintable2)
printHighlightedComponentHierarchy
protected void printHighlightedComponentHierarchy(StringBuilder sb,
AbstractComponent component)
writeUidlResponce
public void writeUidlResponce(AbstractCommunicationManager.Callback callback,
boolean repaintAll,
PrintWriter outWriter,
Window window,
boolean analyzeLayouts)
throws PaintException
- Throws:
PaintException
makeAllPaintablesDirty
public void makeAllPaintablesDirty(Window window)
unregisterPaintable
protected void unregisterPaintable(Component p)
- Parameters:
p
-
Called when communication manager stops listening for repaints for given component.
handleVariableBurst
public boolean handleVariableBurst(Object source,
Application app,
boolean success,
String burst)
changeVariables
protected void changeVariables(Object source,
VariableOwner owner,
Map<String,Object> m)
getVariableOwner
protected VariableOwner getVariableOwner(String string)
getRequestPayload
protected String getRequestPayload(AbstractCommunicationManager.Request request)
throws IOException
- Parameters:
request
-- Returns:
- Throws:
IOException
Reads the request data from the Request and returns it converted to an UTF-8 string.
decodeVariableValue
protected String decodeVariableValue(String encodedValue)
- Parameters:
encodedValue
- to decode- Returns:
- decoded value
Decode encoded burst, record, field and array item separator characters in a variable value String received from the client. This protects from separator injection attacks.
doGetApplicationWindow
protected Window doGetApplicationWindow(AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Callback callback,
Application application,
Window assumedWindow)
- Parameters:
request
-callback
-application
-assumedWindow
-- Returns:
TODO New method - document me!
closeJsonMessage
protected void closeJsonMessage(PrintWriter outWriter)
openJsonMessage
protected void openJsonMessage(PrintWriter outWriter,
AbstractCommunicationManager.Response response)
- Parameters:
outWriter
-response
-
Writes the opening of JSON message to be sent to client.
getPaintableId
public String getPaintableId(Paintable paintable)
- Parameters:
paintable
-- Returns:
- the paintable Id.
Gets the Paintable Id. If Paintable has debug id set it will be used prefixed with "PID_S". Otherwise a sequenced ID is created.
hasPaintableId
public boolean hasPaintableId(Paintable paintable)
repaintRequested
public void repaintRequested(Paintable.RepaintRequestEvent event)
- Specified by:
repaintRequested
in interfacePaintable.RepaintRequestListener
- Parameters:
event
- the repaint request event specifying the paintable source.- See Also:
Paintable.RepaintRequestListener.repaintRequested(com.vaadin.terminal.Paintable.RepaintRequestEvent)
Description copied from interface: Paintable.RepaintRequestListener
Receives repaint request events.
requireLocale
public void requireLocale(String value)
- Parameters:
value
-- See Also:
Locale.toString()
Queues a locale to be sent to the client (browser) for date and time
entry etc. All locale specific information is derived from server-side
Locale
instances and sent to the client when needed, eliminating
the need to use the Locale
class and all the framework behind it
on the client.
handleURI
protected DownloadStream handleURI(Window window,
AbstractCommunicationManager.Request request,
AbstractCommunicationManager.Response response,
AbstractCommunicationManager.Callback callback)
- Parameters:
window
- the target window of the requestrequest
- the request instanceresponse
- the response to write to- Returns:
- DownloadStream if the request was handled and further processing should be suppressed, null otherwise.
- See Also:
URIHandler
Calls the Window URI handler for a request and returns the
DownloadStream
returned by the handler.
If the window is the main window of an application, the (deprecated)
Application.handleURI(java.net.URL, String)
is called first to
handle ApplicationResource
s, and the window handler is only
called if it returns null.
cleanStreamVariable
protected abstract void cleanStreamVariable(VariableOwner owner,
String name)
isProductionMode
public boolean isProductionMode()
setProductionMode
public void setProductionMode(boolean productionMode)