diff options
author | Artur Signell <artur@vaadin.com> | 2013-06-05 14:27:09 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-06-05 15:14:42 +0300 |
commit | edca4095d2e75d73f9d6a5acb2da9009129b4db2 (patch) | |
tree | 15226365a8501ba55255dc21111696709aafa632 /shared | |
parent | ebd4a5c0ae6e61c20283ba5b866fe51e3576a179 (diff) | |
download | vaadin-framework-edca4095d2e75d73f9d6a5acb2da9009129b4db2.tar.gz vaadin-framework-edca4095d2e75d73f9d6a5acb2da9009129b4db2.zip |
Allow customizing client-side push config on server side (#11867)
Change-Id: I212067aa0bd04e3e73844ef57963b5622291986a
Diffstat (limited to 'shared')
-rw-r--r-- | shared/src/com/vaadin/shared/ui/ui/Transport.java | 55 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/ui/ui/UIState.java | 22 |
2 files changed, 75 insertions, 2 deletions
diff --git a/shared/src/com/vaadin/shared/ui/ui/Transport.java b/shared/src/com/vaadin/shared/ui/ui/Transport.java new file mode 100644 index 0000000000..69d713bcca --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ui/Transport.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2013 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.shared.ui.ui; + +/** + * Transport modes for Push + * + * @since 7.1 + * @author Vaadin Ltd + */ +public enum Transport { + /** + * Websockets + */ + WEBSOCKET("websocket"), + /** + * HTTP streaming + */ + STREAMING("streaming"); + + /** + * The default transport mechanism for push + */ + public static final Transport DEFAULT = Transport.WEBSOCKET; + + /** + * The default fallback transport mechanism for push + */ + public static final Transport DEFAULT_FALLBACK = Transport.STREAMING; + + private String identifier; + + private Transport(String identifier) { + this.identifier = identifier; + } + + public String getIdentifier() { + return identifier; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java index 177fe2e7bd..e19a87ada9 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIState.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -17,7 +17,9 @@ package com.vaadin.shared.ui.ui; import java.io.Serializable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.ui.TabIndexState; @@ -27,8 +29,6 @@ public class UIState extends TabIndexState { public LoadingIndicatorConfigurationState loadingIndicatorConfiguration = new LoadingIndicatorConfigurationState(); public int pollInterval = -1; - public PushMode pushMode = PushMode.DISABLED; - // Informing users of assistive devices, that the content of this container // is announced automatically and does not need to be navigated into public String overlayContainerLabel = "This content is announced automatically and does not need to be navigated into."; @@ -48,6 +48,19 @@ public class UIState extends TabIndexState { public int maxWidth = 500; } + public static class PushConfigurationState implements Serializable { + public static final String TRANSPORT_PARAM = "transport"; + public static final String FALLBACK_TRANSPORT_PARAM = "fallbackTransport"; + + public PushMode mode = PushMode.DISABLED; + public Map<String, String> parameters = new HashMap<String, String>(); + { + parameters.put(TRANSPORT_PARAM, Transport.DEFAULT.getIdentifier()); + parameters.put(FALLBACK_TRANSPORT_PARAM, + Transport.DEFAULT_FALLBACK.getIdentifier()); + } + } + /** * State related to the Page class. */ @@ -57,6 +70,11 @@ public class UIState extends TabIndexState { */ public LocaleServiceState localeServiceState = new LocaleServiceState(); + /** + * Configuration for the push channel + */ + public PushConfigurationState pushConfiguration = new PushConfigurationState(); + { primaryStyleName = "v-ui"; // Default is 1 for legacy reasons |