* ConnectorTracker.getConnector() is now DnDService-aware * Deprecated LCM.getDragAndDropService() is removed * LCM.getConnector() simply delegates to ConnectorTracker.getConnector() Change-Id: I9627d50f7386ead8d92ccbba27b4a558c03076c7tags/7.2.0.beta1
@@ -50,14 +50,14 @@ public class DragAndDropService implements VariableOwner, ClientConnector { | |||
private DragAndDropEvent dragEvent; | |||
private final LegacyCommunicationManager manager; | |||
private final VaadinSession session; | |||
private AcceptCriterion acceptCriterion; | |||
private ErrorHandler errorHandler; | |||
public DragAndDropService(LegacyCommunicationManager manager) { | |||
this.manager = manager; | |||
public DragAndDropService(VaadinSession session) { | |||
this.session = session; | |||
} | |||
@Override | |||
@@ -233,8 +233,8 @@ public class DragAndDropService implements VariableOwner, ClientConnector { | |||
outWriter.write(", \"dd\":"); | |||
JsonPaintTarget jsonPaintTarget = new JsonPaintTarget(manager, | |||
outWriter, false); | |||
JsonPaintTarget jsonPaintTarget = new JsonPaintTarget( | |||
session.getCommunicationManager(), outWriter, false); | |||
jsonPaintTarget.startTag("dd"); | |||
jsonPaintTarget.addAttribute("visitId", lastVisitId); | |||
if (acceptCriterion != null) { |
@@ -62,9 +62,6 @@ public class LegacyCommunicationManager implements Serializable { | |||
*/ | |||
private final VaadinSession session; | |||
// TODO Move to VaadinSession (#11409) | |||
private DragAndDropService dragAndDropService; | |||
// TODO Refactor (#11412) | |||
private String requestThemeName; | |||
@@ -277,28 +274,14 @@ public class LegacyCommunicationManager implements Serializable { | |||
} | |||
/** | |||
* @deprecated As of 7.1. See #11411. | |||
* @deprecated As of 7.1. In 7.2 and later, use | |||
* {@link ConnectorTracker#getConnector(String) | |||
* uI.getConnectorTracker().getConnector(connectorId)} instead. | |||
* See ticket #11411. | |||
*/ | |||
@Deprecated | |||
public ClientConnector getConnector(UI uI, String connectorId) { | |||
ClientConnector c = uI.getConnectorTracker().getConnector(connectorId); | |||
if (c == null | |||
&& connectorId.equals(getDragAndDropService().getConnectorId())) { | |||
return getDragAndDropService(); | |||
} | |||
return c; | |||
} | |||
/** | |||
* @deprecated As of 7.1. See #11409. | |||
*/ | |||
@Deprecated | |||
public DragAndDropService getDragAndDropService() { | |||
if (dragAndDropService == null) { | |||
dragAndDropService = new DragAndDropService(this); | |||
} | |||
return dragAndDropService; | |||
return uI.getConnectorTracker().getConnector(connectorId); | |||
} | |||
/** |
@@ -215,6 +215,8 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { | |||
protected WebBrowser browser = new WebBrowser(); | |||
private DragAndDropService dragAndDropService; | |||
private LegacyCommunicationManager communicationManager; | |||
private long cumulativeRequestDuration = 0; | |||
@@ -395,6 +397,13 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { | |||
return communicationManager; | |||
} | |||
public DragAndDropService getDragAndDropService() { | |||
if (dragAndDropService == null) { | |||
dragAndDropService = new DragAndDropService(this); | |||
} | |||
return dragAndDropService; | |||
} | |||
/** | |||
* Loads the VaadinSession for the given service and WrappedSession from the | |||
* HTTP session. |
@@ -271,8 +271,7 @@ public class FileUploadHandler implements RequestHandler { | |||
return true; | |||
} | |||
source = session.getCommunicationManager().getConnector(uI, | |||
connectorId); | |||
source = uI.getConnectorTracker().getConnector(connectorId); | |||
} finally { | |||
session.unlock(); | |||
} |
@@ -199,14 +199,16 @@ public class ServerRpcHandler implements Serializable { | |||
.getCommunicationManager(); | |||
try { | |||
ConnectorTracker connectorTracker = uI.getConnectorTracker(); | |||
Set<Connector> enabledConnectors = new HashSet<Connector>(); | |||
List<MethodInvocation> invocations = parseInvocations( | |||
uI.getConnectorTracker(), invocationsData, | |||
lastSyncIdSeenByClient); | |||
for (MethodInvocation invocation : invocations) { | |||
final ClientConnector connector = manager.getConnector(uI, | |||
invocation.getConnectorId()); | |||
final ClientConnector connector = connectorTracker | |||
.getConnector(invocation.getConnectorId()); | |||
if (connector != null && connector.isConnectorEnabled()) { | |||
enabledConnectors.add(connector); | |||
@@ -216,8 +218,8 @@ public class ServerRpcHandler implements Serializable { | |||
for (int i = 0; i < invocations.size(); i++) { | |||
MethodInvocation invocation = invocations.get(i); | |||
final ClientConnector connector = manager.getConnector(uI, | |||
invocation.getConnectorId()); | |||
final ClientConnector connector = connectorTracker | |||
.getConnector(invocation.getConnectorId()); | |||
if (connector == null) { | |||
getLogger() | |||
.log(Level.WARNING, |
@@ -285,9 +285,7 @@ public class UidlWriter implements Serializable { | |||
+ new JSONArray(styleDependencies).toString()); | |||
} | |||
if (manager.getDragAndDropService() != null) { | |||
manager.getDragAndDropService().printJSONResponse(writer); | |||
} | |||
session.getDragAndDropService().printJSONResponse(writer); | |||
for (ClientConnector connector : dirtyVisibleConnectors) { | |||
uiConnectorTracker.markClientSideInitialized(connector); |
@@ -35,6 +35,7 @@ import org.json.JSONObject; | |||
import com.vaadin.server.AbstractClientConnector; | |||
import com.vaadin.server.ClientConnector; | |||
import com.vaadin.server.DragAndDropService; | |||
import com.vaadin.server.GlobalResourceHandler; | |||
import com.vaadin.server.LegacyCommunicationManager; | |||
import com.vaadin.server.StreamVariable; | |||
@@ -271,8 +272,16 @@ public class ConnectorTracker implements Serializable { | |||
// Ignore connectors that have been unregistered but not yet cleaned up | |||
if (unregisteredConnectors.contains(connector)) { | |||
return null; | |||
} else if (connector != null) { | |||
return connector; | |||
} else { | |||
DragAndDropService service = uI.getSession() | |||
.getDragAndDropService(); | |||
if (connectorId.equals(service.getConnectorId())) { | |||
return service; | |||
} | |||
} | |||
return connector; | |||
return null; | |||
} | |||
/** |