Browse Source

VConsole logging -> java.util.logging

Change-Id: Id1b04e1335f0906f8de2d514ff11bc744dc14c49
tags/7.5.0.beta1
Artur Signell 9 years ago
parent
commit
718eb3e49a

+ 2
- 1
client/src/com/vaadin/client/ApplicationConfiguration.java View File



@Override @Override
public void failed(Throwable reason) { public void failed(Throwable reason) {
VConsole.error(reason);
getLogger().log(Level.SEVERE,
"Error loading deferred bundle", reason);
} }
}); });
} }

+ 149
- 105
client/src/com/vaadin/client/ApplicationConnection.java View File

import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;


import com.google.gwt.aria.client.LiveValue; import com.google.gwt.aria.client.LiveValue;
import com.vaadin.client.ui.dd.VDragAndDropManager; import com.vaadin.client.ui.dd.VDragAndDropManager;
import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.client.ui.ui.UIConnector;
import com.vaadin.client.ui.window.WindowConnector; import com.vaadin.client.ui.window.WindowConnector;
import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.JsonConstants; import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.VaadinUriResolver; import com.vaadin.shared.VaadinUriResolver;
int currentTime = elapsedMillis(); int currentTime = elapsedMillis();
int stepDuration = currentTime - previousStep; int stepDuration = currentTime - previousStep;
if (stepDuration >= minDuration) { if (stepDuration >= minDuration) {
VConsole.log(message + ": " + stepDuration + " ms");
getLogger().info(message + ": " + stepDuration + " ms");
} }
previousStep = currentTime; previousStep = currentTime;
} }
} }


public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) { public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) {
VConsole.log("Starting application " + cnf.getRootPanelId());
VConsole.log("Using theme: " + cnf.getThemeName());
getLogger().info("Starting application " + cnf.getRootPanelId());
getLogger().info("Using theme: " + cnf.getThemeName());


VConsole.log("Vaadin application servlet version: "
+ cnf.getServletVersion());
getLogger().info(
"Vaadin application servlet version: "
+ cnf.getServletVersion());


if (!cnf.getServletVersion().equals(Version.getFullVersion())) { if (!cnf.getServletVersion().equals(Version.getFullVersion())) {
VConsole.error("Warning: your widget set seems to be built with a different "
+ "version than the one used on server. Unexpected "
+ "behavior may occur.");
getLogger()
.severe("Warning: your widget set seems to be built with a different "
+ "version than the one used on server. Unexpected "
+ "behavior may occur.");
} }


this.widgetSet = widgetSet; this.widgetSet = widgetSet;
payload.put(ApplicationConstants.RPC_INVOCATIONS, reqInvocations); payload.put(ApplicationConstants.RPC_INVOCATIONS, reqInvocations);
payload.put(ApplicationConstants.SERVER_SYNC_ID, lastSeenServerSyncId); payload.put(ApplicationConstants.SERVER_SYNC_ID, lastSeenServerSyncId);


VConsole.log("Making UIDL Request with params: " + payload.toJson());
getLogger()
.info("Making UIDL Request with params: " + payload.toJson());
String uri = translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX String uri = translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX
+ ApplicationConstants.UIDL_PATH + '/'); + ApplicationConstants.UIDL_PATH + '/');




