summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-05-10 16:53:33 +0300
committerLeif Åstrand <leif@vaadin.com>2013-05-10 16:53:33 +0300
commit42d94768bfacb3d831e125ae33eeb4b9fa1d8a53 (patch)
treea09cd9d99d1be99dd6600a90db07fb08d15af28a /server/src
parent762c924a8bf05f57b8af7108d7bb6a9c59dcc6c6 (diff)
parent19e27a15ca765de477fbe929a1cb6a7412c523f7 (diff)
downloadvaadin-framework-42d94768bfacb3d831e125ae33eeb4b9fa1d8a53.tar.gz
vaadin-framework-42d94768bfacb3d831e125ae33eeb4b9fa1d8a53.zip
Merge changes from origin/7.0
7d9f544 Test for #11396 (merged from 6.8 branch). Depends on a blur event so cannot be autotested with TB. 1b18807 Remove pre-loader element after pre-loading, fixes #10863 ce9c818 Instead of applying workaround to the root panel, apply it to the sub window content element instead to prevent scrolling of the document when a sub window is removed. #11713 (#10776) 3f5d022 Liferay 6.2 compatibility (#11751) ffd1c1b Don't ignore child component margins in AbstractOrderedLayout (#11553) 62ae5e1 More verbose output from running Jetty 21d9b67 Add a large number of debug calls to VFilterSelect (disabled by default) bdb7931 Merge test for #11623 to 7.0. 19e27a1 Move suggestion popup width calculation from connector to VFilterSelect Change-Id: I2d980126599e55fa5e4f6ec523dca16ba54107b5
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java69
1 files changed, 63 insertions, 6 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index b383878f28..327ce78a6c 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -17,6 +17,7 @@ package com.vaadin.server;
import java.io.IOException;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Map;
@@ -40,7 +41,7 @@ import javax.portlet.ResourceResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
-import com.liferay.portal.kernel.util.PortalClassInvoker;
+import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.vaadin.server.communication.PortletDummyRequestHandler;
import com.vaadin.server.communication.PortletUIInitHandler;
@@ -171,19 +172,75 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
return PropsUtil.get(name);
}
+ /**
+ * Simplified version of what Liferay PortalClassInvoker did. This is
+ * used because the API of PortalClassInvoker has changed in Liferay
+ * 6.2.
+ *
+ * This simply uses reflection with Liferay class loader. Parameters are
+ * Strings to avoid static dependencies and to load all classes with
+ * Liferay's own class loader. Only static utility methods are
+ * supported.
+ *
+ * This method is for internal use only and may change in future
+ * versions.
+ *
+ * @param className
+ * name of the Liferay class to call
+ * @param methodName
+ * name of the method to call
+ * @param parameterClassName
+ * name of the parameter class of the method
+ * @throws Exception
+ * @return return value of the invoked method
+ */
+ private static Object invokeStaticLiferayMethod(String className,
+ String methodName, Object argument, String parameterClassName)
+ throws Exception {
+ Thread currentThread = Thread.currentThread();
+
+ ClassLoader contextClassLoader = currentThread
+ .getContextClassLoader();
+
+ try {
+ // this should be available across all Liferay versions with no
+ // problematic static dependencies
+ ClassLoader portalClassLoader = PortalClassLoaderUtil
+ .getClassLoader();
+ // this is in case the class loading triggers code that
+ // explicitly
+ // uses current thread class loader
+ currentThread.setContextClassLoader(portalClassLoader);
+
+ Class<?> targetClass = portalClassLoader.loadClass(className);
+ Class<?> parameterClass = portalClassLoader
+ .loadClass(parameterClassName);
+ Method method = targetClass.getMethod(methodName,
+ parameterClass);
+
+ return method.invoke(null, new Object[] { argument });
+ } catch (InvocationTargetException ite) {
+ throw (Exception) ite.getCause();
+ } finally {
+ currentThread.setContextClassLoader(contextClassLoader);
+ }
+ }
+
private static HttpServletRequest getOriginalRequest(
PortletRequest request) {
try {
// httpRequest = PortalUtil.getHttpServletRequest(request);
- HttpServletRequest httpRequest = (HttpServletRequest) PortalClassInvoker
- .invoke("com.liferay.portal.util.PortalUtil",
- "getHttpServletRequest", request);
+ HttpServletRequest httpRequest = (HttpServletRequest) invokeStaticLiferayMethod(
+ "com.liferay.portal.util.PortalUtil",
+ "getHttpServletRequest", request,
+ "javax.portlet.PortletRequest");
// httpRequest =
// PortalUtil.getOriginalServletRequest(httpRequest);
- httpRequest = (HttpServletRequest) PortalClassInvoker.invoke(
+ httpRequest = (HttpServletRequest) invokeStaticLiferayMethod(
"com.liferay.portal.util.PortalUtil",
- "getOriginalServletRequest", httpRequest);
+ "getOriginalServletRequest", httpRequest,
+ "javax.servlet.http.HttpServletRequest");
return httpRequest;
} catch (Exception e) {
throw new IllegalStateException("Liferay request not detected",