diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-04-17 14:25:48 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-17 14:37:52 +0000 |
commit | b8614ad16cac44637dbfa11829b4cb896c4ac9cf (patch) | |
tree | e0337ad6721ea9bf59b10ec9d17628e46738d749 | |
parent | 0f75f202d333ac507fb3e5efb8e9bd4d4719e098 (diff) | |
download | vaadin-framework-b8614ad16cac44637dbfa11829b4cb896c4ac9cf.tar.gz vaadin-framework-b8614ad16cac44637dbfa11829b4cb896c4ac9cf.zip |
Add PushMode.isEnabled() (#11626)
Change-Id: I416dc73566e2404a6dce35045fc79f9038e8dd5e
7 files changed, 17 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index ce57dc5bca..04e3ab9dc6 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -89,7 +89,6 @@ import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; -import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.ui.ui.UIConstants; @@ -3395,7 +3394,7 @@ public class ApplicationConnection { } private void initializePush() { - if (getConfiguration().getPushMode() != PushMode.DISABLED) { + if (getConfiguration().getPushMode().isEnabled()) { push = GWT.create(PushConnection.class); push.init(this); diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 822db77b7d..675a217b50 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -41,7 +41,6 @@ import org.jsoup.parser.Tag; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; -import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.UI; /** @@ -356,7 +355,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { "position:absolute;width:0;height:0;border:0;overflow:hidden") .attr("src", "javascript:false")); - if (context.getSession().getPushMode() != PushMode.DISABLED) { + if (context.getSession().getPushMode().isEnabled()) { // Load client-side dependencies for push support fragmentNodes.add(new Element(Tag.valueOf("script"), "").attr( "type", "text/javascript").attr("src", diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java index a6f06b6a79..5cf3898c23 100644 --- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java +++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java @@ -269,7 +269,7 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration { pushMode = PushMode.DISABLED; } - if (pushMode != PushMode.DISABLED && !checkAtomsphereVersion()) { + if (pushMode.isEnabled() && !checkAtomsphereVersion()) { pushMode = PushMode.DISABLED; } } diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index 8b445b6061..f513ef1b15 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -32,7 +32,6 @@ import com.vaadin.server.communication.PushRequestHandler; import com.vaadin.server.communication.ServletBootstrapHandler; import com.vaadin.server.communication.ServletUIInitHandler; import com.vaadin.shared.JsonConstants; -import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.UI; public class VaadinServletService extends VaadinService { @@ -59,7 +58,7 @@ public class VaadinServletService extends VaadinService { List<RequestHandler> handlers = super.createRequestHandlers(); handlers.add(0, new ServletBootstrapHandler()); handlers.add(new ServletUIInitHandler()); - if (getDeploymentConfiguration().getPushMode() != PushMode.DISABLED) { + if (getDeploymentConfiguration().getPushMode().isEnabled()) { handlers.add(new PushRequestHandler(this)); } return handlers; diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index 5e61dd5c98..0057a71c83 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -36,7 +36,6 @@ import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinServletRequest; import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; -import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.UI; /** @@ -89,7 +88,7 @@ public class PushHandler implements AtmosphereHandler { "Could not find the requested UI in session"); return; } - assert session.getPushMode() != PushMode.DISABLED; + assert session.getPushMode().isEnabled(); if (req.getMethod().equalsIgnoreCase("GET")) { /* diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 1fb7ace9df..70ecc1f1fa 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -40,7 +40,6 @@ import com.vaadin.server.VaadinSession; import com.vaadin.server.communication.PushConnection; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; -import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.ui.ui.ScrollClientRpc; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.ui.ui.UIServerRpc; @@ -1157,7 +1156,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements return; } - if (session.getPushMode() == PushMode.DISABLED) { + if (!session.getPushMode().isEnabled()) { throw new IllegalStateException("Push not enabled"); } diff --git a/shared/src/com/vaadin/shared/communication/PushMode.java b/shared/src/com/vaadin/shared/communication/PushMode.java index f7414a89ea..3fe8b4ea3e 100644 --- a/shared/src/com/vaadin/shared/communication/PushMode.java +++ b/shared/src/com/vaadin/shared/communication/PushMode.java @@ -52,4 +52,15 @@ public enum PushMode { * lock is released. */ AUTOMATIC; + + /** + * Checks whether the push mode is using push functionality + * + * @return <code>true</code> if this mode requires push functionality; + * <code>false</code> if no push functionality is used for this + * mode. + */ + public boolean isEnabled() { + return this != DISABLED; + } } |