summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-04-16 13:00:52 +0300
committerLeif Åstrand <leif@vaadin.com>2012-04-16 13:00:52 +0300
commit4155cb0d2c9e9ebe27d726ac38227ff7f0648bd7 (patch)
treedf5518919bd9151395993a2be3401d60e06f286d /src
parent00ef3eff62a9719ae83f802b17dc4b1e501440a8 (diff)
downloadvaadin-framework-4155cb0d2c9e9ebe27d726ac38227ff7f0648bd7.tar.gz
vaadin-framework-4155cb0d2c9e9ebe27d726ac38227ff7f0648bd7.zip
Remove classloader field to make Application serializable (#8644)
The ClassLoader for loading Root instances is instead fetched using request.getDeploymentConfiguration().getClassLoader();
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/Application.java48
-rw-r--r--src/com/vaadin/terminal/DeploymentConfiguration.java9
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java8
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java10
4 files changed, 32 insertions, 43 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index 448daea4c0..4da1d52c00 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -40,6 +40,7 @@ import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.AbstractErrorMessage;
import com.vaadin.terminal.ApplicationResource;
import com.vaadin.terminal.CombinedRequest;
+import com.vaadin.terminal.DeploymentConfiguration;
import com.vaadin.terminal.RequestHandler;
import com.vaadin.terminal.Terminal;
import com.vaadin.terminal.VariableOwner;
@@ -343,8 +344,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
private final boolean productionMode;
- private final ClassLoader classLoader;
-
/**
* @param applicationUrl
* the URL the application should respond to.
@@ -356,19 +355,14 @@ public class Application implements Terminal.ErrorListener, Serializable {
* @param productionMode
* flag indicating whether the application is running in
* production mode.
- * @param classLoader
- * class loader to use for loading Root classes,
- * <code>null</code> indicates that the default class loader
- * should be used.
*/
public ApplicationStartEvent(URL applicationUrl,
Properties applicationProperties, ApplicationContext context,
- boolean productionMode, ClassLoader classLoader) {
+ boolean productionMode) {
this.applicationUrl = applicationUrl;
this.applicationProperties = applicationProperties;
this.context = context;
this.productionMode = productionMode;
- this.classLoader = classLoader;
}
/**
@@ -417,19 +411,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
public boolean isProductionMode() {
return productionMode;
}
-
- /**
- * Gets the class loader to use for loading Root classes,
- * <code>null</code> indicates that the default class loader should be
- * used.
- *
- * @return the class loader, or <code>null</code> if not defined.
- *
- * @see Application#getClassLoader()
- */
- public ClassLoader getClassLoader() {
- return classLoader;
- }
}
private final static Logger logger = Logger.getLogger(Application.class
@@ -522,11 +503,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
private Set<Integer> initedRoots = new HashSet<Integer>();
/**
- * The classloader that is used to load {@link Root} classes.
- */
- private ClassLoader classLoader;
-
- /**
* Gets the user of the application.
*
* <p>
@@ -640,7 +616,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
productionMode = event.isProductionMode();
properties = event.getApplicationProperties();
context = event.getContext();
- classLoader = event.getClassLoader();
init();
applicationIsRunning = true;
}
@@ -1867,9 +1842,9 @@ public class Application implements Terminal.ErrorListener, Serializable {
* The default implementation in {@link Application} creates a new instance
* of the Root class returned by {@link #getRootClassName(WrappedRequest)},
* which in turn uses the {@value #ROOT_PARAMETER} parameter from web.xml.
- * If {@link #getClassLoader()} returns a {@link ClassLoader}, it is used
- * for loading the Root class. Otherwise the {@link ClassLoader} used to
- * load this class is used.
+ * If {@link DeploymentConfiguration#getClassLoader()} for the request
+ * returns a {@link ClassLoader}, it is used for loading the Root class.
+ * Otherwise the {@link ClassLoader} used to load this class is used.
* </p>
*
* @param request
@@ -1890,7 +1865,8 @@ public class Application implements Terminal.ErrorListener, Serializable {
throws RootRequiresMoreInformationException {
String rootClassName = getRootClassName(request);
try {
- ClassLoader classLoader = getClassLoader();
+ ClassLoader classLoader = request.getDeploymentConfiguration()
+ .getClassLoader();
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
@@ -1910,16 +1886,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
}
/**
- * Get the class loader to use for loading Root classes. <code>null</code>
- * indicates that the default class loader should be used.
- *
- * @return the class loader to use, or <code>null</code>
- */
- protected ClassLoader getClassLoader() {
- return classLoader;
- }
-
- /**
* Provides the name of the <code>Root</code> class that should be used for
* a request. The class must have an accessible no-args constructor.
* <p>
diff --git a/src/com/vaadin/terminal/DeploymentConfiguration.java b/src/com/vaadin/terminal/DeploymentConfiguration.java
index 403a6d68b7..02a3f0200f 100644
--- a/src/com/vaadin/terminal/DeploymentConfiguration.java
+++ b/src/com/vaadin/terminal/DeploymentConfiguration.java
@@ -74,4 +74,13 @@ public interface DeploymentConfiguration extends Serializable {
*/
public String getApplicationOrSystemProperty(String propertyName,
String defaultValue);
+
+ /**
+ * Get the class loader to use for loading classes loaded by name, e.g.
+ * custom Root classes. <code>null</code> indicates that the default class
+ * loader should be used.
+ *
+ * @return the class loader to use, or <code>null</code>
+ */
+ public ClassLoader getClassLoader();
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 72a0432f4b..8235859758 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -287,6 +287,12 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
return "/html";
}
}
+
+ public ClassLoader getClassLoader() {
+ // Custom class loaders not currently supported in portlets (see
+ // #8574)
+ return null;
+ }
};
@Override
@@ -857,7 +863,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
application.setLocale(locale);
// No application URL when running inside a portlet
application.start(new ApplicationStartEvent(null,
- applicationProperties, context, isProductionMode(), null));
+ applicationProperties, context, isProductionMode()));
}
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
index c295e05ed7..18cc3f97f4 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
@@ -171,6 +171,14 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
public boolean isStandalone(WrappedRequest request) {
return true;
}
+
+ public ClassLoader getClassLoader() {
+ try {
+ return AbstractApplicationServlet.this.getClassLoader();
+ } catch (ServletException e) {
+ throw new RuntimeException(e);
+ }
+ }
};
static final String UPLOAD_URL_PREFIX = "APP/UPLOAD/";
@@ -1037,7 +1045,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
application.setLocale(locale);
application.start(new ApplicationStartEvent(applicationUrl,
applicationProperties, webApplicationContext,
- isProductionMode(), getClassLoader()));
+ isProductionMode()));
}
}