summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-09-24 10:20:29 +0300
committerMarkus Koivisto <markus@vaadin.com>2015-09-29 18:45:07 +0300
commit901bdc4a041e17560b99aa65267d77ec262ac011 (patch)
tree381e7fd03808a7ec0c4320225741e5ce2795be17
parentd7dfc7477fbfc07893a2ca3271d0d898ad197b53 (diff)
downloadvaadin-framework-901bdc4a041e17560b99aa65267d77ec262ac011.tar.gz
vaadin-framework-901bdc4a041e17560b99aa65267d77ec262ac011.zip
Adds support for defining the URL to use for push requests (#18989)
Change-Id: I12afaf7e5c5c385f3a19c7dab60f044d8721e082
-rw-r--r--client/src/com/vaadin/client/communication/AtmospherePushConnection.java16
-rw-r--r--server/src/com/vaadin/ui/PushConfiguration.java33
-rw-r--r--shared/src/com/vaadin/shared/ui/ui/UIState.java1
3 files changed, 46 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
index a81ab616cf..6aa920bf93 100644
--- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -135,6 +135,11 @@ public class AtmospherePushConnection implements PushConnection {
*/
private Command pendingDisconnectCommand;
+ /**
+ * The url to use for push requests
+ */
+ private String url;
+
public AtmospherePushConnection() {
}
@@ -180,7 +185,12 @@ public class AtmospherePushConnection implements PushConnection {
config.setStringValue(param,
pushConfiguration.parameters.get(param));
}
-
+ if (pushConfiguration.pushUrl != null) {
+ url = pushConfiguration.pushUrl;
+ } else {
+ url = ApplicationConstants.APP_PROTOCOL_PREFIX
+ + ApplicationConstants.PUSH_PATH;
+ }
runWhenAtmosphereLoaded(new Command() {
@Override
public void execute() {
@@ -195,9 +205,7 @@ public class AtmospherePushConnection implements PushConnection {
}
private void connect() {
- String baseUrl = connection
- .translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX
- + ApplicationConstants.PUSH_PATH);
+ String baseUrl = connection.translateVaadinUri(url);
String extraParams = UIConstants.UI_ID_PARAMETER + "="
+ connection.getConfiguration().getUIId();
diff --git a/server/src/com/vaadin/ui/PushConfiguration.java b/server/src/com/vaadin/ui/PushConfiguration.java
index 90ad28542c..d2c12afbe5 100644
--- a/server/src/com/vaadin/ui/PushConfiguration.java
+++ b/server/src/com/vaadin/ui/PushConfiguration.java
@@ -139,6 +139,29 @@ public interface PushConfiguration extends Serializable {
*/
public void setParameter(String parameter, String value);
+ /**
+ * Sets the URL to use for push requests.
+ * <p>
+ * This is only used when overriding the URL to use. Setting this to null
+ * (the default) will use the default URL.
+ *
+ * @since
+ * @param pushUrl
+ * The push URL to use
+ */
+ public void setPushUrl(String pushUrl);
+
+ /**
+ * Returns the URL to use for push requests.
+ * <p>
+ * This is only used when overriding the URL to use. Returns null (the
+ * default) when the default URL is used.
+ *
+ * @since
+ * @return the URL to use for push requests, or null to use to default
+ */
+ public String getPushUrl();
+
}
class PushConfigurationImpl implements PushConfiguration {
@@ -199,6 +222,16 @@ class PushConfigurationImpl implements PushConfiguration {
}
}
+ @Override
+ public void setPushUrl(String pushUrl) {
+ getState().pushUrl = pushUrl;
+ }
+
+ @Override
+ public String getPushUrl() {
+ return getState(false).pushUrl;
+ }
+
/*
* (non-Javadoc)
*
diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java
index 6f7a531eb6..e22b4fb8d1 100644
--- a/shared/src/com/vaadin/shared/ui/ui/UIState.java
+++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java
@@ -114,6 +114,7 @@ public class UIState extends TabIndexState {
public static final String FALLBACK_TRANSPORT_PARAM = "fallbackTransport";
public PushMode mode = PushMode.DISABLED;
+ public String pushUrl = null;
public Map<String, String> parameters = new HashMap<String, String>();
{
parameters