session.unlock();
}
- Map<Class<?>, CurrentInstance> oldThreadLocals = CurrentInstance
- .setThreadLocals(ui);
+ Map<Class<?>, CurrentInstance> oldInstances = CurrentInstance
+ .setCurrent(ui);
try {
if (!connector.handleConnectorRequest(request, response, key)) {
return error(request, response, connector.getClass()
+ ") did not handle connector request for " + key);
}
} finally {
- CurrentInstance.restoreThreadLocals(oldThreadLocals);
+ CurrentInstance.restoreInstances(oldInstances);
}
return true;
+ " is not a valid global resource path");
}
session.lock();
- Map<Class<?>, CurrentInstance> oldThreadLocals = null;
+ Map<Class<?>, CurrentInstance> oldInstances = null;
DownloadStream stream = null;
try {
UI ui = session.getUIById(Integer.parseInt(uiid));
if (ui == null) {
return error(request, response, "No UI found for id " + uiid);
}
- oldThreadLocals = CurrentInstance.setThreadLocals(ui);
+ oldInstances = CurrentInstance.setCurrent(ui);
ConnectorResource resource;
if (LEGACY_TYPE.equals(type)) {
resource = legacyResources.get(key);
}
} finally {
session.unlock();
- if (oldThreadLocals != null) {
- CurrentInstance.restoreThreadLocals(oldThreadLocals);
+ if (oldInstances != null) {
+ CurrentInstance.restoreInstances(oldInstances);
}
}
Map<Class<?>, CurrentInstance> old = null;
lock();
try {
- old = CurrentInstance.setThreadLocals(this);
+ old = CurrentInstance.setCurrent(this);
runnable.run();
} finally {
unlock();
if (old != null) {
- CurrentInstance.restoreThreadLocals(old);
+ CurrentInstance.restoreInstances(old);
}
}
-
+
}
/**
while ((pendingAccess = pendingAccessQueue.poll()) != null) {
if (!pendingAccess.isCancelled()) {
CurrentInstance.clearAll();
- CurrentInstance
- .restoreThreadLocals(pendingAccess.instances);
+ CurrentInstance.restoreInstances(pendingAccess.instances);
accessSynchronously(pendingAccess);
}
}
} finally {
CurrentInstance.clearAll();
- CurrentInstance.restoreThreadLocals(oldInstances);
+ CurrentInstance.restoreInstances(oldInstances);
}
}
}
/**
- * Restores the given thread locals to the given values. Note that this
- * should only be used internally to restore Vaadin classes.
+ * Restores the given instances to the given values. Note that this should
+ * only be used internally to restore Vaadin classes.
+ *
+ * @since 7.1
*
* @param old
- * A Class -> Object map to set as thread locals
+ * A Class -> CurrentInstance map to set as current instances
*/
- public static void restoreThreadLocals(Map<Class<?>, CurrentInstance> old) {
+ public static void restoreInstances(Map<Class<?>, CurrentInstance> old) {
for (Class c : old.keySet()) {
CurrentInstance ci = old.get(c);
set(c, ci.instance, ci.inheritable);
/**
* Gets the currently set instances so that they can later be restored using
- * {@link #restoreThreadLocals(Map)}.
+ * {@link #restoreInstances(Map)}.
*
* @since 7.1
*
}
/**
- * Sets thread locals for the UI and all related classes
+ * Sets current instances for the UI and all related classes. The previously
+ * defined values can be restored by passing the returned map to
+ * {@link #restoreInstances(Map)}.
+ *
+ * @since 7.1
*
* @param ui
* The UI
- * @return A map containing the old values of the thread locals this method
+ * @return A map containing the old values of the instances that this method
* updated.
*/
- public static Map<Class<?>, CurrentInstance> setThreadLocals(UI ui) {
+ public static Map<Class<?>, CurrentInstance> setCurrent(UI ui) {
Map<Class<?>, CurrentInstance> old = new HashMap<Class<?>, CurrentInstance>();
old.put(UI.class, new CurrentInstance(UI.getCurrent(), true));
UI.setCurrent(ui);
- old.putAll(setThreadLocals(ui.getSession()));
+ old.putAll(setCurrent(ui.getSession()));
return old;
}
/**
- * Sets thread locals for the {@link VaadinSession} and all related classes
+ * Sets current instances for the {@link VaadinSession} and all related
+ * classes. The previously defined values can be restored by passing the
+ * returned map to {@link #restoreInstances(Map)}.
+ *
+ * @since 7.1
*
* @param session
* The VaadinSession
- * @return A map containing the old values of the thread locals this method
+ * @return A map containing the old values of the instances this method
* updated.
*/
- public static Map<Class<?>, CurrentInstance> setThreadLocals(
+ public static Map<Class<?>, CurrentInstance> setCurrent(
VaadinSession session) {
Map<Class<?>, CurrentInstance> old = new HashMap<Class<?>, CurrentInstance>();
old.put(VaadinSession.class,