@Override @Override
public void onResponseReceived(Request request, Response response) { public void onResponseReceived(Request request, Response response) {
VConsole.log("Server visit took "
+ String.valueOf((new Date()).getTime()
- requestStartTime.getTime()) + "ms");
getLogger().info(
"Server visit took "
+ String.valueOf((new Date()).getTime()
- requestStartTime.getTime()) + "ms");


int statusCode = response.getStatusCode(); int statusCode = response.getStatusCode();
// Notify network observers about response status // Notify network observers about response status
* Status code 0 does indicate that there was no server * Status code 0 does indicate that there was no server
* side processing, so we can retry the request. * side processing, so we can retry the request.
*/ */
VConsole.log("Status code 0, retrying");
getLogger().warning("Status code 0, retrying");
(new Timer() { (new Timer() {
@Override @Override
public void run() { public void run() {
*/ */
String delay = response.getHeader("Retry-After"); String delay = response.getHeader("Retry-After");
if (delay != null) { if (delay != null) {
VConsole.log("503, retrying in " + delay + "msec");
getLogger().warning(
"503, retrying in " + delay + "msec");
(new Timer() { (new Timer() {
@Override @Override
public void run() { public void run() {
try { try {
doAjaxRequest(uri, payload, requestCallback); doAjaxRequest(uri, payload, requestCallback);
} catch (RequestException e) { } catch (RequestException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in server request", e);
endRequest(); endRequest();
fireEvent(new ConnectionStatusEvent(0)); fireEvent(new ConnectionStatusEvent(0));
} }
return; return;
} }


VConsole.log("JSON parsing took "
+ (new Date().getTime() - start.getTime()) + "ms");
getLogger().info(
"JSON parsing took " + (new Date().getTime() - start.getTime())
+ "ms");
if (isApplicationRunning()) { if (isApplicationRunning()) {
handleReceivedJSONMessage(start, jsonText, json); handleReceivedJSONMessage(start, jsonText, json);
} else { } else {


// Show this message just once // Show this message just once
if (cssWaits++ == 0) { if (cssWaits++ == 0) {
VConsole.log("Assuming CSS loading is not complete, "
+ "postponing render phase. "
+ "(.v-loading-indicator height == 0)");
getLogger().warning(
"Assuming CSS loading is not complete, "
+ "postponing render phase. "
+ "(.v-loading-indicator height == 0)");
} }
} else { } else {
cssLoaded = true; cssLoaded = true;
* *
*/ */
protected void showCommunicationError(String details, int statusCode) { protected void showCommunicationError(String details, int statusCode) {
VConsole.error("Communication error: " + details);
getLogger().severe("Communication error: " + details);
showError(details, configuration.getCommunicationError()); showError(details, configuration.getCommunicationError());
} }


* Optional details for debugging. * Optional details for debugging.
*/ */
protected void showAuthenticationError(String details) { protected void showAuthenticationError(String details) {
VConsole.error("Authentication error: " + details);
getLogger().severe("Authentication error: " + details);
showError(details, configuration.getAuthorizationError()); showError(details, configuration.getAuthorizationError());
} }


* Optional details for debugging. * Optional details for debugging.
*/ */
public void showSessionExpiredError(String details) { public void showSessionExpiredError(String details) {
VConsole.error("Session expired: " + details);
getLogger().severe("Session expired: " + details);
showError(details, configuration.getSessionExpiredError()); showError(details, configuration.getSessionExpiredError());
} }




protected void startRequest() { protected void startRequest() {
if (hasActiveRequest) { if (hasActiveRequest) {
VConsole.error("Trying to start a new request while another is active");
getLogger().severe(
"Trying to start a new request while another is active");
} }
hasActiveRequest = true; hasActiveRequest = true;
requestStartTime = new Date(); requestStartTime = new Date();


protected void endRequest() { protected void endRequest() {
if (!hasActiveRequest) { if (!hasActiveRequest) {
VConsole.error("No active request");
getLogger().severe("No active request");
} }
// After checkForPendingVariableBursts() there may be a new active // After checkForPendingVariableBursts() there may be a new active
// request, so we must set hasActiveRequest to false before, not after, // request, so we must set hasActiveRequest to false before, not after,
&& !getConnectorMap().isDragAndDropPaintable(id)) { && !getConnectorMap().isDragAndDropPaintable(id)) {
// variable owner does not exist anymore // variable owner does not exist anymore
iterator.remove(); iterator.remove();
VConsole.log("Removed variable from removed component: " + id);
getLogger().info(
"Removed variable from removed component: " + id);
} }
} }
} }
// Some component is doing something that can't be interrupted // Some component is doing something that can't be interrupted
// (e.g. animation that should be smooth). Enqueue the UIDL // (e.g. animation that should be smooth). Enqueue the UIDL
// message for later processing. // message for later processing.
VConsole.log("Postponing UIDL handling due to lock...");
getLogger().info("Postponing UIDL handling due to lock...");
pendingUIDLMessages.add(new PendingUIDLMessage(start, jsonText, pendingUIDLMessages.add(new PendingUIDLMessage(start, jsonText,
json)); json));
if (!forceHandleMessage.isRunning()) { if (!forceHandleMessage.isRunning()) {
final Object lock = new Object(); final Object lock = new Object();
suspendReponseHandling(lock); suspendReponseHandling(lock);


VConsole.log("Handling message from server");
getLogger().info("Handling message from server");
eventBus.fireEvent(new ResponseHandlingStartedEvent(this)); eventBus.fireEvent(new ResponseHandlingStartedEvent(this));


final int syncId; final int syncId;
} }
} else { } else {
syncId = -1; syncId = -1;
VConsole.error("Server response didn't contain a sync id. "
+ "Please verify that the server is up-to-date and that the response data has not been modified in transmission.");
getLogger()
.severe("Server response didn't contain a sync id. "
+ "Please verify that the server is up-to-date and that the response data has not been modified in transmission.");
} }


// Handle redirect // Handle redirect
if (json.containsKey("redirect")) { if (json.containsKey("redirect")) {
String url = json.getValueMap("redirect").getString("url"); String url = json.getValueMap("redirect").getString("url");
VConsole.log("redirecting to " + url);
getLogger().info("redirecting to " + url);
redirect(url); redirect(url);
return; return;
} }
csrfToken = json csrfToken = json
.getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); .getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID);
} }
VConsole.log(" * Handling resources from server");
getLogger().info(" * Handling resources from server");


if (json.containsKey("resources")) { if (json.containsKey("resources")) {
ValueMap resources = json.getValueMap("resources"); ValueMap resources = json.getValueMap("resources");
handleUIDLDuration.logDuration( handleUIDLDuration.logDuration(
" * Handling resources from server completed", 10); " * Handling resources from server completed", 10);


VConsole.log(" * Handling type inheritance map from server");
getLogger().info(" * Handling type inheritance map from server");


if (json.containsKey("typeInheritanceMap")) { if (json.containsKey("typeInheritanceMap")) {
configuration.addComponentInheritanceInfo(json configuration.addComponentInheritanceInfo(json
handleUIDLDuration.logDuration( handleUIDLDuration.logDuration(
" * Handling type inheritance map from server completed", 10); " * Handling type inheritance map from server completed", 10);


VConsole.log("Handling type mappings from server");
getLogger().info("Handling type mappings from server");


if (json.containsKey("typeMappings")) { if (json.containsKey("typeMappings")) {
configuration.addComponentMappings( configuration.addComponentMappings(


} }


VConsole.log("Handling resource dependencies");
getLogger().info("Handling resource dependencies");
if (json.containsKey("scriptDependencies")) { if (json.containsKey("scriptDependencies")) {
loadScriptDependencies(json.getJSStringArray("scriptDependencies")); loadScriptDependencies(json.getJSStringArray("scriptDependencies"));
} }
Profiler.enter("Handling meta information"); Profiler.enter("Handling meta information");
ValueMap meta = null; ValueMap meta = null;
if (json.containsKey("meta")) { if (json.containsKey("meta")) {
VConsole.log(" * Handling meta information");
getLogger().info(" * Handling meta information");
meta = json.getValueMap("meta"); meta = json.getValueMap("meta");
if (meta.containsKey("repaintAll")) { if (meta.containsKey("repaintAll")) {
prepareRepaintAll(); prepareRepaintAll();
* connectors which get a state change event before the UI. * connectors which get a state change event before the UI.
*/ */
Profiler.enter("Handling locales"); Profiler.enter("Handling locales");
VConsole.log(" * Handling locales");
getLogger().info(" * Handling locales");
// Store locale data // Store locale data
LocaleService LocaleService
.addLocales(getUIConnector().getState().localeServiceState.localeData); .addLocales(getUIConnector().getState().localeServiceState.localeData);


unregisterRemovedConnectors(connectorHierarchyUpdateResult.detachedConnectorIds); unregisterRemovedConnectors(connectorHierarchyUpdateResult.detachedConnectorIds);


VConsole.log("handleUIDLMessage: "
+ (Duration.currentTimeMillis() - processUidlStart)
+ " ms");
getLogger()
.info("handleUIDLMessage: "
+ (Duration.currentTimeMillis() - processUidlStart)
+ " ms");


updatingState = false; updatingState = false;


layoutManager.setEverythingNeedsMeasure(); layoutManager.setEverythingNeedsMeasure();
layoutManager.layoutNow(); layoutManager.layoutNow();
} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error processing layouts", e);
} }
Profiler.leave("Layout processing"); Profiler.leave("Layout processing");
} }


if (ApplicationConfiguration.isDebugMode()) { if (ApplicationConfiguration.isDebugMode()) {
Profiler.enter("Dumping state changes to the console"); Profiler.enter("Dumping state changes to the console");
VConsole.log(" * Dumping state changes to the console");
getLogger().info(" * Dumping state changes to the console");
VConsole.dirUIDL(json, ApplicationConnection.this); VConsole.dirUIDL(json, ApplicationConnection.this);
Profiler.leave("Dumping state changes to the console"); Profiler.leave("Dumping state changes to the console");
} }
} }
} }


VConsole.log(" Processing time was "
+ String.valueOf(lastProcessingTime) + "ms for "
+ jsonText.length() + " characters of JSON");
VConsole.log("Referenced paintables: " + connectorMap.size());
getLogger().info(
" Processing time was "
+ String.valueOf(lastProcessingTime)
+ "ms for " + jsonText.length()
+ " characters of JSON");
getLogger().info(
"Referenced paintables: " + connectorMap.size());


if (meta == null || !meta.containsKey("async")) { if (meta == null || !meta.containsKey("async")) {
// End the request if the received message was a response, // End the request if the received message was a response,
JsArrayObject<StateChangeEvent> pendingStateChangeEvents) { JsArrayObject<StateChangeEvent> pendingStateChangeEvents) {
Profiler.enter("@DelegateToWidget"); Profiler.enter("@DelegateToWidget");


VConsole.log(" * Running @DelegateToWidget");
getLogger().info(" * Running @DelegateToWidget");


// Keep track of types that have no @DelegateToWidget in their // Keep track of types that have no @DelegateToWidget in their
// state to optimize performance // state to optimize performance
private void sendStateChangeEvents( private void sendStateChangeEvents(
JsArrayObject<StateChangeEvent> pendingStateChangeEvents) { JsArrayObject<StateChangeEvent> pendingStateChangeEvents) {
Profiler.enter("sendStateChangeEvents"); Profiler.enter("sendStateChangeEvents");
VConsole.log(" * Sending state change events");
getLogger().info(" * Sending state change events");


int size = pendingStateChangeEvents.size(); int size = pendingStateChangeEvents.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
try { try {
sce.getConnector().fireEvent(sce); sce.getConnector().fireEvent(sce);
} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error sending state change events", e);
} }
} }


ServerConnector c = currentConnectors.get(i); ServerConnector c = currentConnectors.get(i);
if (c.getParent() != null) { if (c.getParent() != null) {
if (!c.getParent().getChildren().contains(c)) { if (!c.getParent().getChildren().contains(c)) {
VConsole.error("ERROR: Connector "
+ c.getConnectorId()
+ " is connected to a parent but the parent ("
+ c.getParent().getConnectorId()
+ ") does not contain the connector");
getLogger()
.severe("ERROR: Connector "
+ c.getConnectorId()
+ " is connected to a parent but the parent ("
+ c.getParent().getConnectorId()
+ ") does not contain the connector");
} }
} else if (c == getUIConnector()) { } else if (c == getUIConnector()) {
// UIConnector for this connection, ignore // UIConnector for this connection, ignore
} else { } else {
// The connector has been detached from the // The connector has been detached from the
// hierarchy but was not unregistered. // hierarchy but was not unregistered.
VConsole.error("ERROR: Connector "
+ c.getConnectorId()
+ " is not attached to a parent but has not been unregistered");
getLogger()
.severe("ERROR: Connector "
+ c.getConnectorId()
+ " is not attached to a parent but has not been unregistered");
} }


} }
verifyConnectorHierarchy(); verifyConnectorHierarchy();
} }


VConsole.log("* Unregistered " + detachedArray.length()
+ " connectors");
getLogger().info(
"* Unregistered " + detachedArray.length()
+ " connectors");
Profiler.leave("unregisterRemovedConnectors"); Profiler.leave("unregisterRemovedConnectors");
} }


private JsArrayString createConnectorsIfNeeded(ValueMap json) { private JsArrayString createConnectorsIfNeeded(ValueMap json) {
VConsole.log(" * Creating connectors (if needed)");
getLogger().info(" * Creating connectors (if needed)");


JsArrayString createdConnectors = JavaScriptObject JsArrayString createdConnectors = JavaScriptObject
.createArray().cast(); .createArray().cast();
createdConnectors.push(connectorId); createdConnectors.push(connectorId);
} }
} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error handling type data", e);
} }
} }


onlyNoLayoutUpdates = false; onlyNoLayoutUpdates = false;
} }


