From 69def694d5d98f518ad08c039195fd2ac8781d2f Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Wed, 27 Feb 2013 14:33:04 +0200 Subject: Server push (#111) * Asynchronous bidirectional communication * Use Atmosphere as a backend * Use websockets if available, fallback to HTTP streaming * Push mode (disabled, manual, automatic) * Configurable via servlet parameter pushMode * Disabled: The default; regular AJAX communication * Manual: Need explicit UI.push() call * Automatic: push all UIs in session when lock released * UI.push() * Push pending state and RPC to client asynchronously * Must hold session lock when invoking Change-Id: Idb5978ac81f7ff1e66665df4e3f96e29e4c419d4 --- .../com/vaadin/shared/ApplicationConstants.java | 2 + .../com/vaadin/shared/communication/PushMode.java | 55 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 shared/src/com/vaadin/shared/communication/PushMode.java (limited to 'shared/src') diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java index 220679e69c..5f23a3dc38 100644 --- a/shared/src/com/vaadin/shared/ApplicationConstants.java +++ b/shared/src/com/vaadin/shared/ApplicationConstants.java @@ -28,6 +28,8 @@ public class ApplicationConstants implements Serializable { public static final String HEARTBEAT_PATH = "HEARTBEAT"; + public static final String PUSH_PATH = "PUSH"; + public static final String PUBLISHED_FILE_PATH = APP_PATH + '/' + "PUBLISHED"; diff --git a/shared/src/com/vaadin/shared/communication/PushMode.java b/shared/src/com/vaadin/shared/communication/PushMode.java new file mode 100644 index 0000000000..f7414a89ea --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/PushMode.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.communication; + +/** + * The mode of bidirectional ("push") communication that is in use. + * + * @see com.vaadin.server.DeploymentConfiguration#getPushMode() + * + * @author Vaadin Ltd + * @since 7.1 + */ +public enum PushMode { + /** + * Push is disabled. Regular AJAX requests are used to communicate between + * the client and the server. Asynchronous messages from the server are not + * possible. {@link com.vaadin.ui.UI#push() ui.push()} throws + * IllegalStateException. + *

+ * This is the default mode unless + * {@link com.vaadin.server.DeploymentConfiguration#getPushMode() + * configured} otherwise. + */ + DISABLED, + + /** + * Push is enabled. A bidirectional channel is established between the + * client and server and used to communicate state changes and RPC + * invocations. The client is not automatically updated if the server-side + * state is asynchronously changed; {@link com.vaadin.ui.UI#push() + * ui.push()} must be explicitly called. + */ + MANUAL, + + /** + * Push is enabled. Like {@link #MANUAL}, but asynchronous changes to the + * server-side state are automatically pushed to the client once the session + * lock is released. + */ + AUTOMATIC; +} -- cgit v1.2.3