/**
* @see nextapp.echo2.webrender.Service#service(nextapp.echo2.webrender.Connection)
*/
public void service(Connection conn)
throws IOException {
UserInstance userInstance = conn.getUserInstance();
synchronized(userInstance) {
Document clientMessageDocument = parseRequestDocument(conn);
String messageType = clientMessageDocument.getDocumentElement().getAttribute("type");
ServerMessage serverMessage;
if ("initialize".equals(messageType)) {
serverMessage = renderInit(conn, clientMessageDocument);
ClientPropertiesStore.renderStoreDirective(serverMessage, userInstance.getClientProperties());
ClientConfigurationUpdate.renderUpdateDirective(serverMessage, userInstance.getClientConfiguration());
ServerDelayMessageUpdate.renderUpdateDirective(serverMessage, userInstance.getServerDelayMessage());
// Add "test attribute" used by ClientEngine to determine if browser is correctly (un)escaping
// attribute values. Safari does not do this correctly and a workaround is thus employed if such
// bugs are detected.
serverMessage.getDocument().getDocumentElement().setAttribute("xml-attr-test", "x&y");
} else {
serverMessage = renderUpdate(conn, clientMessageDocument);
processUserInstanceUpdates(userInstance, serverMessage);
}
serverMessage.setTransactionId(userInstance.getNextTransactionId());
conn.setContentType(ContentType.TEXT_XML);
serverMessage.render(conn.getWriter());
}
}