summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-09-12 16:07:59 +0300
committerVaadin Code Review <review@vaadin.com>2013-10-10 11:44:31 +0000
commitf595d057951523baf35a797692376dfa5de0bc8d (patch)
tree9da1acd8568807db9784ae8e5c83da74209b7b37 /server/src
parent1b7e40de9435f2584fe6c7f1b7f69cc448c16cc8 (diff)
downloadvaadin-framework-f595d057951523baf35a797692376dfa5de0bc8d.tar.gz
vaadin-framework-f595d057951523baf35a797692376dfa5de0bc8d.zip
Make the various Writers member fields instead of local variables (#12446)
Change-Id: I9ca101edf6df41702b27635da9f749bdac5bf5f4
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/server/communication/UidlRequestHandler.java5
-rw-r--r--server/src/com/vaadin/server/communication/UidlWriter.java32
2 files changed, 23 insertions, 14 deletions
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index d52c5e9fe0..f13199e9ae 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -56,8 +56,7 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
private ServerRpcHandler rpcHandler = new ServerRpcHandler();
- public UidlRequestHandler() {
- }
+ private UidlWriter uidlWriter = new UidlWriter();
@Override
public boolean synchronizedHandleRequest(VaadinSession session,
@@ -146,7 +145,7 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
JSONException {
openJsonMessage(writer, response);
- new UidlWriter().write(ui, writer, repaintAll, false);
+ uidlWriter.write(ui, writer, repaintAll, false);
closeJsonMessage(writer);
}
diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java
index 60933a75c2..fe7a7d42bf 100644
--- a/server/src/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/com/vaadin/server/communication/UidlWriter.java
@@ -51,6 +51,14 @@ import com.vaadin.ui.UI;
*/
public class UidlWriter implements Serializable {
+ private LegacyUidlWriter legacyUidlWriter = new LegacyUidlWriter();
+ private SharedStateWriter sharedStateWriter = new SharedStateWriter();
+ private ConnectorTypeWriter connectorTypeWriter = new ConnectorTypeWriter();
+ private ConnectorHierarchyWriter connectorHierarchyWriter = new ConnectorHierarchyWriter();
+ private ClientRpcWriter clientRpcWriter = new ClientRpcWriter();
+ private MetadataWriter metadataWriter = new MetadataWriter();
+ private ResourceWriter resourceWriter = new ResourceWriter();
+
/**
* Writes a JSON object containing all pending changes to the given UI.
*
@@ -79,13 +87,12 @@ public class UidlWriter implements Serializable {
// to write out
session.getService().runPendingAccessTasks(session);
- ArrayList<ClientConnector> dirtyVisibleConnectors = ui
- .getConnectorTracker().getDirtyVisibleConnectors();
- LegacyCommunicationManager manager = session.getCommunicationManager();
// Paints components
- ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
getLogger().log(Level.FINE, "* Creating response to client");
+ ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
+ ArrayList<ClientConnector> dirtyVisibleConnectors = uiConnectorTracker
+ .getDirtyVisibleConnectors();
getLogger().log(
Level.FINE,
"Found " + dirtyVisibleConnectors.size()
@@ -100,10 +107,13 @@ public class UidlWriter implements Serializable {
try {
writer.write("\"changes\" : ");
+ LegacyCommunicationManager manager = session
+ .getCommunicationManager();
+
JsonPaintTarget paintTarget = new JsonPaintTarget(manager, writer,
!repaintAll);
- new LegacyUidlWriter().write(ui, writer, paintTarget);
+ legacyUidlWriter.write(ui, writer, paintTarget);
paintTarget.close();
writer.write(", "); // close changes
@@ -120,7 +130,7 @@ public class UidlWriter implements Serializable {
// processing.
writer.write("\"state\":");
- new SharedStateWriter().write(ui, writer);
+ sharedStateWriter.write(ui, writer);
writer.write(", "); // close states
// TODO This should be optimized. The type only needs to be
@@ -129,7 +139,7 @@ public class UidlWriter implements Serializable {
// widget mapping
writer.write("\"types\":");
- new ConnectorTypeWriter().write(ui, writer, paintTarget);
+ connectorTypeWriter.write(ui, writer, paintTarget);
writer.write(", "); // close states
// Send update hierarchy information to the client.
@@ -140,7 +150,7 @@ public class UidlWriter implements Serializable {
// child to 0 children)
writer.write("\"hierarchy\":");
- new ConnectorHierarchyWriter().write(ui, writer);
+ connectorHierarchyWriter.write(ui, writer);
writer.write(", "); // close hierarchy
// send server to client RPC calls for components in the UI, in call
@@ -150,7 +160,7 @@ public class UidlWriter implements Serializable {
// which they were performed, remove the calls from components
writer.write("\"rpc\" : ");
- new ClientRpcWriter().write(ui, writer);
+ clientRpcWriter.write(ui, writer);
writer.write(", "); // close rpc
uiConnectorTracker.markAllConnectorsClean();
@@ -160,11 +170,11 @@ public class UidlWriter implements Serializable {
SystemMessages messages = ui.getSession().getService()
.getSystemMessages(ui.getLocale(), null);
// TODO hilightedConnector
- new MetadataWriter().write(ui, writer, repaintAll, async, messages);
+ metadataWriter.write(ui, writer, repaintAll, async, messages);
writer.write(", ");
writer.write("\"resources\" : ");
- new ResourceWriter().write(ui, writer, paintTarget);
+ resourceWriter.write(ui, writer, paintTarget);
Collection<Class<? extends ClientConnector>> usedClientConnectors = paintTarget
.getUsedClientConnectors();