Package muntjac :: Package terminal :: Package gwt :: Package server :: Module abstract_communication_manager :: Class AbstractCommunicationManager
[hide private]
[frames] | no frames]

Class AbstractCommunicationManager

source code

                   object --+        
                            |        
          util.IEventListener --+    
                                |    
             paintable.IPaintable --+
                                    |
                       object --+   |
                                |   |
paintable.IRepaintRequestListener --+
                                    |
                                   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 IPaintable and PaintTarget on the server side). The client widget receives these paint requests as calls to muntjac.terminal.gwt.client.IPaintable.updateFromUIDL. The client component communicates back to the server by sending a list of variable changes (see ApplicationConnection.updateVariable and VariableOwner.changeVariables).

Instance Methods [hide private]
 
__init__(self, application)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
getApplication(self) source code
 
doHandleSimpleMultipartFileUpload(self, request, response, streamVariable, variableName, owner, boundary)
Method used to stream content from a multipart request (either from servlet or portlet request) to given StreamVariable.
source code
 
doHandleXhrFilePost(self, request, response, streamVariable, variableName, owner, contentLength)
Used to stream plain file post (aka XHR2.post(File))
source code
 
streamToReceiver(self, inputStream, streamVariable, filename, typ, contentLength)
Returns: true if the streamvariable has informed that the terminal can forget this variable
source code
 
tryToCloseStream(self, out) source code
 
sendUploadResponse(self, request, response) source code
 
doHandleUidlRequest(self, request, response, callback, window)
Internally process a UIDL request from the client.
source code
 
highlightPaintable(self, highLightedPaintable2) source code
 
printHighlightedComponentHierarchy(self, sb, component) source code
 
paintAfterVariableChanges(self, request, response, callback, repaintAll, outWriter, window, analyzeLayouts) source code
 
writeUidlResponce(self, callback, repaintAll, outWriter, window, analyzeLayouts) source code
 
getTimeoutInterval(self) source code
 
getTheme(self, window) source code
 
getRequestTheme(self) source code
 
makeAllPaintablesDirty(self, window) source code
 
unregisterPaintable(self, p)
Called when communication manager stops listening for repaints for given component.
source code
 
handleVariables(self, request, response, callback, application2, window)
If this method returns false, something was submitted that we did not expect; this is probably due to the client being out-of-sync and sending variable changes for non-existing pids
source code
 
handleVariableBurst(self, source, app, success, burst) source code
 
changeVariables(self, source, owner, m) source code
 
getVariableOwner(self, string) source code
 
getDragAndDropService(self) source code
 
getRequestPayload(self, request)
Reads the request data from the Request and returns it converted to an UTF-8 string.
source code
 
handleChangeVariablesError(self, application, owner, e, m)
Handles an error (exception) that occurred when processing variable changes from the client or a failure of a file upload.
source code
 
convertVariableValue(self, variableType, strValue) source code
 
convertMap(self, strValue) source code
 
convertStringArray(self, strValue) source code
 
convertArray(self, strValue) source code
 
decodeVariableValue(self, encodedValue)
Decode encoded burst, record, field and array item separator characters in a variable value String received from the client.
source code
 
printLocaleDeclarations(self, outWriter)
Prints the queued (pending) locale definitions to a PrintWriter in a (UIDL) format that can be sent to the client and used there in formatting dates, times etc.
source code
 
doGetApplicationWindow(self, request, callback, application, assumedWindow) source code
 
endApplication(self, request, response, application)
Ends the Application.
source code
 
closeJsonMessage(self, outWriter) source code
 
openJsonMessage(self, outWriter, response)
Writes the opening of JSON message to be sent to client.
source code
 
getPaintableId(self, paintable)
Gets the IPaintable Id.
source code
 
hasPaintableId(self, paintable) source code
 
getDirtyVisibleComponents(self, w)
Returns dirty components which are in given window.
source code
 
repaintRequested(self, event)
Receives repaint request events.
source code
 
paintablePainted(self, paintable)
Internally mark a IPaintable as painted and start collecting new repaint requests for it.
source code
 
requireLocale(self, value)
Queues a locale to be sent to the client (browser) for date and time entry etc.
source code
 
generateLocale(self, value)
Constructs a Locale instance to be sent to the client based on a short locale description string.
source code
 
handleURI(self, window, request, response, callback)
Calls the Window URI handler for a request and returns the DownloadStream returned by the handler.
source code
 
getTagForType(self, class1) source code
 
getStreamVariableTargetUrl(self, owner, name, value) source code
 
cleanStreamVariable(self, owner, name) source code

Inherited from paintable.IPaintable: addCallback, addListener, getDebugId, paint, removeCallback, removeListener, requestRepaint, requestRepaintRequests, setDebugId

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_readLine(cls, stream) source code
 
removePath(cls, filename)
Removes any possible path information from the filename and returns the filename.
source code
 
