Repository: wicket Updated Branches: refs/heads/master f733de4e6 -> 38bee6e93
Add information how to setup Native WebSockets in Spring Boot application. Based on feedback at users@ mailing list: http://markmail.org/message/ffvmoc2te5wxt6lb (cherry picked from commit a95c59823a7d49af18c28d2b52c31700c360de56) Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/38bee6e9 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/38bee6e9 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/38bee6e9 Branch: refs/heads/master Commit: 38bee6e932e63fa033c2139cdfb2f82eba55fadc Parents: f733de4 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Thu Jun 22 22:24:45 2017 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Thu Jun 22 22:29:57 2017 +0200 ---------------------------------------------------------------------- .../src/main/asciidoc/nativewebsockets.adoc | 2 +- .../nativewebsockets/nativewebsockets_1.adoc | 2 +- .../nativewebsockets/nativewebsockets_2.adoc | 42 ++++++++++++++++++-- 3 files changed, 41 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/38bee6e9/wicket-user-guide/src/main/asciidoc/nativewebsockets.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/nativewebsockets.adoc b/wicket-user-guide/src/main/asciidoc/nativewebsockets.adoc index 96f1e80..f6949d3 100644 --- a/wicket-user-guide/src/main/asciidoc/nativewebsockets.adoc +++ b/wicket-user-guide/src/main/asciidoc/nativewebsockets.adoc @@ -2,7 +2,7 @@ http://en.wikipedia.org/wiki/WebSocket[WebSockets] is a technology that provides full-duplex communications channels over a single TCP connection. This means that once the browser establish a web socket connection to the server the server can push data back to the browser without the browser explicitly asking again and again whether there is something new for it. -Wicket Native WebSockets modules provide functionality to integrate with the non-standard APIs provided by different web containers (like http://tomcat.apache.org/[Apache Tomcat] +Wicket Native WebSockets modules provide functionality to integrate with the non-standard APIs provided by different web containers (like http://tomcat.apache.org/[Apache Tomcat]) WARNING: Native WebSocket works only when both the browser and the web containers support WebSocket technology. There are no plans to add support to fallback to long-polling, streaming or any other technology that simulates two way communication. Use it only if you really know that you will run your application in an environment that supports WebSockets. Currently supported web containers are Jetty 7.5+ , Tomcat 7.0.27+ and JBoss WildFly 8.0.0+. http://git-wip-us.apache.org/repos/asf/wicket/blob/38bee6e9/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_1.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_1.adoc b/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_1.adoc index d285e11..c3efa29 100644 --- a/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_1.adoc +++ b/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_1.adoc @@ -1,5 +1,5 @@ -Each of the modules provide a specialization of _org.apache.wicket.protocol.http.WicketFilter_ that registers implementation specific endpoint when an HTTP request is http://en.wikipedia.org/wiki/WebSocket#WebSocket_protocol_handshake[upgraded] +Each of the modules provide a specialization of _org.apache.wicket.protocol.http.WicketFilter_ that registers implementation specific endpoint when an HTTP request is http://en.wikipedia.org/wiki/WebSocket#WebSocket_protocol_handshake[upgraded]. WebSockets communication can be used in a Wicket page by using _org.apache.wicket.protocol.ws.api.WebSocketBehavior_ or in a IResource by exteding _org.apache.wicket.protocol.ws.api.WebSocketResource_. When a client is connected it is being registered in a application scoped registry using as a key the application name, the client http session id, and the id of the page or the resource name that registered it. Later when the server needs to push a message it can use this registry to filter out which clients need to receive the message. http://git-wip-us.apache.org/repos/asf/wicket/blob/38bee6e9/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_2.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_2.adoc b/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_2.adoc index 46acfe0..56b491f 100644 --- a/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_2.adoc +++ b/wicket-user-guide/src/main/asciidoc/nativewebsockets/nativewebsockets_2.adoc @@ -33,8 +33,17 @@ Depending on the web container that is used the application has to add a depende </dependency> ---- -NOTE: All web containers providing JSR356 implementation are built with Java 7. This is the reason why _wicket-native-websocket-javax_ module is available only with Wicket 7.x+. If your application runs with JRE 6.x then you can -use _wicket-native-websocket-javax_ together with the latest version of Wicket 6.x. +- for https://projects.spring.io/spring-boot/[Spring Boot] applications also add +---- +<dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-websocket</artifactId> +</dependency> +---- + + +NOTE: All web containers providing JSR356 implementation are built with Java 7. This is the reason why _wicket-native-websocket-javax_ module is available only with Wicket 7.x. If your application runs with JRE 7.x but you are still using Wicket 6.x then you can +use the https://github.com/wicketstuff/core/tree/wicket-6.x/wicketstuff-native-websocket-javax[WicketStuff] module. Beware that the API/implementation of _wicket-native-websocket-javax_ may change before Wicket 7.0.0 is released! NOTE: The examples above show snippets for Maven's pom.xml but the application can use any other dependency management tool like http://www.gradle.org/[Gradle] @@ -66,7 +75,34 @@ For JSR356 complaint web containers (at the moment: Tomcat 7.0.47+, Tomcat 8.x a <filter-class>org.apache.wicket.protocol.ws.javax.JavaxWebSocketFilter</filter-class> ---- - +For https://projects.spring.io/spring-boot/[Spring Boot] application: +---- +@Bean + public FilterRegistrationBean wicketFilter() { + final FilterRegistrationBean wicketFilter = new +FilterRegistrationBean(); + wicketFilter.setDispatcherTypes(DispatcherType.REQUEST, +DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.ASYNC); + wicketFilter.setAsyncSupported(true); + wicketFilter.setFilter(new JavaxWebSocketFilter()); + wicketFilter.addInitParameter(WicketFilter.APP_FACT_PARAM, +SpringWebApplicationFactory.class.getName()); + wicketFilter.addInitParameter(WicketFilter.FILTER_MAPPING_PARAM, +"/*"); + wicketFilter.addUrlPatterns("/*"); + return wicketFilter; + } + + @Bean + public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); + } + + @Bean + public WicketServerEndpointConfig wicketServerEndpointConfig() { + return new WicketServerEndpointConfig(); + } +---- * *WebSocketBehavior*
