diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-21 13:33:44 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-05-21 13:33:44 +0300 |
commit | 778de066b1f8b1608b40bdd98b61b6fee078442d (patch) | |
tree | 775cddd66437e673eea226287c06d4d8eef9e016 /server/src/com/vaadin/util | |
parent | 42c4b2097bc955ca18107c449e04f0d5d5683ca3 (diff) | |
download | vaadin-framework-778de066b1f8b1608b40bdd98b61b6fee078442d.tar.gz vaadin-framework-778de066b1f8b1608b40bdd98b61b6fee078442d.zip |
Derive current servlet/portlet from the current service (#11779)
Implement VaadinPortlet.getCurrent() to use VaadinService.getCurrent()
instead of having a separate thread local variable. This is done to
avoid classloading issues when determining which instances to preserve
in CurrentInstance.setThreadLocals. The two current instances have
previously been kept in sync in all cases except during
VaadinPortlet.init where VaadinService has not yet been created.
VaadinPortlet.setCurrent() is removed as no way of preserving its
semantics has been found. This breaks API compatibility, but is probably
better than having a deprecated implementation that can not work as
expected in all situations.
The same changes have also been made to VaadinServlet to maintain the
symmetry.
Change-Id: I0a1ccc07a4aeecec558a9aaae211bd56207313d8
Diffstat (limited to 'server/src/com/vaadin/util')
-rw-r--r-- | server/src/com/vaadin/util/CurrentInstance.java | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/server/src/com/vaadin/util/CurrentInstance.java b/server/src/com/vaadin/util/CurrentInstance.java index 60489d596e..0854d422fd 100644 --- a/server/src/com/vaadin/util/CurrentInstance.java +++ b/server/src/com/vaadin/util/CurrentInstance.java @@ -22,12 +22,10 @@ import java.util.Map; import java.util.Map.Entry; import com.vaadin.server.VaadinPortlet; -import com.vaadin.server.VaadinPortletService; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinServlet; -import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; import com.vaadin.ui.UI; @@ -52,18 +50,6 @@ public class CurrentInstance implements Serializable { private final Object instance; private final boolean inheritable; - private static boolean portletAvailable = false; - { - try { - /* - * VaadinPortlet depends on portlet API which is available only if - * running in a portal. - */ - portletAvailable = (VaadinPortlet.class.getName() != null); - } catch (Throwable t) { - } - } - private static InheritableThreadLocal<Map<Class<?>, CurrentInstance>> instances = new InheritableThreadLocal<Map<Class<?>, CurrentInstance>>() { @Override protected Map<Class<?>, CurrentInstance> childValue( @@ -236,18 +222,6 @@ public class CurrentInstance implements Serializable { VaadinSession.setCurrent(session); VaadinService.setCurrent(service); - if (service instanceof VaadinServletService) { - old.put(VaadinServlet.class, - new CurrentInstance(VaadinServlet.getCurrent(), true)); - VaadinServlet.setCurrent(((VaadinServletService) service) - .getServlet()); - } else if (portletAvailable && service instanceof VaadinPortletService) { - old.put(VaadinPortlet.class, - new CurrentInstance(VaadinPortlet.getCurrent(), true)); - VaadinPortlet.setCurrent(((VaadinPortletService) service) - .getPortlet()); - } - return old; } } |