</servlet>
<servlet>
- <!-- This servlet is a separate instance for the sole purpose of
- testing #12446 (com.vaadin.tests.components.ui.TimeoutRedirectResetsOnActivity)
- because it modifies the VaadinService timeout parameters -->
+ <!-- This servlet is a separate instance for the sole purpose of testing
+ #12446 (com.vaadin.tests.components.ui.TimeoutRedirectResetsOnActivity) because
+ it modifies the VaadinService timeout parameters -->
<servlet-name>VaadinApplicationRunnerWithTimeoutRedirect</servlet-name>
<servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class>
</servlet>
<async-supported>true</async-supported>
</servlet>
+ <!-- For testing custom push path with, for example, Weblogic 12.1.2 -->
+ <servlet>
+ <servlet-name>VaadinApplicationRunnerWithPushPathTest</servlet-name>
+ <servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class>
+ <init-param>
+ <param-name>pushPath</param-name>
+ <param-value>ws</param-value>
+ </init-param>
+ <async-supported>true</async-supported>
+ </servlet>
+
<servlet-mapping>
<servlet-name>Embed App 1</servlet-name>
<url-pattern>/embed1/*</url-pattern>
<url-pattern>/run-push/*</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>VaadinApplicationRunnerWithPushPathTest</servlet-name>
+ <url-pattern>/run-pushpath/*</url-pattern>
+ </servlet-mapping>
+
<servlet-mapping>
<servlet-name>IntegrationTest</servlet-name>
<url-pattern>/integration/*</url-pattern>
/**
* The default {@link PushConnection} implementation that uses Atmosphere for
* handling the communication channel.
- *
+ *
* @author Vaadin Ltd
* @since 7.1
*/
*/
private Command pendingDisconnectCommand;
+ private String pushPath;
+
public AtmospherePushConnection() {
}
pushConfiguration.parameters.get(param));
}
+ pushPath = pushConfiguration.pushPath;
+ assert pushPath != null;
+
runWhenAtmosphereLoaded(new Command() {
@Override
public void execute() {
private void connect() {
String baseUrl = connection
.translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX
- + ApplicationConstants.PUSH_PATH + '/');
+ + pushPath + '/');
String extraParams = UIConstants.UI_ID_PARAMETER + "="
+ connection.getConfiguration().getUIId();
/**
* Called whenever a server push connection is established (or
* re-established).
- *
+ *
* @param response
- *
+ *
* @since 7.2
*/
protected void onConnect(AtmosphereResponse response) {
/**
* Called if the push connection fails. Atmosphere will automatically retry
* the connection until successful.
- *
+ *
*/
protected void onError(AtmosphereResponse response) {
state = State.DISCONNECTED;
location="${result.dir}/js/VAADIN/vaadinPush.debug.js" />
<!-- Keep the version number in sync with ivy.xml, server/src/com/vaadin/server/Constants.java -->
- <property name="atmosphere.runtime.version" value="2.2.4.vaadin2" />
+ <property name="atmosphere.runtime.version" value="2.2.4.vaadin3" />
<property name="jquery.js" location="lib/jquery/jquery-1.11.0.js" />
<path id="classpath.compile.custom" />
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ivy-module [
<!-- Keep the version number in sync with build.xml -->
- <!ENTITY atmosphere.runtime.version "2.2.4.vaadin2">
+ <!ENTITY atmosphere.runtime.version "2.2.4.vaadin3">
<!ENTITY atmosphere.js.version "2.2.6.vaadin3">
]>
// Keep the version number in sync with push/build.xml and other locations
// listed in that file
- static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.2.4.vaadin2";
+ static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.2.4.vaadin3";
static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n"
+ "=================================================================\n"
static final String SERVLET_PARAMETER_RESOURCE_CACHE_TIME = "resourceCacheTime";
static final String SERVLET_PARAMETER_HEARTBEAT_INTERVAL = "heartbeatInterval";
static final String SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS = "closeIdleSessions";
- static final String SERVLET_PARAMETER_PUSH_MODE = "pushMode";
static final String SERVLET_PARAMETER_UI_PROVIDER = "UIProvider";
static final String SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING = "legacyPropertyToString";
static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
static final String SERVLET_PARAMETER_SENDURLSASPARAMETERS = "sendUrlsAsParameters";
+ static final String SERVLET_PARAMETER_PUSH_MODE = "pushMode";
+ static final String SERVLET_PARAMETER_PUSH_PATH = "pushPath";
// Configurable parameter names
static final String PARAMETER_VAADIN_RESOURCES = "Resources";
public static final boolean DEFAULT_SEND_URLS_AS_PARAMETERS = true;
+ /**
+ * Default value for {@link #getPushPath()} = {@value} .
+ *
+ * @since 7.4.1
+ */
+ public static final String DEFAULT_PUSH_PATH = "PUSH";
+
private final Properties initParameters;
private boolean productionMode;
private boolean xsrfProtectionEnabled;
return initParameters;
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * The default path {@link DEFAULT_PUSH_PATH} can be changed by using init
+ * parameter {@link Constants.SERVLET_PARAMETER_PUSH_PATH}.
+ */
+ @Override
+ public String getPushPath() {
+ return getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_PUSH_PATH, DEFAULT_PUSH_PATH);
+ }
+
/**
* Log a warning if Vaadin is not running in production mode.
*/
*
* @since 7.4
*
- * @return UI class name
+ * @return the name of the widgetset
*/
public String getWidgetset(String defaultValue);
*/
public String getClassLoaderName();
+ /**
+ * Returns the push path configuration option value. Should never be null.
+ *
+ * @since 7.4.1
+ * @return the path used with server push
+ */
+ public String getPushPath();
+
/**
* Returns to legacy Property.toString() mode used. See
* {@link AbstractProperty#isLegacyToStringEnabled()} for more information.
}
public static boolean isPushRequest(VaadinRequest request) {
- return hasPathPrefix(request, ApplicationConstants.PUSH_PATH + '/');
+ return hasPathPrefix(request, request.getService()
+ .getDeploymentConfiguration().getPushPath() + '/');
}
public static void initDefaultUIProvider(VaadinSession session,
PushMode pushMode = provider.getPushMode(event);
if (pushMode == null) {
- pushMode = session.getService().getDeploymentConfiguration()
- .getPushMode();
+ pushMode = session.getConfiguration().getPushMode();
}
ui.getPushConfiguration().setPushMode(pushMode);
+ ui.getPushConfiguration().setPushPath(
+ session.getConfiguration().getPushPath());
Transport transport = provider.getPushTransport(event);
if (transport != null) {
*/
public void setFallbackTransport(Transport fallbackTransport);
+ /**
+ * Sets the path that is used with push.
+ *
+ * @since 7.4.1
+ * @param pushPath
+ * The path to be used with push
+ *
+ * @throws IllegalArgumentException
+ * if the argument is null or empty.
+ */
+ public void setPushPath(String pushPath);
+
+ /**
+ * Returns the path used with push.
+ *
+ * @since 7.4.1
+ * @return The path that is used with push
+ */
+ public String getPushPath();
+
/**
* Returns the given parameter, if set.
* <p>
fallbackTransport.getIdentifier());
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.PushConfiguration#setPushPath(java.lang.String)
+ */
+ @Override
+ public void setPushPath(String pushPath) {
+ if (pushPath != null && !pushPath.isEmpty()) {
+ getState().pushPath = pushPath;
+ } else {
+ throw new IllegalArgumentException(
+ "Push path can't be empty or null");
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.PushConfiguration#getPushPath()
+ */
+ @Override
+ public String getPushPath() {
+ return getState(false).pushPath;
+ }
+
/*
* (non-Javadoc)
*
return Collections.unmodifiableCollection(getState(false).parameters
.keySet());
}
-
}
return DefaultDeploymentConfiguration.DEFAULT_SEND_URLS_AS_PARAMETERS;
}
+ @Override
+ public String getPushPath() {
+ return null;
+ }
}
}
private LegacyProperyToStringMode legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
private boolean syncIdCheckEnabled = true;
private boolean sendUrlsAsParameters = true;
+ private String pushPath = "PUSH";
@Override
public boolean isProductionMode() {
return sendUrlsAsParameters;
}
+ @Override
+ public String getPushPath() {
+ return pushPath;
+ }
+
}
public static final String HEARTBEAT_PATH = "HEARTBEAT";
- public static final String PUSH_PATH = "PUSH";
-
public static final String PUBLISHED_FILE_PATH = APP_PATH + '/'
+ "PUBLISHED";
/**
* The name of the javascript containing the bootstrap code. The file is
* located in the VAADIN directory.
- *
+ *
* @since 7.3
*/
public static final String VAADIN_BOOTSTRAP_JS = "vaadinBootstrap.js";
/**
* The name of the debug version of the javascript containing push support.
* The file is located in the VAADIN directory.
- *
+ *
* @since 7.1.6
*/
public static final String VAADIN_PUSH_DEBUG_JS = "vaadinPush.debug.js";
/**
* The name of the parameter used to transmit RPC invocations
- *
+ *
* @since 7.2
*/
public static final String RPC_INVOCATIONS = "rpc";
/**
* The name of the parameter used to transmit the CSRF token
- *
+ *
* @since 7.2
*/
public static final String CSRF_TOKEN = "csrfToken";
* The name of the parameter used to transmit the sync id. The value can be
* set to -1 e.g. when testing with pre-recorded requests to make the
* framework ignore the sync id.
- *
+ *
* @see com.vaadin.ui.ConnectorTracker#getCurrentSyncId()
* @since 7.2
*/
public static final String FALLBACK_TRANSPORT_PARAM = "fallbackTransport";
public PushMode mode = PushMode.DISABLED;
+ public String pushPath;
public Map<String, String> parameters = new HashMap<String, String>();
{
parameters
try {
VaadinServletService service = (VaadinServletService) VaadinService
.getCurrent();
- session = service
- .findVaadinSession(new VaadinServletRequest(
- currentRequest, service));
+ if (service != null) {
+ session = service
+ .findVaadinSession(new VaadinServletRequest(
+ currentRequest, service));
+ }
+
} finally {
/*
* Clear some state set by findVaadinSession to
--- /dev/null
+/*
+ * Copyright 2000-2014 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.tests.push;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+
+@Push(transport = Transport.WEBSOCKET)
+public class PushPath extends AbstractTestUI {
+
+ public static final String PUSH_PATH_LABEL_ID = "push-path-label-id";
+ public static final String PUSH_PATH_LABEL_TEXT = "Label by push";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ // use only websockets
+ getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+
+ String pushPath = request.getService().getDeploymentConfiguration()
+ .getPushPath();
+ String transport = getPushConfiguration().getTransport().name();
+ Label pushPathLabel = new Label(String.format(
+ "Waiting for push from path '%s' using %s in 3 seconds.",
+ pushPath, transport));
+ addComponent(pushPathLabel);
+
+ new PushThread().start();
+ }
+
+ public class PushThread extends Thread {
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ }
+ access(new Runnable() {
+
+ @Override
+ public void run() {
+ Label pushLabel = new Label(PUSH_PATH_LABEL_TEXT);
+ pushLabel.setId(PUSH_PATH_LABEL_ID);
+ addComponent(pushLabel);
+ }
+ });
+
+ }
+ }
+
+ @Override
+ public Integer getTicketNumber() {
+ return 14432;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Push path should be configurable since some servers can't serve both websockets and long polling from same URL.";
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2014 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.tests.push;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.WebsocketTest;
+
+public class PushPathTest extends WebsocketTest {
+
+ private static final int TEN_SECONDS_IN_MS = 10 * 1000;
+
+ @Test
+ public void testCustomPushPath() throws InterruptedException {
+ openTestURL();
+ sleep(TEN_SECONDS_IN_MS);
+ Assert.assertEquals(vaadinElementById(PushPath.PUSH_PATH_LABEL_ID)
+ .getText(), PushPath.PUSH_PATH_LABEL_TEXT);
+ }
+
+ @Override
+ public String getDeploymentPath() {
+ Class<?> uiClass = getUIClass();
+ return "/run-pushpath/" + uiClass.getCanonicalName();
+ }
+
+}