VConsole.log(" * Passing UIDL to Vaadin 6 style connectors");
getLogger()
.info(" * Passing UIDL to Vaadin 6 style connectors");
// update paintables // update paintables
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
try { try {
Profiler.leave(key); Profiler.leave(key);
} }
} else if (legacyConnector == null) { } else if (legacyConnector == null) {
VConsole.error("Received update for "
+ uidl.getTag()
+ ", but there is no such paintable ("
+ connectorId + ") rendered.");
getLogger()
.severe("Received update for "
+ uidl.getTag()
+ ", but there is no such paintable ("
+ connectorId + ") rendered.");
} else { } else {
VConsole.error("Server sent Vaadin 6 style updates for "
+ Util.getConnectorString(legacyConnector)
+ " but this is not a Vaadin 6 Paintable");
getLogger()
.severe("Server sent Vaadin 6 style updates for "
+ Util.getConnectorString(legacyConnector)
+ " but this is not a Vaadin 6 Paintable");
} }


} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error handling UIDL", e);
} }
} }


} }
Profiler.enter("sendHierarchyChangeEvents"); Profiler.enter("sendHierarchyChangeEvents");


VConsole.log(" * Sending hierarchy change events");
getLogger().info(" * Sending hierarchy change events");
for (int i = 0; i < eventCount; i++) { for (int i = 0; i < eventCount; i++) {
ConnectorHierarchyChangeEvent event = events.get(i); ConnectorHierarchyChangeEvent event = events.get(i);
try { try {
logHierarchyChange(event); logHierarchyChange(event);
event.getConnector().fireEvent(event); event.getConnector().fireEvent(event);
} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error sending hierarchy change events", e);
} }
} }


return; return;
} }


VConsole.log("Hierarchy changed for "
+ Util.getConnectorString(event.getConnector()));
getLogger()
.info("Hierarchy changed for "
+ Util.getConnectorString(event.getConnector()));
String oldChildren = "* Old children: "; String oldChildren = "* Old children: ";
for (ComponentConnector child : event.getOldChildren()) { for (ComponentConnector child : event.getOldChildren()) {
oldChildren += Util.getConnectorString(child) + " "; oldChildren += Util.getConnectorString(child) + " ";
} }
VConsole.log(oldChildren);
getLogger().info(oldChildren);


