|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vaadin.terminal.gwt.server.AbstractCommunicationManager
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
.
TODO Document better!
Nested Class Summary | |
---|---|
static interface |
AbstractCommunicationManager.Callback
TODO Document me! |
class |
AbstractCommunicationManager.ErrorHandlerErrorEvent
|
protected class |
AbstractCommunicationManager.InvalidUIDLSecurityKeyException
|
static class |
AbstractCommunicationManager.SimpleMultiPartInputStream
Stream that extracts content from another stream until the boundary string is encountered. |
Field Summary | |
---|---|
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(ClientConnector owner,
String name)
|
protected void |
closeJsonMessage(PrintWriter outWriter)
|
protected abstract BootstrapHandler |
createBootstrapHandler()
|
protected void |
doHandleSimpleMultipartFileUpload(WrappedRequest request,
WrappedResponse response,
StreamVariable streamVariable,
String variableName,
ClientConnector owner,
String boundary)
Method used to stream content from a multipart request (either from servlet or portlet request) to given StreamVariable |
protected void |
doHandleXhrFilePost(WrappedRequest request,
WrappedResponse response,
StreamVariable streamVariable,
String variableName,
ClientConnector owner,
int contentLength)
Used to stream plain file post (aka XHR2.post(File)) |
protected Application |
getApplication()
|
protected ClientConnector |
getConnector(Root root,
String connectorId)
|
protected String |
getInitialUIDL(WrappedRequest request,
Root root)
Generates the initial UIDL message that can e.g. |
protected String |
getRequestPayload(WrappedRequest request)
Reads the request data from the Request and returns it converted to an UTF-8 string. |
protected String |
getSecurityKey(WrappedRequest request)
Gets the security key (and generates one if needed). |
String |
getSecurityKeyUIDL(WrappedRequest request)
Gets the security key (and generates one if needed) as UIDL. |
protected abstract InputStream |
getThemeResourceAsStream(Root root,
String themeName,
String resource)
|
protected boolean |
handleApplicationRequest(WrappedRequest request,
WrappedResponse response)
|
void |
handleBrowserDetailsRequest(WrappedRequest request,
WrappedResponse response,
Application application)
|
boolean |
handleBurst(WrappedRequest source,
Root root,
String burst)
Processes a message burst received from the client. |
void |
handleUidlRequest(WrappedRequest request,
WrappedResponse response,
AbstractCommunicationManager.Callback callback,
Root root)
Internally process a UIDL request from the client. |
protected void |
highlightConnector(Connector highlightedConnector)
|
boolean |
isXSRFEnabled(Application application)
Returns false if the cross site request forgery protection is turned off. |
protected void |
openJsonMessage(PrintWriter outWriter,
WrappedResponse response)
Writes the opening of JSON message to be sent to client. |
protected void |
postPaint(Root root)
Method called after the paint phase while still being synchronized on the application |
protected void |
printHighlightedComponentHierarchy(StringBuilder sb,
AbstractComponent component)
|
void |
requireLocale(String value)
Queues a locale to be sent to the client (browser) for date and time entry etc. |
protected void |
sendUploadResponse(WrappedRequest request,
WrappedResponse response)
TODO document |
void |
serveConnectorResource(String resourceName,
WrappedRequest request,
WrappedResponse response,
String mimetype)
Serve a connector resource from the classpath if the resource has previously been registered by calling registerResource(String, Class) . |
protected boolean |
streamToReceiver(InputStream in,
StreamVariable streamVariable,
String filename,
String type,
int contentLength)
|
protected String |
unescapeBurst(String encodedValue)
Unescape encoded burst separator characters in a burst received from the client. |
void |
writeUidlResponse(WrappedRequest request,
boolean repaintAll,
PrintWriter outWriter,
Root root,
boolean analyzeLayouts)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char VAR_BURST_SEPARATOR
public static final char VAR_ESCAPE_CHARACTER
Constructor Detail |
---|
public AbstractCommunicationManager(Application application)
application
- Method Detail |
---|
protected Application getApplication()
protected void doHandleSimpleMultipartFileUpload(WrappedRequest request, WrappedResponse response, StreamVariable streamVariable, String variableName, ClientConnector owner, String boundary) throws IOException
request
- response
- streamVariable
- owner
- boundary
-
IOException
protected void doHandleXhrFilePost(WrappedRequest request, WrappedResponse response, StreamVariable streamVariable, String variableName, ClientConnector owner, int contentLength) throws IOException
request
- response
- streamVariable
- owner
- contentLength
-
IOException
protected final boolean streamToReceiver(InputStream in, StreamVariable streamVariable, String filename, String type, int contentLength) throws UploadException
in
- streamVariable
- filename
- type
- contentLength
-
UploadException
protected void sendUploadResponse(WrappedRequest request, WrappedResponse response) throws IOException
request
- response
-
IOException
public void handleUidlRequest(WrappedRequest request, WrappedResponse response, AbstractCommunicationManager.Callback callback, Root root) throws IOException, AbstractCommunicationManager.InvalidUIDLSecurityKeyException, JSONException
handleVariables(WrappedRequest, WrappedResponse, Callback, Application, Root)
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
request
- response
- callback
- root
- target window for the UIDL request, can be null if target not
found
IOException
AbstractCommunicationManager.InvalidUIDLSecurityKeyException
JSONException
protected void postPaint(Root root)
root
- protected void highlightConnector(Connector highlightedConnector)
protected void printHighlightedComponentHierarchy(StringBuilder sb, AbstractComponent component)
public String getSecurityKeyUIDL(WrappedRequest request)
request
-
protected String getSecurityKey(WrappedRequest request)
request
-
public void writeUidlResponse(WrappedRequest request, boolean repaintAll, PrintWriter outWriter, Root root, boolean analyzeLayouts) throws PaintException, JSONException
PaintException
JSONException
protected abstract InputStream getThemeResourceAsStream(Root root, String themeName, String resource)
public boolean isXSRFEnabled(Application application)
application
-
public boolean handleBurst(WrappedRequest source, Root root, String burst)
source
- root
- the root receiving the burstburst
- the content of the burst as a String to be parsed
protected void changeVariables(Object source, VariableOwner owner, Map<String,Object> m)
protected ClientConnector getConnector(Root root, String connectorId)
protected String getRequestPayload(WrappedRequest request) throws IOException
request
-
IOException
protected String unescapeBurst(String encodedValue)
encodedValue
- to decode
protected void closeJsonMessage(PrintWriter outWriter)
protected void openJsonMessage(PrintWriter outWriter, WrappedResponse response)
outWriter
- response
- public void requireLocale(String value)
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.
value
- Locale.toString()
protected abstract void cleanStreamVariable(ClientConnector owner, String name)
protected abstract BootstrapHandler createBootstrapHandler()
protected boolean handleApplicationRequest(WrappedRequest request, WrappedResponse response) throws IOException
IOException
public void handleBrowserDetailsRequest(WrappedRequest request, WrappedResponse response, Application application) throws IOException
IOException
protected String getInitialUIDL(WrappedRequest request, Root root) throws PaintException, JSONException
request
- the request that caused the initializationroot
- the root for which the UIDL should be generated
PaintException
- if an exception occurs while painting
JSONException
- if an exception occurs while encoding outputpublic void serveConnectorResource(String resourceName, WrappedRequest request, WrappedResponse response, String mimetype) throws IOException
registerResource(String, Class)
. Sending arbitrary files from
the classpath is prevented by only accepting resource names that have
explicitly been registered. Resources can currently only be registered by
including a JavaScript
or StyleSheet
annotation on a
Connector class.
resourceName
- request
- response
- mimetype
-
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |