summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/util/CurrentInstance.java
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-05-28 15:39:02 +0300
committerLeif Åstrand <leif@vaadin.com>2013-05-28 15:39:02 +0300
commitd34583895c884767537ad866de942d23c044af52 (patch)
tree5d3e693f3b0dfb2b12c7e337518e795f3d5bd7af /server/src/com/vaadin/util/CurrentInstance.java
parent2b5ba963af81bb8a21f51ab29bd47ecd0054daa6 (diff)
downloadvaadin-framework-d34583895c884767537ad866de942d23c044af52.tar.gz
vaadin-framework-d34583895c884767537ad866de942d23c044af52.zip
Remove ThreadLocal references from CurrentInstance (#11914)
Change-Id: Ic7389a06726026383b96de80b0d038ed11e9d273
Diffstat (limited to 'server/src/com/vaadin/util/CurrentInstance.java')
-rw-r--r--server/src/com/vaadin/util/CurrentInstance.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/server/src/com/vaadin/util/CurrentInstance.java b/server/src/com/vaadin/util/CurrentInstance.java
index 8e6ef8266e..b97bab3d8a 100644
--- a/server/src/com/vaadin/util/CurrentInstance.java
+++ b/server/src/com/vaadin/util/CurrentInstance.java
@@ -174,13 +174,15 @@ public class CurrentInstance implements Serializable {
}
/**
- * 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);
@@ -189,7 +191,7 @@ public class CurrentInstance implements Serializable {
/**
* Gets the currently set instances so that they can later be restored using
- * {@link #restoreThreadLocals(Map)}.
+ * {@link #restoreInstances(Map)}.
*
* @since 7.1
*
@@ -216,30 +218,38 @@ public class CurrentInstance implements Serializable {
}
/**
- * 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,