String newChildren = "* New children: "; String newChildren = "* New children: ";
HasComponentsConnector parent = (HasComponentsConnector) event HasComponentsConnector parent = (HasComponentsConnector) event
for (ComponentConnector child : parent.getChildComponents()) { for (ComponentConnector child : parent.getChildComponents()) {
newChildren += Util.getConnectorString(child) + " "; newChildren += Util.getConnectorString(child) + " ";
} }
VConsole.log(newChildren);
getLogger().info(newChildren);
} }


private JsArrayObject<StateChangeEvent> updateConnectorState( private JsArrayObject<StateChangeEvent> updateConnectorState(
ValueMap json, JsArrayString createdConnectorIds) { ValueMap json, JsArrayString createdConnectorIds) {
JsArrayObject<StateChangeEvent> events = JavaScriptObject JsArrayObject<StateChangeEvent> events = JavaScriptObject
.createArray().cast(); .createArray().cast();
VConsole.log(" * Updating connector states");
getLogger().info(" * Updating connector states");
if (!json.containsKey("state")) { if (!json.containsKey("state")) {
return events; return events;
} }
Profiler.leave("updateConnectorState inner loop"); Profiler.leave("updateConnectorState inner loop");
} }
} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error updating connector states", e);
} }
} }


ValueMap json) { ValueMap json) {
ConnectorHierarchyUpdateResult result = new ConnectorHierarchyUpdateResult(); ConnectorHierarchyUpdateResult result = new ConnectorHierarchyUpdateResult();


VConsole.log(" * Updating connector hierarchy");
getLogger().info(" * Updating connector hierarchy");
if (!json.containsKey("hierarchy")) { if (!json.containsKey("hierarchy")) {
return result; return result;
} }
ServerConnector childConnector = connectorMap ServerConnector childConnector = connectorMap
.getConnector(childConnectorId); .getConnector(childConnectorId);
if (childConnector == null) { if (childConnector == null) {
VConsole.error("Hierarchy claims that "
+ childConnectorId
+ " is a child for "
+ connectorId
+ " ("
+ parentConnector.getClass().getName()
+ ") but no connector with id "
+ childConnectorId
+ " has been registered. "
+ "More information might be available in the server-side log if assertions are enabled");
getLogger()
.severe("Hierarchy claims that "
+ childConnectorId
+ " is a child for "
+ connectorId
+ " ("
+ parentConnector.getClass()
.getName()
+ ") but no connector with id "
+ childConnectorId
+ " has been registered. "
+ "More information might be available in the server-side log if assertions are enabled");
continue; continue;
} }
newChildren.add(childConnector); newChildren.add(childConnector);
result.events.add(event); result.events.add(event);
} }
} else if (!newComponents.isEmpty()) { } else if (!newComponents.isEmpty()) {
VConsole.error("Hierachy claims "
+ Util.getConnectorString(parentConnector)
+ " has component children even though it isn't a HasComponentsConnector");
getLogger()
.severe("Hierachy claims "
+ Util.getConnectorString(parentConnector)
+ " has component children even though it isn't a HasComponentsConnector");
} }


Profiler.leave("updateConnectorHierarchy handle HasComponentsConnector"); Profiler.leave("updateConnectorHierarchy handle HasComponentsConnector");


Profiler.leave("updateConnectorHierarchy find removed children"); Profiler.leave("updateConnectorHierarchy find removed children");
} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error updating connector hierarchy", e);
} finally { } finally {
Profiler.leave("updateConnectorHierarchy hierarchy entry"); Profiler.leave("updateConnectorHierarchy hierarchy entry");
} }
if (json.containsKey("rpc")) { if (json.containsKey("rpc")) {
Profiler.enter("handleRpcInvocations"); Profiler.enter("handleRpcInvocations");


VConsole.log(" * Performing server to client RPC calls");
getLogger()
.info(" * Performing server to client RPC calls");


JsonArray rpcCalls = Util.jso2json(json JsonArray rpcCalls = Util.jso2json(json
.getJavaScriptObject("rpc")); .getJavaScriptObject("rpc"));
} }


} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e);
getLogger()
.log(Level.SEVERE,
"Error performing server to client RPC calls",
e);
} }
} }




@Override @Override
public void onError(ResourceLoadEvent event) { public void onError(ResourceLoadEvent event) {
VConsole.error(event.getResourceUrl()
+ " could not be loaded, or the load detection failed because the stylesheet is empty.");
getLogger()
.severe(event.getResourceUrl()
+ " could not be loaded, or the load detection failed because the stylesheet is empty.");
// The show must go on // The show must go on
onLoad(event); onLoad(event);
} }


@Override @Override
public void onError(ResourceLoadEvent event) { public void onError(ResourceLoadEvent event) {
VConsole.error(event.getResourceUrl() + " could not be loaded.");
getLogger().severe(
event.getResourceUrl() + " could not be loaded.");
// The show must go on // The show must go on
onLoad(event); onLoad(event);
} }


layoutManager.forceLayout(); layoutManager.forceLayout();


VConsole.log("forceLayout in " + duration.elapsedMillis() + " ms");
getLogger().info("forceLayout in " + duration.elapsedMillis() + " ms");
} }


/** /**
*/ */
@Deprecated @Deprecated
public void unregisterPaintable(ServerConnector p) { public void unregisterPaintable(ServerConnector p) {
VConsole.log("unregisterPaintable (unnecessarily) called for "
+ Util.getConnectorString(p));
getLogger().info(
"unregisterPaintable (unnecessarily) called for "
+ Util.getConnectorString(p));
} }


/** /**
} }


if (!manageCaption) { if (!manageCaption) {
VConsole.error(Util.getConnectorString(connector)
+ " called updateComponent with manageCaption=false. The parameter was ignored - override delegateCaption() to return false instead. It is however not recommended to use caption this way at all.");
getLogger()
.warning(
Util.getConnectorString(connector)
+ " called updateComponent with manageCaption=false. The parameter was ignored - override delegateCaption() to return false instead. It is however not recommended to use caption this way at all.");
} }
return false; return false;
} }
Timer forceHandleMessage = new Timer() { Timer forceHandleMessage = new Timer() {
@Override @Override
public void run() { public void run() {
VConsole.log("WARNING: reponse handling was never resumed, forcibly removing locks...");
getLogger()
.warning(
"WARNING: reponse handling was never resumed, forcibly removing locks...");
responseHandlingLocks.clear(); responseHandlingLocks.clear();
handlePendingMessages(); handlePendingMessages();
} }
forceHandleMessage.cancel(); forceHandleMessage.cancel();


if (!pendingUIDLMessages.isEmpty()) { if (!pendingUIDLMessages.isEmpty()) {
VConsole.log("No more response handling locks, handling pending requests.");
getLogger()
.info("No more response handling locks, handling pending requests.");
handlePendingMessages(); handlePendingMessages();
} }
} }

+ 5
- 1
client/src/com/vaadin/client/ConnectorMap.java View File



import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.logging.Logger;


import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
*/ */
public void unregisterConnector(ServerConnector connector) { public void unregisterConnector(ServerConnector connector) {
if (connector == null) { if (connector == null) {
VConsole.error("Trying to unregister null connector");
getLogger().severe("Trying to unregister null connector");
return; return;
} }


return getConnectorId(w.getElement()) != null; return getConnectorId(w.getElement()) != null;
} }


