summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-24 15:44:08 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-24 16:01:46 +0300
commitded204acce46a009bac6d6562de43d5b6120e349 (patch)
tree74493e3e6e01f7f9cb600f626ee889e103003f03
parent0cd118248d77eeb197f2480ce59b35c6c3963e5c (diff)
downloadvaadin-framework-ded204acce46a009bac6d6562de43d5b6120e349.tar.gz
vaadin-framework-ded204acce46a009bac6d6562de43d5b6120e349.zip
Use event objects for future-proofing UIProvider API (#9721)
-rw-r--r--server/src/com/vaadin/server/AbstractCommunicationManager.java13
-rw-r--r--server/src/com/vaadin/server/BootstrapHandler.java15
-rw-r--r--server/src/com/vaadin/server/DefaultUIProvider.java3
-rw-r--r--server/src/com/vaadin/server/LegacyApplicationUIProvider.java26
-rw-r--r--server/src/com/vaadin/server/UIClassSelectionEvent.java39
-rw-r--r--server/src/com/vaadin/server/UICreateEvent.java54
-rw-r--r--server/src/com/vaadin/server/UIProvider.java61
-rw-r--r--server/src/com/vaadin/server/UIProviderEvent.java62
-rw-r--r--server/src/com/vaadin/server/VaadinPortletService.java4
-rw-r--r--server/src/com/vaadin/server/VaadinService.java13
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java5
-rw-r--r--uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java17
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java17
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java5
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java13
16 files changed, 259 insertions, 92 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java
index c631043507..ed3b73dc20 100644
--- a/server/src/com/vaadin/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java
@@ -2466,6 +2466,9 @@ public abstract class AbstractCommunicationManager implements Serializable {
List<UIProvider> uiProviders = vaadinService.getUIProviders(session);
+ UIClassSelectionEvent classSelectionEvent = new UIClassSelectionEvent(
+ request);
+
UIProvider provider = null;
Class<? extends UI> uiClass = null;
for (UIProvider p : uiProviders) {
@@ -2473,14 +2476,15 @@ public abstract class AbstractCommunicationManager implements Serializable {
if (p instanceof LegacyApplicationUIProvider) {
LegacyApplicationUIProvider legacyProvider = (LegacyApplicationUIProvider) p;
- UI existingUi = legacyProvider.getExistingUI(request);
+ UI existingUi = legacyProvider
+ .getExistingUI(classSelectionEvent);
if (existingUi != null) {
UI.setCurrent(existingUi);
return existingUi;
}
}
- uiClass = p.getUIClass(request);
+ uiClass = p.getUIClass(classSelectionEvent);
if (uiClass != null) {
provider = p;
break;
@@ -2523,7 +2527,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
// Explicit Class.cast to detect if the UIProvider does something
// unexpected
- UI ui = uiClass.cast(provider.createInstance(request, uiClass));
+ UICreateEvent event = new UICreateEvent(request, uiClass);
+ UI ui = uiClass.cast(provider.createInstance(event));
// Initialize some fields for a newly created UI
if (ui.getSession() != session) {
@@ -2540,7 +2545,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
session.addUI(ui);
// Remember if it should be remembered
- if (vaadinService.preserveUIOnRefresh(request, ui, provider)) {
+ if (vaadinService.preserveUIOnRefresh(provider, event)) {
// Remember this UI
String windowName = request.getBrowserDetails().getWindowName();
if (windowName == null) {
diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java
index d6c6d0e59b..dcd933945c 100644
--- a/server/src/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/com/vaadin/server/BootstrapHandler.java
@@ -119,11 +119,14 @@ public abstract class BootstrapHandler implements RequestHandler {
List<UIProvider> uiProviders = request.getVaadinService()
.getUIProviders(session);
+ UIClassSelectionEvent classSelectionEvent = new UIClassSelectionEvent(
+ request);
+
// Find UI provider and UI class
Class<? extends UI> uiClass = null;
UIProvider provider = null;
for (UIProvider p : uiProviders) {
- uiClass = p.getUIClass(request);
+ uiClass = p.getUIClass(classSelectionEvent);
// If we found something
if (uiClass != null) {
provider = p;
@@ -243,7 +246,8 @@ public abstract class BootstrapHandler implements RequestHandler {
.attr("content", "chrome=1");
String title = response.getUIProvider().getPageTitle(
- context.getRequest(), context.getUIClass());
+ new UICreateEvent(context.getRequest(), context
+ .getUIClass()));
if (title != null) {
head.appendElement("title").appendText(title);
}
@@ -285,8 +289,9 @@ public abstract class BootstrapHandler implements RequestHandler {
public String getWidgetsetForUI(BootstrapContext context) {
VaadinRequest request = context.getRequest();
+ UICreateEvent event = new UICreateEvent(context.getRequest(), context.getUIClass());
String widgetset = context.getBootstrapResponse().getUIProvider()
- .getWidgetset(context.getRequest(), context.getUIClass());
+ .getWidgetset(event);
if (widgetset == null) {
widgetset = request.getVaadinService().getConfiguredWidgetset(
request);
@@ -513,8 +518,8 @@ public abstract class BootstrapHandler implements RequestHandler {
* @return
*/
public String getThemeName(BootstrapContext context) {
- return context.getBootstrapResponse().getUIProvider()
- .getTheme(context.getRequest(), context.getUIClass());
+ UICreateEvent event = new UICreateEvent(context.getRequest(), context.getUIClass());
+ return context.getBootstrapResponse().getUIProvider().getTheme(event);
}
/**
diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java
index 85fc10e716..5ca479cc6d 100644
--- a/server/src/com/vaadin/server/DefaultUIProvider.java
+++ b/server/src/com/vaadin/server/DefaultUIProvider.java
@@ -21,7 +21,8 @@ import com.vaadin.ui.UI;
public class DefaultUIProvider extends UIProvider {
@Override
- public Class<? extends UI> getUIClass(VaadinRequest request) {
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
+ VaadinRequest request = event.getRequest();
Object uiClassNameObj = request.getVaadinService()
.getDeploymentConfiguration().getInitParameters()
.getProperty(VaadinSession.UI_PARAMETER);
diff --git a/server/src/com/vaadin/server/LegacyApplicationUIProvider.java b/server/src/com/vaadin/server/LegacyApplicationUIProvider.java
index a8c7cd230b..1b7161e33f 100644
--- a/server/src/com/vaadin/server/LegacyApplicationUIProvider.java
+++ b/server/src/com/vaadin/server/LegacyApplicationUIProvider.java
@@ -39,8 +39,8 @@ public abstract class LegacyApplicationUIProvider extends UIProvider {
.compile("^/?([^/]+).*");
@Override
- public Class<? extends UI> getUIClass(VaadinRequest request) {
- UI uiInstance = getUIInstance(request);
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
+ UI uiInstance = getUIInstance(event);
if (uiInstance != null) {
return uiInstance.getClass();
}
@@ -48,12 +48,12 @@ public abstract class LegacyApplicationUIProvider extends UIProvider {
}
@Override
- public UI createInstance(VaadinRequest request, Class<? extends UI> type) {
- return getUIInstance(request);
+ public UI createInstance(UICreateEvent event) {
+ return getUIInstance(event);
}
@Override
- public String getTheme(VaadinRequest request, Class<? extends UI> uiClass) {
+ public String getTheme(UICreateEvent event) {
LegacyApplication application = getApplication();
if (application != null) {
return application.getTheme();
@@ -63,17 +63,17 @@ public abstract class LegacyApplicationUIProvider extends UIProvider {
}
@Override
- public String getPageTitle(VaadinRequest request,
- Class<? extends UI> uiClass) {
- UI uiInstance = getUIInstance(request);
+ public String getPageTitle(UICreateEvent event) {
+ UI uiInstance = getUIInstance(event);
if (uiInstance != null) {
return uiInstance.getCaption();
} else {
- return super.getPageTitle(request, uiClass);
+ return super.getPageTitle(event);
}
}
- private UI getUIInstance(VaadinRequest request) {
+ private UI getUIInstance(UIProviderEvent event) {
+ VaadinRequest request = event.getRequest();
String pathInfo = request.getRequestPathInfo();
String name = null;
if (pathInfo != null && pathInfo.length() > 0) {
@@ -99,11 +99,11 @@ public abstract class LegacyApplicationUIProvider extends UIProvider {
* Hack used to return existing LegacyWindow instances without regard for
* out-of-sync problems.
*
- * @param request
+ * @param event
* @return
*/
- public UI getExistingUI(VaadinRequest request) {
- UI uiInstance = getUIInstance(request);
+ public UI getExistingUI(UIClassSelectionEvent event) {
+ UI uiInstance = getUIInstance(event);
if (uiInstance == null || uiInstance.getUIId() == -1) {
// Not initialized -> Let go through createUIInstance to make it
// initialized
diff --git a/server/src/com/vaadin/server/UIClassSelectionEvent.java b/server/src/com/vaadin/server/UIClassSelectionEvent.java
new file mode 100644
index 0000000000..401801e691
--- /dev/null
+++ b/server/src/com/vaadin/server/UIClassSelectionEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+/**
+ * Contains information used by
+ * {@link UIProvider#getUIClass(UIClassSelectionEvent)} to choose a UI class to
+ * use in a specific situation.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+public class UIClassSelectionEvent extends UIProviderEvent {
+
+ /**
+ * Creates a new event for a specific request.
+ *
+ * @param request
+ * the Vaadin request for which a UI class is wanted.
+ */
+ public UIClassSelectionEvent(VaadinRequest request) {
+ super(request);
+ }
+
+}
diff --git a/server/src/com/vaadin/server/UICreateEvent.java b/server/src/com/vaadin/server/UICreateEvent.java
new file mode 100644
index 0000000000..561bc4cdfa
--- /dev/null
+++ b/server/src/com/vaadin/server/UICreateEvent.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import com.vaadin.ui.UI;
+
+/**
+ * Contains data used by various methods in {@link UIProvider} for determining
+ * information about a new UI that is about to be created.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+public class UICreateEvent extends UIProviderEvent {
+
+ private final Class<? extends UI> uiClass;
+
+ /**
+ * Creates a new UI create event for a given VaadinRequest and UI class.
+ *
+ * @param request
+ * the request for which the UI will be created
+ * @param uiClass
+ * the UI class that will be created
+ */
+ public UICreateEvent(VaadinRequest request, Class<? extends UI> uiClass) {
+ super(request);
+ this.uiClass = uiClass;
+ }
+
+ /**
+ * Gets the UI class that will be created.
+ *
+ * @return the UI class
+ */
+ public Class<? extends UI> getUIClass() {
+ return uiClass;
+ }
+
+}
diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java
index 812c2588da..e90d4f27f4 100644
--- a/server/src/com/vaadin/server/UIProvider.java
+++ b/server/src/com/vaadin/server/UIProvider.java
@@ -26,11 +26,11 @@ import com.vaadin.annotations.Widgetset;
import com.vaadin.ui.UI;
public abstract class UIProvider implements Serializable {
- public abstract Class<? extends UI> getUIClass(VaadinRequest request);
+ public abstract Class<? extends UI> getUIClass(UIClassSelectionEvent event);
- public UI createInstance(VaadinRequest request, Class<? extends UI> type) {
+ public UI createInstance(UICreateEvent event) {
try {
- return type.newInstance();
+ return event.getUIClass().newInstance();
} catch (InstantiationException e) {
throw new RuntimeException("Could not instantiate root class", e);
} catch (IllegalAccessException e) {
@@ -40,20 +40,20 @@ public abstract class UIProvider implements Serializable {
/**
* Helper to get an annotation for a class. If the annotation is not present
- * on the target class, it's superclasses and implemented interfaces are
+ * on the target class, it's super classes and implemented interfaces are
* also searched for the annotation.
*
- * @param type
- * the target class from which the annotation should be found
+ * @param event
+ * the UI create event to get required info from
* @param annotationType
* the annotation type to look for
* @return an annotation of the given type, or <code>null</code> if the
* annotation is not present on the class
*/
- protected static <T extends Annotation> T getAnnotationFor(Class<?> type,
- Class<T> annotationType) {
+ protected static <T extends Annotation> T getAnnotationFor(
+ UICreateEvent event, Class<T> annotationType) {
// Find from the class hierarchy
- Class<?> currentType = type;
+ Class<?> currentType = event.getUIClass();
while (currentType != Object.class) {
T annotation = currentType.getAnnotation(annotationType);
if (annotation != null) {
@@ -64,7 +64,7 @@ public abstract class UIProvider implements Serializable {
}
// Find from an implemented interface
- for (Class<?> iface : type.getInterfaces()) {
+ for (Class<?> iface : event.getUIClass().getInterfaces()) {
T annotation = iface.getAnnotation(annotationType);
if (annotation != null) {
return annotation;
@@ -77,17 +77,19 @@ public abstract class UIProvider implements Serializable {
/**
* Finds the theme to use for a specific UI. If no specific theme is
* required, <code>null</code> is returned.
+ * <p>
+ * The default implementation checks for a @{@link Theme} annotation on the
+ * UI class.
*
- * TODO Tell what the default implementation does once it does something.
- *
- * @param uI
- * the UI to get a theme for
+ * @param event
+ * the UI create event with information about the UI and the
+ * current request.
* @return the name of the theme, or <code>null</code> if the default theme
* should be used
*
*/
- public String getTheme(VaadinRequest request, Class<? extends UI> uiClass) {
- Theme uiTheme = getAnnotationFor(uiClass, Theme.class);
+ public String getTheme(UICreateEvent event) {
+ Theme uiTheme = getAnnotationFor(event, Theme.class);
if (uiTheme != null) {
return uiTheme.value();
} else {
@@ -102,17 +104,15 @@ public abstract class UIProvider implements Serializable {
* The default implementation uses the @{@link Widgetset} annotation if it's
* defined for the UI class.
*
- * @param request
- * the Vaadin request for which to get a widgetset
- * @param uiClass
- * the UI class to get a widgetset for
+ * @param event
+ * the UI create event with information about the UI and the
+ * current request.
* @return the name of the widgetset, or <code>null</code> if the default
* widgetset should be used
*
*/
- public String getWidgetset(VaadinRequest request,
- Class<? extends UI> uiClass) {
- Widgetset uiWidgetset = getAnnotationFor(uiClass, Widgetset.class);
+ public String getWidgetset(UICreateEvent event) {
+ Widgetset uiWidgetset = getAnnotationFor(event, Widgetset.class);
if (uiWidgetset != null) {
return uiWidgetset.value();
} else {
@@ -126,22 +126,21 @@ public abstract class UIProvider implements Serializable {
* previously been open. The framework attempts to discover this by checking
* the value of window.name in the browser.
*
- * @param request
- * @param uiClass
+ * @param event
+ * the UI create event with information about the UI and the
+ * current request.
*
* @return <code>true</code>if the same UI instance should be reused e.g.
* when the browser window is refreshed.
*/
- public boolean isPreservedOnRefresh(VaadinRequest request,
- Class<? extends UI> uiClass) {
- PreserveOnRefresh preserveOnRefresh = getAnnotationFor(uiClass,
+ public boolean isPreservedOnRefresh(UICreateEvent event) {
+ PreserveOnRefresh preserveOnRefresh = getAnnotationFor(event,
PreserveOnRefresh.class);
return preserveOnRefresh != null;
}
- public String getPageTitle(VaadinRequest request,
- Class<? extends UI> uiClass) {
- Title titleAnnotation = getAnnotationFor(uiClass, Title.class);
+ public String getPageTitle(UICreateEvent event) {
+ Title titleAnnotation = getAnnotationFor(event, Title.class);
if (titleAnnotation == null) {
return null;
} else {
diff --git a/server/src/com/vaadin/server/UIProviderEvent.java b/server/src/com/vaadin/server/UIProviderEvent.java
new file mode 100644
index 0000000000..335ce86119
--- /dev/null
+++ b/server/src/com/vaadin/server/UIProviderEvent.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import java.util.EventObject;
+
+/**
+ * Base class for the events that are sent to various methods in UIProvider.
+ *
+ * @see UIProvider
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+public class UIProviderEvent extends EventObject {
+
+ private final VaadinRequest request;
+
+ /**
+ * Creates a new UI provider event.
+ *
+ * @param request
+ * the request for which the event is UI provider is invoked
+ */
+ public UIProviderEvent(VaadinRequest request) {
+ super(request.getVaadinService());
+ this.request = request;
+ }
+
+ /**
+ * Gets the Vaadin service from which the event originates.
+ *
+ * @return the Vaadin service
+ */
+ public VaadinService getService() {
+ return (VaadinService) getSource();
+ }
+
+ /**
+ * Gets the request associated with this event.
+ *
+ * @return the Vaadin request
+ */
+ public VaadinRequest getRequest() {
+ return request;
+ }
+
+}
diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java
index 9940cb5a79..02974aeea5 100644
--- a/server/src/com/vaadin/server/VaadinPortletService.java
+++ b/server/src/com/vaadin/server/VaadinPortletService.java
@@ -25,7 +25,6 @@ import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import com.vaadin.server.VaadinPortlet.RequestType;
-import com.vaadin.ui.UI;
public class VaadinPortletService extends VaadinService {
private final VaadinPortlet portlet;
@@ -214,8 +213,7 @@ public class VaadinPortletService extends VaadinService {
* Always preserve UIs in portlets to make portlet actions work.
*/
@Override
- public boolean preserveUIOnRefresh(VaadinRequest request, UI ui,
- UIProvider provider) {
+ public boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event) {
return true;
}
} \ No newline at end of file
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index b3f9cd3ecf..9a4a3a80f5 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -719,19 +719,16 @@ public abstract class VaadinService implements Serializable {
* typically checks the @{@link PreserveOnRefresh} annotation but UI
* providers and ultimately VaadinService implementations may choose to
* override the defaults.
- *
- * @param request
- * the Vaadin request used to initialize the UI
- * @param ui
- * the UI for which the preserve setting should be returned
* @param provider
* the UI provider responsible for the UI
+ * @param event
+ * the UI create event with details about the UI
+ *
* @return <code>true</code> if the UI should be preserved on refresh;
* <code>false</code> if a new UI instance should be initialized on
* refreshed.
*/
- public boolean preserveUIOnRefresh(VaadinRequest request, UI ui,
- UIProvider provider) {
- return provider.isPreservedOnRefresh(request, ui.getClass());
+ public boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event) {
+ return provider.isPreservedOnRefresh(event);
}
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java
index 858a18b223..e84d1c9939 100644
--- a/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java
+++ b/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java
@@ -11,6 +11,7 @@ import org.easymock.EasyMock;
import com.vaadin.DefaultDeploymentConfiguration;
import com.vaadin.server.DefaultUIProvider;
import com.vaadin.server.DeploymentConfiguration;
+import com.vaadin.server.UIClassSelectionEvent;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
@@ -59,7 +60,7 @@ public class CustomUIClassLoader extends TestCase {
DefaultUIProvider uiProvider = new DefaultUIProvider();
Class<? extends UI> uiClass = uiProvider
- .getUIClass(createRequestMock(null));
+ .getUIClass(new UIClassSelectionEvent(createRequestMock(null)));
assertEquals(MyUI.class, uiClass);
}
@@ -103,7 +104,7 @@ public class CustomUIClassLoader extends TestCase {
DefaultUIProvider uiProvider = new DefaultUIProvider();
Class<? extends UI> uiClass = uiProvider
- .getUIClass(createRequestMock(loggingClassLoader));
+ .getUIClass(new UIClassSelectionEvent(createRequestMock(null)));
assertEquals(MyUI.class, uiClass);
assertEquals(1, loggingClassLoader.requestedClasses.size());
diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java
index b121ae7992..4ff5624ba1 100644
--- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java
+++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java
@@ -30,10 +30,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vaadin.LegacyApplication;
-import com.vaadin.server.UIProvider;
import com.vaadin.server.DeploymentConfiguration;
import com.vaadin.server.LegacyVaadinServlet;
import com.vaadin.server.ServiceException;
+import com.vaadin.server.UIClassSelectionEvent;
import com.vaadin.server.UIProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServletRequest;
@@ -144,14 +144,13 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet {
try {
final Class<?> classToRun = getClassToRun();
if (UI.class.isAssignableFrom(classToRun)) {
- getVaadinService().addUIProvider(session,
- new UIProvider() {
- @Override
- public Class<? extends UI> getUIClass(
- VaadinRequest request) {
- return (Class<? extends UI>) classToRun;
- }
- });
+ getVaadinService().addUIProvider(session, new UIProvider() {
+ @Override
+ public Class<? extends UI> getUIClass(
+ UIClassSelectionEvent event) {
+ return (Class<? extends UI>) classToRun;
+ }
+ });
} else if (LegacyApplication.class.isAssignableFrom(classToRun)) {
// Avoid using own UIProvider for legacy Application
} else if (UIProvider.class.isAssignableFrom(classToRun)) {
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java b/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java
index 6a2f5c500b..b4f29dda06 100644
--- a/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java
+++ b/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java
@@ -16,6 +16,7 @@
package com.vaadin.tests.applicationservlet;
+import com.vaadin.server.UIClassSelectionEvent;
import com.vaadin.server.UIProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent;
@@ -24,7 +25,8 @@ import com.vaadin.ui.UI;
public class InitParamUIProvider extends UIProvider {
@Override
- public Class<? extends UI> getUIClass(VaadinRequest request) {
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
+ VaadinRequest request = event.getRequest();
String pathInfo = request.getRequestPathInfo();
if ("/test".equals(pathInfo)) {
return BasicJavaScriptComponent.class;
diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
index d405a4c138..9524a41cd8 100644
--- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
+++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
@@ -1,8 +1,11 @@
package com.vaadin.tests.components.ui;
import com.vaadin.server.ExternalResource;
-import com.vaadin.server.VaadinSession;
+import com.vaadin.server.UIClassSelectionEvent;
+import com.vaadin.server.UICreateEvent;
+import com.vaadin.server.UIProviderEvent;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinSession;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.AbstractTestUIProvider;
import com.vaadin.ui.Label;
@@ -20,17 +23,17 @@ public class LazyInitUIs extends AbstractTestUIProvider {
}
@Override
- public UI createInstance(VaadinRequest request,
- Class<? extends UI> type) {
- return getUI(request);
+ public UI createInstance(UICreateEvent event) {
+ return getUI(event);
}
@Override
- public Class<? extends UI> getUIClass(VaadinRequest request) {
- return getUI(request).getClass();
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
+ return getUI(event).getClass();
}
- private UI getUI(VaadinRequest request) {
+ private UI getUI(UIProviderEvent event) {
+ VaadinRequest request = event.getRequest();
if (request.getParameter("lazyCreate") != null) {
// UI created on second request
UI uI = new UI() {
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java
index c5d997cfd4..942e5ed1ef 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java
+++ b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java
@@ -3,8 +3,9 @@ package com.vaadin.tests.components.ui;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
-import com.vaadin.server.VaadinSession;
+import com.vaadin.server.UIClassSelectionEvent;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinSession;
import com.vaadin.tests.components.AbstractTestUIProvider;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
@@ -32,7 +33,7 @@ public class UIsInMultipleTabs extends AbstractTestUIProvider {
}
@Override
- public Class<? extends UI> getUIClass(VaadinRequest request) {
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
return TabUI.class;
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java
index dd152232f1..ad3a30d4ca 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java
@@ -16,9 +16,11 @@
package com.vaadin.tests.minitutorials.v7a1;
+import com.vaadin.server.UIClassSelectionEvent;
+import com.vaadin.server.UICreateEvent;
import com.vaadin.server.UIProvider;
-import com.vaadin.server.WebBrowser;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.WebBrowser;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
@@ -33,9 +35,9 @@ import com.vaadin.ui.UI;
public class DifferentFeaturesForDifferentClients extends UIProvider {
@Override
- public Class<? extends UI> getUIClass(VaadinRequest request) {
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
// could also use browser version etc.
- if (request.getHeader("user-agent").contains("mobile")) {
+ if (event.getRequest().getHeader("user-agent").contains("mobile")) {
return TouchRoot.class;
} else {
return DefaultRoot.class;
@@ -45,10 +47,9 @@ public class DifferentFeaturesForDifferentClients extends UIProvider {
// Must override as default implementation isn't allowed to
// instantiate our non-public classes
@Override
- public UI createInstance(VaadinRequest request,
- Class<? extends UI> type) {
+ public UI createInstance(UICreateEvent event) {
try {
- return type.newInstance();
+ return event.getUIClass().newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}