diff options
author | Artur Signell <artur@vaadin.com> | 2013-06-03 23:15:43 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-06-05 12:17:10 +0000 |
commit | b0574f7b33c4d3d437c8c11cd53389e5522f6999 (patch) | |
tree | c7cf8acae992d345fd0b274cb39d6857f5858d26 /server/src/com/vaadin | |
parent | edca4095d2e75d73f9d6a5acb2da9009129b4db2 (diff) | |
download | vaadin-framework-b0574f7b33c4d3d437c8c11cd53389e5522f6999.tar.gz vaadin-framework-b0574f7b33c4d3d437c8c11cd53389e5522f6999.zip |
Add transport parameter to @Push (#11966)
Change-Id: Ic47e68a41ba407917a990ef82a98c1526a9510ef
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r-- | server/src/com/vaadin/annotations/Push.java | 10 | ||||
-rw-r--r-- | server/src/com/vaadin/server/UIProvider.java | 24 | ||||
-rw-r--r-- | server/src/com/vaadin/server/communication/UIInitHandler.java | 6 |
3 files changed, 40 insertions, 0 deletions
diff --git a/server/src/com/vaadin/annotations/Push.java b/server/src/com/vaadin/annotations/Push.java index 58e70acf21..d5e42d6f60 100644 --- a/server/src/com/vaadin/annotations/Push.java +++ b/server/src/com/vaadin/annotations/Push.java @@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.vaadin.shared.communication.PushMode; +import com.vaadin.shared.ui.ui.Transport; import com.vaadin.ui.UI; /** @@ -46,4 +47,13 @@ public @interface Push { */ public PushMode value() default PushMode.AUTOMATIC; + /** + * Returns the transport type used for the push for the annotated UI. The + * default transport type when this annotation is present is + * {@link Transport#WEBSOCKET}. + * + * @return the transport type to use + */ + public Transport transport() default Transport.DEFAULT; + } diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java index 0305b907e6..3e7c85aea9 100644 --- a/server/src/com/vaadin/server/UIProvider.java +++ b/server/src/com/vaadin/server/UIProvider.java @@ -25,6 +25,7 @@ import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.annotations.Widgetset; import com.vaadin.shared.communication.PushMode; +import com.vaadin.shared.ui.ui.Transport; import com.vaadin.ui.UI; public abstract class UIProvider implements Serializable { @@ -174,4 +175,27 @@ public abstract class UIProvider implements Serializable { return push.value(); } } + + /** + * Finds the {@link Transport} to use for a specific UI. If no transport is + * defined, <code>null</code> is returned. + * <p> + * The default implementation uses the @{@link Push} annotation if it's + * defined for the UI class. + * + * @param event + * the UI create event with information about the UI and the + * current request. + * @return the transport type to use, or <code>null</code> if the default + * transport type should be used + */ + public Transport getPushTransport(UICreateEvent event) { + Push push = getAnnotationFor(event.getUIClass(), Push.class); + if (push == null) { + return null; + } else { + return push.transport(); + } + } + } diff --git a/server/src/com/vaadin/server/communication/UIInitHandler.java b/server/src/com/vaadin/server/communication/UIInitHandler.java index 9807ea6a9f..d4b0bc709f 100644 --- a/server/src/com/vaadin/server/communication/UIInitHandler.java +++ b/server/src/com/vaadin/server/communication/UIInitHandler.java @@ -39,6 +39,7 @@ import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinSession; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.PushMode; +import com.vaadin.shared.ui.ui.Transport; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.ui.UI; @@ -211,6 +212,11 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler { } ui.getPushConfiguration().setPushMode(pushMode); + Transport transport = provider.getPushTransport(event); + if (transport != null) { + ui.getPushConfiguration().setTransport(transport); + } + // Set thread local here so it is available in init UI.setCurrent(ui); |