private static Logger getLogger() {
return Logger.getLogger(ConnectorMap.class.getName());
}
} }

+ 16
- 11
client/src/com/vaadin/client/DateTimeService.java View File

package com.vaadin.client; package com.vaadin.client;


import java.util.Date; import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.i18n.client.LocaleInfo;
try { try {
return LocaleService.getMonthNames(currentLocale)[month]; return LocaleService.getMonthNames(currentLocale)[month];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in getMonth", e);
return null; return null;
} }
} }
try { try {
return LocaleService.getShortMonthNames(currentLocale)[month]; return LocaleService.getShortMonthNames(currentLocale)[month];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in getShortMonth", e);
return null; return null;
} }
} }
try { try {
return LocaleService.getDayNames(currentLocale)[day]; return LocaleService.getDayNames(currentLocale)[day];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in getDay", e);
return null; return null;
} }
} }
try { try {
return LocaleService.getShortDayNames(currentLocale)[day]; return LocaleService.getShortDayNames(currentLocale)[day];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in getShortDay", e);
return null; return null;
} }
} }
try { try {
return LocaleService.getFirstDayOfWeek(currentLocale); return LocaleService.getFirstDayOfWeek(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in getFirstDayOfWeek", e);
return 0; return 0;
} }
} }
try { try {
return LocaleService.isTwelveHourClock(currentLocale); return LocaleService.isTwelveHourClock(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in isTwelveHourClock", e);
return false; return false;
} }
} }
try { try {
return LocaleService.getClockDelimiter(currentLocale); return LocaleService.getClockDelimiter(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error in getClockDelimiter", e);
return ":"; return ":";
} }
} }
return LocaleService.getAmPmStrings(currentLocale); return LocaleService.getAmPmStrings(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO can this practically even happen? Should die instead? // TODO can this practically even happen? Should die instead?
VConsole.error("Locale not loaded, using fallback : AM/PM");
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Locale not loaded, using fallback : AM/PM", e);
return DEFAULT_AMPM_STRINGS; return DEFAULT_AMPM_STRINGS;
} }
} }
try { try {
firstDay = LocaleService.getFirstDayOfWeek(currentLocale); firstDay = LocaleService.getFirstDayOfWeek(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
VConsole.error("Locale not loaded, using fallback 0");
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Locale not loaded, using fallback 0", e);
firstDay = 0; firstDay = 0;
} }
int start = dateForFirstOfThisMonth.getDay() - firstDay; int start = dateForFirstOfThisMonth.getDay() - firstDay;


} }


public static Logger getLogger() {
return Logger.getLogger(DateTimeService.class.getName());
}
} }

+ 13
- 5
client/src/com/vaadin/client/JavaScriptConnectorHelper.java View File

import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger;


import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArray;
String initFunctionName = serverSideClassName String initFunctionName = serverSideClassName
.replaceAll("\\.", "_"); .replaceAll("\\.", "_");
if (tryInitJs(initFunctionName, getConnectorWrapper())) { if (tryInitJs(initFunctionName, getConnectorWrapper())) {
VConsole.log("JavaScript connector initialized using "
+ initFunctionName);
getLogger().info(
"JavaScript connector initialized using "
+ initFunctionName);
this.initFunctionName = initFunctionName; this.initFunctionName = initFunctionName;
return true; return true;
} else { } else {
VConsole.log("No JavaScript function " + initFunctionName
+ " found");
getLogger()
.warning(
"No JavaScript function " + initFunctionName
+ " found");
attemptedNames.add(initFunctionName); attemptedNames.add(initFunctionName);
tag = conf.getParentTag(tag.intValue()); tag = conf.getParentTag(tag.intValue());
} }
} }
VConsole.log("No JavaScript init for connector not found");
getLogger().info("No JavaScript init for connector found");
showInitProblem(attemptedNames); showInitProblem(attemptedNames);
return false; return false;
} }
public String getInitFunctionName() { public String getInitFunctionName() {
return initFunctionName; return initFunctionName;
} }

public static Logger getLogger() {
return Logger.getLogger(JavaScriptConnectorHelper.class.getName());
}
} }

+ 44
- 26
client/src/com/vaadin/client/LayoutManager.java View File

import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;


import com.google.gwt.core.client.Duration; import com.google.gwt.core.client.Duration;
} }
layoutCounts.put(layout.getConnectorId(), count); layoutCounts.put(layout.getConnectorId(), count);
if (count.intValue() > 2) { if (count.intValue() > 2) {
VConsole.error(Util.getConnectorString(layout)
+ " has been layouted " + count.intValue() + " times");
getLogger().severe(
Util.getConnectorString(layout) + " has been layouted "
+ count.intValue() + " times");
} }
} }


} }