isChildOf(cls, parent, child)
Helper method to test if a component contains another.
source code
Class Variables [hide private]
  _DASHDASH = '--'
  _GET_PARAM_REPAINT_ALL = 'repaintAll'
  _WRITE_SECURITY_TOKEN_FLAG = 'writeSecurityToken'
  _VAR_PID = 1
  _VAR_NAME = 2
  _VAR_TYPE = 3
  _VAR_VALUE = 0
  _VTYPE_PAINTABLE = 'p'
  _VTYPE_BOOLEAN = 'b'
  _VTYPE_DOUBLE = 'd'
  _VTYPE_FLOAT = 'f'
  _VTYPE_LONG = 'l'
  _VTYPE_INTEGER = 'i'
  _VTYPE_STRING = 's'
  _VTYPE_ARRAY = 'a'
  _VTYPE_STRINGARRAY = 'c'
  _VTYPE_MAP = 'm'
  _VAR_RECORD_SEPARATOR = u'\u001e'
  _VAR_FIELD_SEPARATOR = u'\u001f'
  VAR_BURST_SEPARATOR = u'\u001d'
  VAR_ARRAYITEM_SEPARATOR = u'\u001c'
  VAR_ESCAPE_CHARACTER = u'\u001b'
  _MAX_BUFFER_SIZE = 64* 1024
  _MAX_UPLOAD_BUFFER_SIZE = 4* 1024
  _GET_PARAM_ANALYZE_LAYOUTS = 'analyzeLayouts'
  _nextUnusedWindowSuffix = 1
  _LF = '\n'
  _CRLF = '\r\n'
  _UTF8 = 'UTF8'
  _GET_PARAM_HIGHLIGHT_COMPONENT = "highlightComponent"
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, application)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

doHandleSimpleMultipartFileUpload(self, request, response, streamVariable, variableName, owner, boundary)

source code 

Method used to stream content from a multipart request (either from servlet or portlet request) to given StreamVariable.

Raises:
  • IOException

doHandleXhrFilePost(self, request, response, streamVariable, variableName, owner, contentLength)

source code 

Used to stream plain file post (aka XHR2.post(File))

Raises:
  • IOException

streamToReceiver(self, inputStream, streamVariable, filename, typ, contentLength)

source code 
Returns:
true if the streamvariable has informed that the terminal can forget this variable
Raises:

removePath(cls, filename)
Class Method

source code 

Removes any possible path information from the filename and returns the filename. Separators / and \ are used.

sendUploadResponse(self, request, response)

source code 
Raises:
  • IOException

doHandleUidlRequest(self, request, response, callback, window)

source code 

Internally process a UIDL request from the client.

This method calls handleVariables 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.

Parameters:
  • request
  • response
  • callback
  • window - target window for the UIDL request, can be null if target not found
Raises:

paintAfterVariableChanges(self, request, response, callback, repaintAll, outWriter, window, analyzeLayouts)

source code 
Raises:

handleVariables(self, request, response, callback, application2, window)

source code 

If this method returns false, something was submitted that we did not expect; this is probably due to the client being out-of-sync and sending variable changes for non-existing pids

Returns:
true if successful, false if there was an inconsistency

getRequestPayload(self, request)

source code 

Reads the request data from the Request and returns it converted to an UTF-8 string.

Raises:
  • IOException

handleChangeVariablesError(self, application, owner, e, m)

source code 

Handles an error (exception) that occurred when processing variable changes from the client or a failure of a file upload.

For AbstractField components, AbstractField.handleError() is called. In all other cases (or if the field does not handle the error), ErrorListener.terminalError for the application error handler is called.

Parameters:
  • application
  • owner - component that the error concerns
  • e - exception that occurred
  • m - map from variable names to values

decodeVariableValue(self, encodedValue)

source code 

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.

Parameters:
  • encodedValue - value to decode
Returns:
decoded value

endApplication(self, request, response, application)

source code 

Ends the Application.

The browser is redirected to the Application logout URL set with Application.setLogoutURL, or to the application URL if no logout URL is given.

Parameters:
  • request - the request instance.
  • response - the response to write to.
  • application - the Application to end.
Raises:
  • IOException - if the writing failed due to input/output error.

getPaintableId(self, paintable)

source code 

Gets the IPaintable Id. If IPaintable has debug id set it will be used prefixed with "PID_S". Otherwise a sequenced ID is created.

Parameters:
  • paintable
Returns:
the paintable Id.

getDirtyVisibleComponents(self, w)

source code 

Returns dirty components which are in given window. Components in an invisible subtrees are omitted.

Parameters:
  • w - root window for which dirty components is to be fetched

repaintRequested(self, event)

source code 

Receives repaint request events.

Parameters:
  • event - the repaint request event specifying the paintable source.
Overrides: paintable.IRepaintRequestListener.repaintRequested

requireLocale(self, value)

source code 

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.

generateLocale(self, value)

source code 

Constructs a Locale instance to be sent to the client based on a short locale description string.

See Also: requireLocale

handleURI(self, window, request, response, callback)

source code 

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 is called first to handle ApplicationResources, and the window handler is only called if it returns null.

Parameters:
  • window - the target window of the request
  • request - the request instance
  • response - the response to write to
Returns:
DownloadStream if the request was handled and further processing should be suppressed, null otherwise.

See Also: URIHandler