private void doLayout() { private void doLayout() {
VConsole.log("Starting layout phase");
getLogger().info("Starting layout phase");
Profiler.enter("LayoutManager phase init"); Profiler.enter("LayoutManager phase init");


FastStringMap<Integer> layoutCounts = FastStringMap.create(); FastStringMap<Integer> layoutCounts = FastStringMap.create();


everythingNeedsMeasure = false; everythingNeedsMeasure = false;
if (measuredConnectorCount == 0) { if (measuredConnectorCount == 0) {
VConsole.log("No more changes in pass " + passes);
getLogger().info("No more changes in pass " + passes);
Profiler.leave("Layout pass"); Profiler.leave("Layout pass");
break; break;
} }
Profiler.leave(key); Profiler.leave(key);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error in resize listener", e);
} }
} }
Profiler.leave("Layout fire resize events - listeners not null"); Profiler.leave("Layout fire resize events - listeners not null");
Profiler.leave(key); Profiler.leave(key);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
VConsole.error(e);
getLogger().log(Level.SEVERE,
"Error in ManagedLayout handling", e);
} }
countLayout(layoutCounts, cl); countLayout(layoutCounts, cl);
} else { } else {
Profiler.leave(key); Profiler.leave(key);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
VConsole.error(e);
getLogger()
.log(Level.SEVERE,
"Error in SimpleManagedLayout (horizontal) handling",
e);

} }
countLayout(layoutCounts, rr); countLayout(layoutCounts, rr);
} }
Profiler.leave(key); Profiler.leave(key);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
VConsole.error(e);
getLogger()
.log(Level.SEVERE,
"Error in DirectionalManagedLayout handling",
e);
} }
countLayout(layoutCounts, cl); countLayout(layoutCounts, cl);
} else { } else {
Profiler.leave(key); Profiler.leave(key);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
VConsole.error(e);
getLogger()
.log(Level.SEVERE,
"Error in SimpleManagedLayout (vertical) handling",
e);
} }
countLayout(layoutCounts, rr); countLayout(layoutCounts, rr);
} }
b.append(connectorString); b.append(connectorString);
} }
} }
VConsole.log(b.toString());
getLogger().info(b.toString());
} }


Profiler.leave("Layout pass"); Profiler.leave("Layout pass");


VConsole.log("Pass " + passes + " measured "
+ measuredConnectorCount + " elements, fired "
+ firedListeners + " listeners and did " + layoutCount
+ " layouts.");
getLogger()
.info("Pass " + passes + " measured "
+ measuredConnectorCount + " elements, fired "
+ firedListeners + " listeners and did "
+ layoutCount + " layouts.");


if (passes > 100) { if (passes > 100) {
VConsole.log(LOOP_ABORT_MESSAGE);
getLogger().severe(LOOP_ABORT_MESSAGE);
if (ApplicationConfiguration.isDebugMode()) { if (ApplicationConfiguration.isDebugMode()) {
VNotification.createNotification( VNotification.createNotification(
VNotification.DELAY_FOREVER, VNotification.DELAY_FOREVER,


cleanMeasuredSizes(); cleanMeasuredSizes();


VConsole.log("Total layout phase time: "
+ totalDuration.elapsedMillis() + "ms");
getLogger().info(
"Total layout phase time: " + totalDuration.elapsedMillis()
+ "ms");
} }


private void logConnectorStatus(int connectorId) { private void logConnectorStatus(int connectorId) {
} }


if (debugLogging) { if (debugLogging) {
VConsole.log("Doing overflow fix for "
+ Util.getConnectorString(componentConnector)
+ " in "
+ Util.getConnectorString(componentConnector
.getParent()));
getLogger()
.info("Doing overflow fix for "
+ Util.getConnectorString(componentConnector)
+ " in "
+ Util.getConnectorString(componentConnector
.getParent()));
} }
Profiler.enter("Overflow fix apply"); Profiler.enter("Overflow fix apply");


Profiler.leave("Overflow fix restore"); Profiler.leave("Overflow fix restore");


if (!pendingOverflowFixes.isEmpty()) { if (!pendingOverflowFixes.isEmpty()) {
VConsole.log("Did overflow fix for " + remainingCount
+ " elements");
getLogger().info(
"Did overflow fix for " + remainingCount + " elements");
} }
pendingOverflowFixes = delayedOverflowFixes; pendingOverflowFixes = delayedOverflowFixes;
} }
measuredAndUpdate(element, getMeasuredSize(element, null)); measuredAndUpdate(element, getMeasuredSize(element, null));
} }
Profiler.leave("LayoutManager.measureNonConenctors"); Profiler.leave("LayoutManager.measureNonConenctors");
VConsole.log("Measured " + measuredNonConnectorElements.size()
+ " non connector elements");
getLogger().info(
"Measured " + measuredNonConnectorElements.size()
+ " non connector elements");
} }


private MeasureResult measuredAndUpdate(Element element, private MeasureResult measuredAndUpdate(Element element,

+ 9
- 2
client/src/com/vaadin/client/MeasuredSize.java View File

*/ */
package com.vaadin.client; package com.vaadin.client;


import java.util.logging.Logger;

import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;


private void debugSizeChange(Element element, String sizeChangeType, private void debugSizeChange(Element element, String sizeChangeType,
String changedFrom, String changedTo) { String changedFrom, String changedTo) {
if (debugSizeChanges) { if (debugSizeChanges) {
VConsole.log(sizeChangeType + " has changed from " + changedFrom
+ " to " + changedTo + " for " + element.toString());
getLogger()
.info(sizeChangeType + " has changed from " + changedFrom
+ " to " + changedTo + " for " + element.toString());
} }
} }


return sizes1[0] != sizes2[0] || sizes1[2] != sizes2[2]; return sizes1[0] != sizes2[0] || sizes1[2] != sizes2[2];
} }


public static Logger getLogger() {
return Logger.getLogger(MeasuredSize.class.getName());
}

} }

+ 17
- 9
client/src/com/vaadin/client/SuperDevMode.java View File

*/ */
package com.vaadin.client; package com.vaadin.client;


import java.util.logging.Logger;

import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.http.client.UrlBuilder; import com.google.gwt.http.client.UrlBuilder;


private static void recompileWidgetsetAndStartInDevMode( private static void recompileWidgetsetAndStartInDevMode(
final String serverUrl) { final String serverUrl) {
VConsole.log("Recompiling widgetset using<br/>" + serverUrl
+ "<br/>and then reloading in super dev mode");
getLogger().info(
"Recompiling widgetset using<br/>" + serverUrl
+ "<br/>and then reloading in super dev mode");
VNotification n = new VNotification(); VNotification n = new VNotification();
n.show("<b>Recompiling widgetset, please wait</b>", n.show("<b>Recompiling widgetset, please wait</b>",
VNotification.CENTERED, VNotification.STYLE_SYSTEM); VNotification.CENTERED, VNotification.STYLE_SYSTEM);


@Override @Override
public void onSuccess(RecompileResult result) { public void onSuccess(RecompileResult result) {
VConsole.log("JSONP compile call successful");
getLogger().fine("JSONP compile call successful");


if (!result.ok()) { if (!result.ok()) {
VConsole.log("* result: " + result);
getLogger().fine("* result: " + result);
failed(); failed();
return; return;
} }
serverUrl)); serverUrl));
setSession(SKIP_RECOMPILE, "1"); setSession(SKIP_RECOMPILE, "1");


VConsole.log("* result: OK. Reloading");
getLogger().fine("* result: OK. Reloading");
Location.reload(); Location.reload();
} }


@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
VConsole.error("JSONP compile call failed");
getLogger().severe("JSONP compile call failed");
// Don't log exception as they are shown as // Don't log exception as they are shown as
// notifications // notifications
VConsole.error(caught.getClass().getSimpleName() + ": "
+ caught.getMessage());
getLogger().severe(
caught.getClass().getSimpleName() + ": "
+ caught.getMessage());
failed(); failed();


} }
} }


if (hasSession(SKIP_RECOMPILE)) { if (hasSession(SKIP_RECOMPILE)) {
VConsole.log("Running in SuperDevMode");
getLogger().info("Running in SuperDevMode");
// When we get here, we are running in super dev mode // When we get here, we are running in super dev mode


// Remove the flag so next reload will recompile // Remove the flag so next reload will recompile
VNotification n = new VNotification(); VNotification n = new VNotification();
n.show(message, VNotification.CENTERED_TOP, VNotification.STYLE_SYSTEM); n.show(message, VNotification.CENTERED_TOP, VNotification.STYLE_SYSTEM);
} }

public static Logger getLogger() {
return Logger.getLogger(SuperDevMode.class.getName());
}
} }

+ 15
- 7
client/src/com/vaadin/client/Util.java View File

import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
ApplicationConnection c) { ApplicationConnection c) {
ServerConnector connector = ConnectorMap.get(c).getConnector(id); ServerConnector connector = ConnectorMap.get(c).getConnector(id);
if (connector != null) { if (connector != null) {
VConsole.log("\t" + id + " (" + connector.getClass() + ") :");
getLogger().info("\t" + id + " (" + connector.getClass() + ") :");
} else { } else {
VConsole.log("\t" + id
+ ": Warning: no corresponding connector for id " + id);
getLogger().warning(
"\t" + id + ": Warning: no corresponding connector for id "
+ id);
} }
for (MethodInvocation invocation : invocations) { for (MethodInvocation invocation : invocations) {
Object[] parameters = invocation.getParameters(); Object[] parameters = invocation.getParameters();
formattedParams = (null != parameters) ? Arrays formattedParams = (null != parameters) ? Arrays
.toString(parameters) : null; .toString(parameters) : null;
} }
VConsole.log("\t\t" + invocation.getInterfaceName() + "."
+ invocation.getMethodName() + "(" + formattedParams + ")");
getLogger().info(
"\t\t" + invocation.getInterfaceName() + "."
+ invocation.getMethodName() + "("
+ formattedParams + ")");
} }
} }


static void logVariableBurst(ApplicationConnection c, static void logVariableBurst(ApplicationConnection c,
Collection<MethodInvocation> loggedBurst) { Collection<MethodInvocation> loggedBurst) {
try { try {
VConsole.log("Variable burst to be sent to server:");
getLogger().info("Variable burst to be sent to server:");
String curId = null; String curId = null;
ArrayList<MethodInvocation> invocations = new ArrayList<MethodInvocation>(); ArrayList<MethodInvocation> invocations = new ArrayList<MethodInvocation>();
for (MethodInvocation methodInvocation : loggedBurst) { for (MethodInvocation methodInvocation : loggedBurst) {
printConnectorInvocations(invocations, curId, c); printConnectorInvocations(invocations, curId, c);
} }
} catch (Exception e) { } catch (Exception e) {
VConsole.error(e);
getLogger().log(Level.SEVERE, "Error sending variable burst", e);
} }
} }


return JSON.parse(jsonAsString); return JSON.parse(jsonAsString);
}-*/; }-*/;


public static Logger getLogger() {
return Logger.getLogger(Util.class.getName());
}
} }

+ 8
- 1
client/src/com/vaadin/client/VCaption.java View File



package com.vaadin.client; package com.vaadin.client;


import java.util.logging.Logger;

import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
if (owner != null) { if (owner != null) {
Util.notifyParentOfSizeChange(owner.getWidget(), true); Util.notifyParentOfSizeChange(owner.getWidget(), true);
} else { } else {
VConsole.log("Warning: Icon load event was not propagated because VCaption owner is unknown.");
getLogger()
.warning(
"Warning: Icon load event was not propagated because VCaption owner is unknown.");
} }
} }
} }


} }


public static Logger getLogger() {
return Logger.getLogger(VCaption.class.getName());
}
} }

+ 8
- 1
client/src/com/vaadin/client/WidgetSet.java View File



package com.vaadin.client; package com.vaadin.client;


import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.vaadin.client.communication.HasJavaScriptConnectorHelper; import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
import com.vaadin.client.metadata.BundleLoadCallback; import com.vaadin.client.metadata.BundleLoadCallback;


@Override @Override
public void failed(Throwable reason) { public void failed(Throwable reason) {
VConsole.error(reason);
getLogger().log(Level.SEVERE, "Error loading bundle",
reason);
ApplicationConfiguration.endDependencyLoading(); ApplicationConfiguration.endDependencyLoading();
} }
}); });
} }
} }


public static Logger getLogger() {
return Logger.getLogger(WidgetSet.class.getName());
}
} }

+ 25
- 18
client/src/com/vaadin/client/communication/AtmospherePushConnection.java View File

package com.vaadin.client.communication; package com.vaadin.client.communication;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Logger;


import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.vaadin.client.ResourceLoader; import com.vaadin.client.ResourceLoader;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.ResourceLoader.ResourceLoadListener;
import com.vaadin.client.VConsole;
import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.Version; import com.vaadin.shared.Version;
import com.vaadin.shared.communication.PushConstants; import com.vaadin.shared.communication.PushConstants;
// uri is needed to identify the right connection when closing // uri is needed to identify the right connection when closing
uri = SharedUtil.addGetParameters(baseUrl, extraParams); uri = SharedUtil.addGetParameters(baseUrl, extraParams);


VConsole.log("Establishing push connection");
getLogger().info("Establishing push connection");
socket = doConnect(uri, getConfig()); socket = doConnect(uri, getConfig());
} }


switch (state) { switch (state) {
case CONNECT_PENDING: case CONNECT_PENDING:
assert isActive(); assert isActive();
VConsole.log("Queuing push message: " + message.toJson());
getLogger().info("Queuing push message: " + message.toJson());
messageQueue.add(message); messageQueue.add(message);
break; break;
case CONNECTED: case CONNECTED:
assert isActive(); assert isActive();
VConsole.log("Sending push message: " + message.toJson());
getLogger().info("Sending push message: " + message.toJson());


if (transport.equals("websocket")) { if (transport.equals("websocket")) {
FragmentedMessage fragmented = new FragmentedMessage( FragmentedMessage fragmented = new FragmentedMessage(
} }


protected void onReopen(AtmosphereResponse response) { protected void onReopen(AtmosphereResponse response) {
VConsole.log("Push connection re-established using "
+ response.getTransport());
getLogger().info(
"Push connection re-established using "
+ response.getTransport());
onConnect(response); onConnect(response);
} }


protected void onOpen(AtmosphereResponse response) { protected void onOpen(AtmosphereResponse response) {
VConsole.log("Push connection established using "
+ response.getTransport());
getLogger().info(
"Push connection established using " + response.getTransport());
onConnect(response); onConnect(response);
} }


break; break;
case CONNECTED: case CONNECTED:
// Normal disconnect // Normal disconnect
VConsole.log("Closing push connection");
getLogger().info("Closing push connection");
doDisconnect(uri); doDisconnect(uri);
state = State.DISCONNECTED; state = State.DISCONNECTED;
command.execute(); command.execute();
protected void onMessage(AtmosphereResponse response) { protected void onMessage(AtmosphereResponse response) {
String message = response.getResponseBody(); String message = response.getResponseBody();
if (message.startsWith("for(;;);")) { if (message.startsWith("for(;;);")) {
VConsole.log("Received push message: " + message);
getLogger().info("Received push message: " + message);
// "for(;;);[{json}]" -> "{json}" // "for(;;);[{json}]" -> "{json}"
message = message.substring(9, message.length() - 1); message = message.substring(9, message.length() - 1);
connection.handlePushMessage(message); connection.handlePushMessage(message);
* tried * tried
*/ */
protected void onTransportFailure() { protected void onTransportFailure() {
VConsole.log("Push connection using primary method ("
+ getConfig().getTransport() + ") failed. Trying with "
+ getConfig().getFallbackTransport());
getLogger().warning(
"Push connection using primary method ("
+ getConfig().getTransport() + ") failed. Trying with "
+ getConfig().getFallbackTransport());
} }


/** /**
} }


protected void onClose(AtmosphereResponse response) { protected void onClose(AtmosphereResponse response) {
VConsole.log("Push connection closed");
getLogger().info("Push connection closed");
state = State.CONNECT_PENDING; state = State.CONNECT_PENDING;
} }


protected void onReconnect(JavaScriptObject request, protected void onReconnect(JavaScriptObject request,
final AtmosphereResponse response) { final AtmosphereResponse response) {
if (state == State.CONNECTED) { if (state == State.CONNECTED) {
VConsole.log("No onClose was received before reconnect. Forcing state to closed.");
getLogger()
.fine("No onClose was received before reconnect. Forcing state to closed.");
state = State.CONNECT_PENDING; state = State.CONNECT_PENDING;
} }
VConsole.log("Reopening push connection");
getLogger().info("Reopening push connection");
} }


public static abstract class AbstractJSO extends JavaScriptObject { public static abstract class AbstractJSO extends JavaScriptObject {
} else { } else {
final String pushJs = getVersionedPushJs(); final String pushJs = getVersionedPushJs();


VConsole.log("Loading " + pushJs);
getLogger().info("Loading " + pushJs);
ResourceLoader.get().loadScript( ResourceLoader.get().loadScript(
connection.getConfiguration().getVaadinDirUrl() + pushJs, connection.getConfiguration().getVaadinDirUrl() + pushJs,
new ResourceLoadListener() { new ResourceLoadListener() {
@Override @Override
public void onLoad(ResourceLoadEvent event) { public void onLoad(ResourceLoadEvent event) {
if (isAtmosphereLoaded()) { if (isAtmosphereLoaded()) {
VConsole.log(pushJs + " loaded");
getLogger().info(pushJs + " loaded");
command.execute(); command.execute();
} else { } else {
// If bootstrap tried to load vaadinPush.js, // If bootstrap tried to load vaadinPush.js,
public String getTransportType() { public String getTransportType() {
return transport; return transport;
} }

public static Logger getLogger() {
return Logger.getLogger(AtmospherePushConnection.class.getName());
}
} }

+ 5
- 2
client/src/com/vaadin/client/communication/RpcManager.java View File

package com.vaadin.client.communication; package com.vaadin.client.communication;


import java.util.Collection; import java.util.Collection;
import java.util.logging.Logger;


import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ConnectorMap; import com.vaadin.client.ConnectorMap;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.VConsole;
import com.vaadin.client.metadata.Method; import com.vaadin.client.metadata.Method;
import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Type; import com.vaadin.client.metadata.Type;
} }


parseMethodParameters(invocation, parametersJson, connection); parseMethodParameters(invocation, parametersJson, connection);
VConsole.log("Server to client RPC call: " + invocation);
getLogger().info("Server to client RPC call: " + invocation);
applyInvocation(invocation, connector); applyInvocation(invocation, connector);
} }


methodInvocation.setParameters(parameters); methodInvocation.setParameters(parameters);
} }


public static Logger getLogger() {
return Logger.getLogger(RpcManager.class.getName());
}
} }

+ 7
- 2
client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java View File

import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.JsArrayObject; import com.vaadin.client.JsArrayObject;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.VConsole;
import com.vaadin.client.WidgetUtil; import com.vaadin.client.WidgetUtil;
import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.Property;
} }
} catch (NoDataException e) { } catch (NoDataException e) {
html += "<div>Could not read state, error has been logged to the console</div>"; html += "<div>Could not read state, error has been logged to the console</div>";
VConsole.error(e);
getLogger().log(Level.SEVERE, "Could not read state", e);
} }


clear(); clear();
public void clearContents() { public void clearContents() {
clear(); clear();
} }

public static Logger getLogger() {
return Logger.getLogger(ConnectorInfoPanel.class.getName());
}
} }

+ 6
- 2
client/src/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java View File



import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger;


import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VConsole;
import com.vaadin.client.ui.UnknownComponentConnector; import com.vaadin.client.ui.UnknownComponentConnector;


/** /**
tag++; tag++;
if (tag > 10000) { if (tag > 10000) {
// Sanity check // Sanity check
VConsole.error("Search for used connector classes was forcefully terminated");
getLogger()
.severe("Search for used connector classes was forcefully terminated");
break; break;
} }
} }
return s; return s;
} }


public static Logger getLogger() {
return Logger.getLogger(OptimizedWidgetsetPanel.class.getName());
}
} }

Loading…
Cancel
Save