You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2017/01/17 21:09:31 UTC
[1/2] wicket git commit: WICKET-6309 Move the Native WebSocket demo
to wicket-examples module
Repository: wicket
Updated Branches:
refs/heads/master 65dffc14c -> 18acedc4c
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartWebSocketResource.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartWebSocketResource.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartWebSocketResource.java
deleted file mode 100644
index a7468d6..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartWebSocketResource.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example.charts;
-
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.wicket.protocol.ws.api.WebSocketResource;
-import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
-import org.apache.wicket.protocol.ws.example.JSR356Application;
-
-/**
- *
- */
-public class ChartWebSocketResource extends WebSocketResource
-{
- public static final String NAME = ChartWebSocketResource.class.getName();
-
- @Override
- protected void onConnect(ConnectedMessage message)
- {
- super.onConnect(message);
-
- ScheduledExecutorService service = JSR356Application.get().getScheduledExecutorService();
- ChartUpdater.start(message, service);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartsResourceReference.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartsResourceReference.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartsResourceReference.java
deleted file mode 100644
index fe0998d..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartsResourceReference.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example.charts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.wicket.markup.head.HeaderItem;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.protocol.ws.api.WicketWebSocketJQueryResourceReference;
-import org.apache.wicket.request.Url;
-import org.apache.wicket.request.resource.JavaScriptResourceReference;
-import org.apache.wicket.request.resource.UrlResourceReference;
-
-/**
- * A resource reference that contributes 'charts.js' - the JavaScript that registers the WebSocket client
- * and constructs the Google chart.
- */
-public class ChartsResourceReference extends JavaScriptResourceReference
-{
- public ChartsResourceReference()
- {
- super(ChartsResourceReference.class, "charts.js");
- }
-
- /**
- * Specify that charts.js depends on Google JS APIs and Wicket WebSocket JavaScript
- * @return a list of dependencies
- */
- @Override
- public List<HeaderItem> getDependencies()
- {
- List<HeaderItem> dependencies = new ArrayList<HeaderItem>();
- dependencies.add(JavaScriptHeaderItem.forReference(new UrlResourceReference(Url.parse("https://www.google.com/jsapi"))));
- dependencies.add(JavaScriptHeaderItem.forReference(WicketWebSocketJQueryResourceReference.get()));
- return dependencies;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.html
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.html b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.html
deleted file mode 100644
index 4f245b6..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<!DOCTYPE html>
-<html xmlns:wicket="http://wicket.apache.org">
-<wicket:panel>
- <div id="chart_div"></div>
-</wicket:panel>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.java
deleted file mode 100644
index e47d8c9..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/WebSocketChart.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example.charts;
-
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.markup.html.panel.Panel;
-
-/**
- * A panel that initializes a Google Line chart and uses WebSocketBehavior to register an asynchronous
- * task that will push some data through the web socket connection.
- */
-public class WebSocketChart extends Panel
-{
- public WebSocketChart(final String id)
- {
- super(id);
- }
-
- @Override
- public void renderHead(IHeaderResponse response)
- {
- super.renderHead(response);
- response.render(JavaScriptHeaderItem.forReference(new ChartsResourceReference()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/charts.js
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/charts.js b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/charts.js
deleted file mode 100644
index 501d9e0..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/charts.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-google.load("visualization", "1", {
- packages:["corechart"]
-});
-
-google.setOnLoadCallback(drawChart);
-
-function drawChart() {
-
- var options = {
- title: 'Stock prices'
- };
-
- var rawData = [
- ['Year', 'Company 1', 'Company 2'],
- ["1999", 0, 0]
- ];
-
- var chart;
-
- /**
- * (Re)Initializes the chart
- */
- var updateChart = function() {
- var data = google.visualization.arrayToDataTable(rawData);
- if (chart) {
- chart.clearChart();
- } else {
- chart = new google.visualization.LineChart(Wicket.$('chart_div'));
- }
- chart.draw(data, options);
- };
-
- /**
- * Updates the chart data by updating or appending the new data pushed by the server
- *
- * @param data the new data pushed by the server
- */
- var updateChartData = function(data) {
-
- // the index of the column which data will be updated. Either 1 (Company 1) or 2 (Company 2)
- var columnIndex = rawData[0].indexOf(data.field);
-
- var replaced = false;
-
- // look whether there is already a record for that year and update the data for the company
- for (var r = 1; r < rawData.length; r++) {
- var oldRecord = rawData[r];
- if (oldRecord[0] === data.year) {
- oldRecord[columnIndex] = data.value;
- replaced = true;
- break;
- }
- }
-
- if (!replaced) {
- // there is no update, so append the new data
-
- // the data of the last appended record
- var lastRecord = rawData[rawData.length - 1];
-
- // the new record that keeps the same data as the last one but updates the value for the updated company
- var newRecord = [data.year, lastRecord[1], lastRecord[2]];
- newRecord[columnIndex] = data.value;
- rawData.push(newRecord);
- }
-
- if (rawData.length > 20) {
- // show at most 20 years back. The first record is special (the headers), so cut the second one
- rawData.splice(1, 1);
- }
-
- updateChart();
- };
-
- Wicket.Event.subscribe("/websocket/open", function(jqEvent) {
- // show the initial state of the chart
- updateChart();
- });
-
- Wicket.Event.subscribe("/websocket/message", function(jqEvent, message) {
- // new record is pushed by the server
-
- var record = jQuery.parseJSON(message);
- if (record && record.year) {
- updateChartData(record);
- }
- });
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/resources/log4j.properties b/wicket-native-websocket/wicket-native-websocket-example/src/main/resources/log4j.properties
deleted file mode 100644
index f9cafac..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n
-
-log4j.rootLogger=INFO,Stdout
-
-log4j.logger.org.apache.wicket=INFO
-log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
-log4j.logger.org.apache.wicket.version=INFO
-log4j.logger.org.apache.wicket.RequestCycle=INFO
-log4j.logger.org.apache.wicket.protocol.ws.javax=TRACE
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/WEB-INF/web.xml b/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index fec480d..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
- version="3.1">
-
- <display-name>wicket-native-websockets-example</display-name>
-
- <filter>
- <filter-name>wrapper</filter-name>
- <filter-class>org.apache.wicket.protocol.ws.example.WrappingFilter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>wrapper</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>wicket.wicket-native-websockets</filter-name>
- <!--<filter-class>org.apache.wicket.protocol.ws.jetty.Jetty7WebSocketFilter</filter-class>-->
- <!--<filter-class>org.apache.wicket.protocol.ws.jetty9.Jetty9WebSocketFilter</filter-class>-->
- <!--<filter-class>org.apache.wicket.protocol.ws.tomcat7.Tomcat7WebSocketFilter</filter-class>-->
- <filter-class>org.apache.wicket.protocol.ws.javax.JavaxWebSocketFilter</filter-class>
- <!--<filter-class>org.wicketstuff.protocol.ws.javax.JavaxWebSocketFilter</filter-class>-->
- <init-param>
- <param-name>applicationClassName</param-name>
- <param-value>org.apache.wicket.protocol.ws.example.JSR356Application</param-value>
- </init-param>
- </filter>
-
- <filter-mapping>
- <filter-name>wicket.wicket-native-websockets</filter-name>
- <!--<url-pattern>/ff/*</url-pattern>-->
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
-
-</web-app>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/logo.png
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/logo.png b/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/logo.png
deleted file mode 100644
index 39ec548..0000000
Binary files a/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/logo.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/style.css
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/style.css b/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/style.css
deleted file mode 100644
index 185ecd4..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/webapp/style.css
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-body, p, li, a { font-family: georgia, times, serif;font-size:13pt;}
-h1, h2, h3 { font-family: 'Yanone Kaffeesatz', arial, serif; }
-body { margin:0;padding:0;}
-#hd {
- width : 100%;
- height : 87px;
- background-color : #092E67;
- margin-top : 0;
- padding-top : 10px;
- border-bottom : 1px solid #888;
- z-index : 0;
-}
-#ft {
- position : absolute;
- bottom : 0;
- width : 100%;
- height : 99px;
- background-color : #6493D2;
- border-top : 1px solid #888;
- z-index : 0;
-}
-#logo,#bd {
- width : 650px;
- margin: 0 auto;
- padding: 25px 50px 0 50px;
-}
-#logo h1 {
- color : white;
- font-size:36pt;
- display: inline;
-}
-#logo img {
- display:inline;
- vertical-align: bottom;
- margin-left : 50px;
- margin-right : 5px;
-}
-body { margin-top : 0; padding-top : 0;}
-#logo, #logo h1 { margin-top : 0; padding-top : 0;}
-#bd {
- position : absolute;
- top : 75px;
- bottom : 75px;
- left : 50%;
- margin-left : -325px;
- z-index : 1;
- overflow: auto;
- background-color : #fff;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
- -moz-box-shadow: 0px 0px 10px #888;
- -webkit-box-shadow: 0px 0px 10px #888;
- box-shadow: 0px 0px 10px #888;
-}
-a, a:visited, a:hover, a:active {
- color : #6493D2;
-}
-h2 {
- padding : 0; margin:0;
- font-size:36pt;
- color:#FF5500;
-}
-h3 {
- padding : 0; margin:0;
- font-size:24pt;
- color:#092E67;
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/ApacheLicenceHeaderTest.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/ApacheLicenceHeaderTest.java b/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/ApacheLicenceHeaderTest.java
deleted file mode 100644
index a145cc6..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/ApacheLicenceHeaderTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import org.apache.wicket.util.license.ApacheLicenseHeaderTestCase;
-
-/**
- * Test that the license headers are in place in this project. The tests are run from
- * {@link ApacheLicenseHeaderTestCase}, but you can add project specific tests here if needed.
- */
-public class ApacheLicenceHeaderTest extends ApacheLicenseHeaderTestCase
-{
- /**
- * Construct.
- */
- public ApacheLicenceHeaderTest()
- {
- // addHeaders = true;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/StartNativeWebSocketExample.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/StartNativeWebSocketExample.java b/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/StartNativeWebSocketExample.java
deleted file mode 100644
index 22a5df0..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/test/java/org/apache/wicket/protocol/ws/example/StartNativeWebSocketExample.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import org.apache.wicket.protocol.ws.javax.WicketServerEndpointConfig;
-import org.eclipse.jetty.server.HttpConfiguration;
-import org.eclipse.jetty.server.HttpConnectionFactory;
-import org.eclipse.jetty.server.SecureRequestCustomizer;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.SslConnectionFactory;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
-import org.eclipse.jetty.webapp.WebAppContext;
-import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
-import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
-
-public class StartNativeWebSocketExample
-{
- public static void main(String[] args) throws Exception
- {
- HttpConfiguration http_config = new HttpConfiguration();
- http_config.setSecureScheme("https");
- http_config.setSecurePort(8443);
- http_config.setOutputBufferSize(32768);
- http_config.setRequestHeaderSize(8192);
- http_config.setResponseHeaderSize(8192);
- http_config.setSendServerVersion(true);
- http_config.setSendDateHeader(false);
-
- Server server = new Server();
- ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
-
- // Set some timeout options to make debugging easier.
-// connector.setMaxIdleTime(timeout);
- connector.setSoLingerTime(-1);
- connector.setPort(8080);
- server.addConnector(connector);
-
- Resource keystore = Resource.newClassPathResource("/keystore");
- if (keystore != null && keystore.exists()) {
- // if a keystore for a SSL certificate is available, start a SSL
- // connector on port 8443.
- // By default, the quickstart comes with a Apache Wicket Quickstart
- // Certificate that expires about half way september 2021. Do not
- // use this certificate anywhere important as the passwords are
- // available in the source.
-
- SslContextFactory factory = new SslContextFactory();
- factory.setKeyStoreResource(keystore);
- factory.setKeyStorePassword("wicket");
- factory.setTrustStoreResource(keystore);
- factory.setKeyManagerPassword("wicket");
-
- // SSL HTTP Configuration
- HttpConfiguration https_config = new HttpConfiguration(http_config);
- https_config.addCustomizer(new SecureRequestCustomizer());
-
- // SSL Connector
- ServerConnector sslConnector = new ServerConnector(server,
- new SslConnectionFactory(factory,"http/1.1"),
- new HttpConnectionFactory(https_config));
- sslConnector.setPort(8443);
- server.addConnector(sslConnector);
-
- System.out.println("SSL access to the quickstart has been enabled on port 8443");
- System.out.println("You can access the application using SSL on https://localhost:8443");
- System.out.println();
- }
-
- WebAppContext bb = new WebAppContext();
- bb.setServer(server);
- bb.setContextPath("/");
-// bb.setExtraClasspath("target/classes");
- bb.setWar("src/main/webapp");
-// bb.getMetaData().addContainerResource(new FileResource(new File("./target/classes").toURI()));
-// bb.setConfigurations(new Configuration[]{
-// new WebXmlConfiguration(),
-// new AnnotationConfiguration()
-// });
-// ServletContainerInitializersStarter starter = new ServletContainerInitializersStarter(bb);
-// starter.doStart();
-
- ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb);
- serverContainer.addEndpoint(new WicketServerEndpointConfig());
-// WebSocketUpgradeFilter upgradeFilter =
-// (WebSocketUpgradeFilter) webAppContext.getAttribute(WebSocketUpgradeFilter.class.getName());
-// upgradeFilter.getFactory().getPolicy().setIdleTimeout(5000);
-
- // START JMX SERVER
- // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
- // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
- // server.getContainer().addEventListener(mBeanContainer);
- // mBeanContainer.start();
-
- server.setHandler(bb);
-
- try {
- System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
- server.start();
- System.in.read();
- System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
- server.stop();
- server.join();
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/test/resources/keystore b/wicket-native-websocket/wicket-native-websocket-example/src/test/resources/keystore
deleted file mode 100644
index 30bbc90..0000000
Binary files a/wicket-native-websocket/wicket-native-websocket-example/src/test/resources/keystore and /dev/null differ
[2/2] wicket git commit: WICKET-6309 Move the Native WebSocket demo
to wicket-examples module
Posted by mg...@apache.org.
WICKET-6309 Move the Native WebSocket demo to wicket-examples module
WICKET-6305 Remove Atmosphere examples
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/18acedc4
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/18acedc4
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/18acedc4
Branch: refs/heads/master
Commit: 18acedc4cfc60b88e696a96e28099362ebcccb0c
Parents: 65dffc1
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jan 17 22:08:17 2017 +0100
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jan 17 22:08:17 2017 +0100
----------------------------------------------------------------------
pom.xml | 26 +---
wicket-examples/pom.xml | 29 +---
.../atmosphere/AtmosphereApplication.java | 67 ---------
.../wicket/examples/atmosphere/ChatMessage.java | 42 ------
.../wicket/examples/atmosphere/HomePage.html | 25 ----
.../wicket/examples/atmosphere/HomePage.java | 93 ------------
.../examples/atmosphere/ReceiverFilter.java | 41 -----
.../wicket/examples/websocket/HomePage.html | 35 +++++
.../wicket/examples/websocket/HomePage.java | 23 +++
.../examples/websocket/JSR356Application.java | 72 +++++++++
.../websocket/WebSocketBehaviorDemoPage.html | 30 ++++
.../websocket/WebSocketBehaviorDemoPage.java | 58 ++++++++
.../websocket/WebSocketResourceDemoPage.html | 30 ++++
.../websocket/WebSocketResourceDemoPage.java | 34 +++++
.../examples/websocket/charts/ChartUpdater.java | 147 ++++++++++++++++++
.../charts/ChartWebSocketResource.java | 40 +++++
.../charts/ChartsResourceReference.java | 52 +++++++
.../websocket/charts/WebSocketChart.html | 23 +++
.../websocket/charts/WebSocketChart.java | 41 +++++
.../wicket/examples/websocket/charts/charts.js | 105 +++++++++++++
.../wicket/examples/homepage/HomePage.html | 2 +-
wicket-examples/src/main/webapp/WEB-INF/web.xml | 60 ++------
.../apache/wicket/examples/StartExamples.java | 8 +-
wicket-native-websocket/pom.xml | 1 -
.../wicket-native-websocket-example/pom.xml | 148 -------------------
.../wicket/protocol/ws/example/HomePage.html | 40 -----
.../wicket/protocol/ws/example/HomePage.java | 23 ---
.../protocol/ws/example/JSR356Application.java | 72 ---------
.../ws/example/WebSocketBehaviorDemoPage.html | 35 -----
.../ws/example/WebSocketBehaviorDemoPage.java | 58 --------
.../ws/example/WebSocketResourceDemoPage.html | 35 -----
.../ws/example/WebSocketResourceDemoPage.java | 34 -----
.../protocol/ws/example/WrappingFilter.java | 51 -------
.../ws/example/charts/ChartUpdater.java | 148 -------------------
.../example/charts/ChartWebSocketResource.java | 40 -----
.../example/charts/ChartsResourceReference.java | 52 -------
.../ws/example/charts/WebSocketChart.html | 23 ---
.../ws/example/charts/WebSocketChart.java | 41 -----
.../wicket/protocol/ws/example/charts/charts.js | 105 -------------
.../src/main/resources/log4j.properties | 25 ----
.../src/main/webapp/WEB-INF/web.xml | 55 -------
.../src/main/webapp/logo.png | Bin 12244 -> 0 bytes
.../src/main/webapp/style.css | 84 -----------
.../ws/example/ApacheLicenceHeaderTest.java | 34 -----
.../ws/example/StartNativeWebSocketExample.java | 124 ----------------
.../src/test/resources/keystore | Bin 1481 -> 0 bytes
46 files changed, 721 insertions(+), 1590 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1b15eac..cb994ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,7 +128,7 @@
<!-- Project Versions -->
<jacoco.version>0.7.8</jacoco.version>
- <jetty.version>9.3.10.v20160621</jetty.version>
+ <jetty.version>9.4.0.v20161208</jetty.version>
<joda-time.version>2.9.4</joda-time.version>
<junit.version>4.12</junit.version>
<spring.version>4.3.4.RELEASE</spring.version>
@@ -189,31 +189,13 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
+ <classifier>uber</classifier>
</dependency>
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-jmx</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.4</version>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-examples/pom.xml b/wicket-examples/pom.xml
index 40ebea4..63d6298 100644
--- a/wicket-examples/pom.xml
+++ b/wicket-examples/pom.xml
@@ -58,24 +58,9 @@
</dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${jetty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>${jetty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>${jetty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-jmx</artifactId>
- <version>${jetty.version}</version>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <classifier>uber</classifier>
</dependency>
<dependency>
<groupId>javax.el</groupId>
@@ -150,10 +135,10 @@
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-velocity</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.wicket.experimental.wicket8</groupId>
- <artifactId>wicket-atmosphere</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-native-websocket-javax</artifactId>
+ </dependency>
<dependency>
<groupId>org.codelibs</groupId>
<artifactId>jhighlight</artifactId>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/AtmosphereApplication.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/AtmosphereApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/AtmosphereApplication.java
deleted file mode 100644
index 1f02e5b..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/AtmosphereApplication.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.examples.atmosphere;
-
-import java.util.Date;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.atmosphere.EventBus;
-import org.apache.wicket.atmosphere.config.AtmosphereLogLevel;
-import org.apache.wicket.atmosphere.config.AtmosphereTransport;
-import org.apache.wicket.protocol.http.WebApplication;
-
-/**
- * Application object for your web application. If you want to run this application without
- * deploying, run the Start class.
- */
-public class AtmosphereApplication extends WebApplication
-{
- private EventBus eventBus;
-
- @Override
- public Class<HomePage> getHomePage()
- {
- return HomePage.class;
- }
-
- public EventBus getEventBus()
- {
- return eventBus;
- }
-
- public static AtmosphereApplication get()
- {
- return (AtmosphereApplication)Application.get();
- }
-
- @Override
- public void init()
- {
- super.init();
-
- eventBus = new EventBus(this);
- eventBus.getParameters().setTransport(AtmosphereTransport.STREAMING);
- eventBus.getParameters().setLogLevel(AtmosphereLogLevel.DEBUG);
-
- ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
- final Runnable beeper = () -> eventBus.post(new Date());
- scheduler.scheduleWithFixedDelay(beeper, 2, 2, TimeUnit.SECONDS);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ChatMessage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ChatMessage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ChatMessage.java
deleted file mode 100644
index 27450fe..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ChatMessage.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.examples.atmosphere;
-
-import java.io.Serializable;
-
-public class ChatMessage implements Serializable
-{
-
- private String receiver;
- private String message;
-
- public ChatMessage(String receiver, String message)
- {
- this.receiver = receiver;
- this.message = message;
- }
-
- public String getReceiver()
- {
- return receiver;
- }
-
- public String getMessage()
- {
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.html
deleted file mode 100644
index 6787a86..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:wicket="http://wicket.apache.org">
-<head>
-<title>Wicket Examples - atmosphere</title>
-<link rel="stylesheet" type="text/css" href="style.css" />
-</head>
-<body>
- <span wicket:id="mainNavigation"></span>
- <p>
- The current time is (updated every 2 seconds from the server using push): <span wicket:id="time"></span>
- </p>
- <p>This page also shows a very simple 'chat' client. Type a message in the
- second input field and send it to everyone. To send a private message, paste
- the session id (you can find this in the session cookie) of the receiver in
- the first input field and send a message.</p>
- <p>
- Message received: <span wicket:id="message"></span>
- </p>
- <form wicket:id="form">
- <div>Session id of receiver: <input wicket:id="receiver" /></div>
- Message: <input wicket:id="input" /> <a href="#" wicket:id="send">Send
- message</a>
- </form>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.java
deleted file mode 100644
index 01593da..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/HomePage.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.examples.atmosphere;
-
-import java.util.Date;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
-import org.apache.wicket.atmosphere.AtmosphereInternalEvent;
-import org.apache.wicket.atmosphere.EventBus;
-import org.apache.wicket.atmosphere.Subscribe;
-import org.apache.wicket.examples.WicketExamplePage;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-public class HomePage extends WicketExamplePage
-{
- private static final long serialVersionUID = 1L;
-
- private Component timeLabel;
- private Component messageLabel;
- private TextField<String> receiver;
- private TextField<String> input;
-
- public HomePage(final PageParameters parameters)
- {
- super(parameters);
-
- add(timeLabel = new Label("time", Model.of("start")).setOutputMarkupId(true));
- add(messageLabel = new Label("message", Model.of("-")).setOutputMarkupId(true));
-
- Form<Void> form = new Form<>("form");
- add(form);
- form.add(receiver = new TextField<>("receiver", Model.of("")));
- form.add(input = new TextField<>("input", Model.of("")));
- form.add(new AjaxSubmitLink("send", form)
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onSubmit(AjaxRequestTarget target)
- {
- EventBus.get().post(
- new ChatMessage(receiver.getModelObject(), input.getModelObject()));
- }
-
- @Override
- protected void onError(AjaxRequestTarget target)
- {
- }
- });
-
- setVersioned(false);
- }
-
- @Subscribe
- public void updateTime(AjaxRequestTarget target, Date event)
- {
- timeLabel.setDefaultModelObject(event.toString());
- target.add(timeLabel);
- }
-
- @Subscribe(contextAwareFilter = ReceiverFilter.class)
- public void receiveMessage(AjaxRequestTarget target, ChatMessage message)
- {
- messageLabel.setDefaultModelObject(message.getMessage());
- target.add(messageLabel);
- }
-
- @Subscribe
- public void internalEvent(AjaxRequestTarget target, AtmosphereInternalEvent message)
- {
-// System.err.println(message);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ReceiverFilter.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ReceiverFilter.java b/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ReceiverFilter.java
deleted file mode 100644
index 503dccb..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/atmosphere/ReceiverFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.examples.atmosphere;
-
-import org.apache.wicket.Session;
-import org.apache.wicket.atmosphere.AtmosphereEvent;
-
-import com.google.common.base.Predicate;
-
-public class ReceiverFilter implements Predicate<AtmosphereEvent>
-{
- public ReceiverFilter()
- {
- }
-
- @Override
- public boolean apply(AtmosphereEvent input)
- {
- if (input.getPayload() instanceof ChatMessage)
- {
- ChatMessage msg = (ChatMessage)input.getPayload();
- return msg.getReceiver() == null || msg.getReceiver().isEmpty() ||
- msg.getReceiver().equals(Session.get().getId());
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.html
new file mode 100644
index 0000000..83f9685
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.html
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+ <head>
+ <meta charset="utf-8" />
+ <title>Apache Wicket Native WebSocket demos</title>
+ <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
+ </head>
+ <body>
+ <div wicket:id="mainNavigation"></div>
+
+ <wicket:link>
+ <ul>
+ <li><a href="WebSocketBehaviorDemoPage.html">demo with WebSocketBehavior</a></li>
+ <li><a href="WebSocketResourceDemoPage.html">demo with WebSocketResource</a></li>
+ </ul>
+ </wicket:link>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.java
new file mode 100644
index 0000000..d2c56b9
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/HomePage.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket;
+
+import org.apache.wicket.examples.WicketExamplePage;
+
+public class HomePage extends WicketExamplePage
+{
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/JSR356Application.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/JSR356Application.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/JSR356Application.java
new file mode 100644
index 0000000..b0275a4
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/JSR356Application.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket;
+
+import org.apache.wicket.examples.websocket.charts.ChartWebSocketResource;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.https.HttpsConfig;
+import org.apache.wicket.protocol.https.HttpsMapper;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * Application object for your web application.
+ * If you want to run this application without deploying, run the com.wicketinaction.StartNativeWebSocketExample class.
+ */
+public class JSR356Application extends WebApplication
+{
+ private ScheduledExecutorService scheduledExecutorService;
+
+ @Override
+ public Class<HomePage> getHomePage()
+ {
+ return HomePage.class;
+ }
+
+ @Override
+ public void init()
+ {
+ super.init();
+
+ scheduledExecutorService = Executors.newScheduledThreadPool(1);
+
+ setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)));
+
+ mountPage("/behavior", WebSocketBehaviorDemoPage.class);
+ mountPage("/resource", WebSocketResourceDemoPage.class);
+
+ getSharedResources().add(ChartWebSocketResource.NAME, new ChartWebSocketResource());
+ }
+
+ @Override
+ protected void onDestroy() {
+ scheduledExecutorService.shutdownNow();
+
+ super.onDestroy();
+ }
+
+ public ScheduledExecutorService getScheduledExecutorService()
+ {
+ return scheduledExecutorService;
+ }
+
+ public static JSR356Application get()
+ {
+ return (JSR356Application) WebApplication.get();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.html
new file mode 100644
index 0000000..136256e
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.html
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+ <head>
+ <meta charset="utf-8" />
+ <title>WebSocketBehavior demo - Apache Wicket Native WebSocket</title>
+ <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
+ </head>
+ <body>
+ <div wicket:id="mainNavigation"></div>
+
+ <div wicket:id="chartPanel"></div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.java
new file mode 100644
index 0000000..cf3b321
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketBehaviorDemoPage.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.apache.wicket.examples.WicketExamplePage;
+import org.apache.wicket.examples.websocket.charts.ChartUpdater;
+import org.apache.wicket.examples.websocket.charts.WebSocketChart;
+import org.apache.wicket.protocol.https.RequireHttps;
+import org.apache.wicket.protocol.ws.api.WebSocketBehavior;
+import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
+import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
+import org.apache.wicket.protocol.ws.api.message.TextMessage;
+
+@RequireHttps
+public class WebSocketBehaviorDemoPage extends WicketExamplePage
+{
+ public WebSocketBehaviorDemoPage()
+ {
+ WebSocketChart chartPanel = new WebSocketChart("chartPanel");
+ chartPanel.add(new WebSocketBehavior()
+ {
+ @Override
+ protected void onConnect(ConnectedMessage message)
+ {
+ super.onConnect(message);
+
+ ScheduledExecutorService service = JSR356Application.get().getScheduledExecutorService();
+ ChartUpdater.start(message, service);
+ }
+ });
+ add(chartPanel);
+
+ add(new WebSocketBehavior()
+ {
+ @Override
+ protected void onMessage(WebSocketRequestHandler handler, TextMessage message)
+ {
+ super.onMessage(handler, message);
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.html
new file mode 100644
index 0000000..f5b1099
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.html
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+ <head>
+ <meta charset="utf-8" />
+ <title>WebSocketResource demo - Apache Wicket Native WebSocket</title>
+ <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
+ </head>
+ <body>
+ <div wicket:id="mainNavigation"></div>
+
+ <div wicket:id="chartPanel"></div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.java
new file mode 100644
index 0000000..d8aef4d
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/WebSocketResourceDemoPage.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket;
+
+import org.apache.wicket.examples.WicketExamplePage;
+import org.apache.wicket.examples.websocket.charts.ChartWebSocketResource;
+import org.apache.wicket.examples.websocket.charts.WebSocketChart;
+import org.apache.wicket.protocol.https.RequireHttps;
+import org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior;
+
+@RequireHttps
+public class WebSocketResourceDemoPage extends WicketExamplePage
+{
+ public WebSocketResourceDemoPage()
+ {
+ WebSocketChart chartPanel = new WebSocketChart("chartPanel");
+ chartPanel.add(new BaseWebSocketBehavior(ChartWebSocketResource.NAME));
+ add(chartPanel);
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartUpdater.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartUpdater.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartUpdater.java
new file mode 100644
index 0000000..29f11dc
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartUpdater.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket.charts;
+
+import java.util.Random;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.protocol.ws.WebSocketSettings;
+import org.apache.wicket.protocol.ws.api.IWebSocketConnection;
+import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
+import org.apache.wicket.protocol.ws.api.registry.IKey;
+import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry;
+
+/**
+ * A helper class that uses the web connection to push data to the
+ * client.
+ * To keep the demo simpler it doesn't use #onClose() to stop
+ * the thread.
+ */
+public class ChartUpdater
+{
+ public static void start(ConnectedMessage message, ScheduledExecutorService scheduledExecutorService)
+ {
+ Record[] data = generateData();
+
+ // create an asynchronous task that will write the data to the client
+ UpdateTask updateTask = new UpdateTask(message.getApplication(), message.getSessionId(), message.getKey(), data);
+ scheduledExecutorService.schedule(updateTask, 1, TimeUnit.SECONDS);
+ }
+
+
+
+ /**
+ * Generates some random data to send to the client
+ * @return records with random data
+ */
+ private static Record[] generateData()
+ {
+ Random randomGenerator = new Random();
+ Record[] data = new Record[1000];
+ for (int i = 0; i < 1000; i++)
+ {
+ Record r = new Record();
+ r.year = 2000 + i;
+ r.field = (i % 2 == 0) ? "Company 1" : "Company 2";
+ r.value = randomGenerator.nextInt(1500);
+ data[i] = r;
+ }
+ return data;
+ }
+
+
+ /**
+ * A task that sends data to the client by pushing it to the web socket connection
+ */
+ private static class UpdateTask implements Runnable
+ {
+ private static final String JSON_SKELETON = "{ \"year\": \"%s\", \"field\": \"%s\", \"value\": %s }";
+
+ /**
+ * The following fields are needed to be able to lookup the IWebSocketConnection from
+ * IWebSocketConnectionRegistry
+ */
+ private final String applicationName;
+ private final String sessionId;
+ private final IKey key;
+
+ /**
+ * The data that has to be sent to the client
+ */
+ private final Record[] data;
+
+ private UpdateTask(Application application, String sessionId, IKey key, Record[] data)
+ {
+ this.applicationName = application.getName();
+ this.sessionId = sessionId;
+ this.key = key;
+ this.data = data;
+ }
+
+ @Override
+ public void run()
+ {
+ Application application = Application.get(applicationName);
+ WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
+ IWebSocketConnectionRegistry webSocketConnectionRegistry = webSocketSettings.getConnectionRegistry();
+ IWebSocketConnection connection = webSocketConnectionRegistry.getConnection(application, sessionId, key);
+
+ int dataIndex = 0;
+
+ while (dataIndex < data.length)
+ {
+ try
+ {
+ Record record = data[dataIndex++];
+ String json = String.format(JSON_SKELETON, record.year, record.field, record.value);
+
+ if (connection == null || !connection.isOpen())
+ {
+ // stop if the web socket connection is closed
+ return;
+ }
+ connection.sendMessage(json);
+
+ // sleep for a while to simulate work
+ TimeUnit.SECONDS.sleep(1);
+ }
+ catch (InterruptedException x)
+ {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * The data that is being sent to the client in JSON format
+ */
+ private static class Record
+ {
+ private int year;
+ private String field;
+ private int value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartWebSocketResource.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartWebSocketResource.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartWebSocketResource.java
new file mode 100644
index 0000000..b3ebfc5
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartWebSocketResource.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket.charts;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.apache.wicket.examples.websocket.JSR356Application;
+import org.apache.wicket.protocol.ws.api.WebSocketResource;
+import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
+
+/**
+ *
+ */
+public class ChartWebSocketResource extends WebSocketResource
+{
+ public static final String NAME = ChartWebSocketResource.class.getName();
+
+ @Override
+ protected void onConnect(ConnectedMessage message)
+ {
+ super.onConnect(message);
+
+ ScheduledExecutorService service = JSR356Application.get().getScheduledExecutorService();
+ ChartUpdater.start(message, service);
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartsResourceReference.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartsResourceReference.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartsResourceReference.java
new file mode 100644
index 0000000..d6f8100
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/ChartsResourceReference.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket.charts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.markup.head.HeaderItem;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.protocol.ws.api.WicketWebSocketJQueryResourceReference;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.resource.JavaScriptResourceReference;
+import org.apache.wicket.request.resource.UrlResourceReference;
+
+/**
+ * A resource reference that contributes 'charts.js' - the JavaScript that registers the WebSocket client
+ * and constructs the Google chart.
+ */
+public class ChartsResourceReference extends JavaScriptResourceReference
+{
+ public ChartsResourceReference()
+ {
+ super(ChartsResourceReference.class, "charts.js");
+ }
+
+ /**
+ * Specify that charts.js depends on Google JS APIs and Wicket WebSocket JavaScript
+ * @return a list of dependencies
+ */
+ @Override
+ public List<HeaderItem> getDependencies()
+ {
+ List<HeaderItem> dependencies = new ArrayList<HeaderItem>();
+ dependencies.add(JavaScriptHeaderItem.forReference(new UrlResourceReference(Url.parse("https://www.google.com/jsapi"))));
+ dependencies.add(JavaScriptHeaderItem.forReference(WicketWebSocketJQueryResourceReference.get()));
+ return dependencies;
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.html b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.html
new file mode 100644
index 0000000..4f245b6
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.html
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:panel>
+ <div id="chart_div"></div>
+</wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.java b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.java
new file mode 100644
index 0000000..af9675e
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/WebSocketChart.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.examples.websocket.charts;
+
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.markup.html.panel.Panel;
+
+/**
+ * A panel that initializes a Google Line chart and uses WebSocketBehavior to register an asynchronous
+ * task that will push some data through the web socket connection.
+ */
+public class WebSocketChart extends Panel
+{
+ public WebSocketChart(final String id)
+ {
+ super(id);
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response)
+ {
+ super.renderHead(response);
+ response.render(JavaScriptHeaderItem.forReference(new ChartsResourceReference()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/charts.js
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/charts.js b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/charts.js
new file mode 100644
index 0000000..501d9e0
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/websocket/charts/charts.js
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+google.load("visualization", "1", {
+ packages:["corechart"]
+});
+
+google.setOnLoadCallback(drawChart);
+
+function drawChart() {
+
+ var options = {
+ title: 'Stock prices'
+ };
+
+ var rawData = [
+ ['Year', 'Company 1', 'Company 2'],
+ ["1999", 0, 0]
+ ];
+
+ var chart;
+
+ /**
+ * (Re)Initializes the chart
+ */
+ var updateChart = function() {
+ var data = google.visualization.arrayToDataTable(rawData);
+ if (chart) {
+ chart.clearChart();
+ } else {
+ chart = new google.visualization.LineChart(Wicket.$('chart_div'));
+ }
+ chart.draw(data, options);
+ };
+
+ /**
+ * Updates the chart data by updating or appending the new data pushed by the server
+ *
+ * @param data the new data pushed by the server
+ */
+ var updateChartData = function(data) {
+
+ // the index of the column which data will be updated. Either 1 (Company 1) or 2 (Company 2)
+ var columnIndex = rawData[0].indexOf(data.field);
+
+ var replaced = false;
+
+ // look whether there is already a record for that year and update the data for the company
+ for (var r = 1; r < rawData.length; r++) {
+ var oldRecord = rawData[r];
+ if (oldRecord[0] === data.year) {
+ oldRecord[columnIndex] = data.value;
+ replaced = true;
+ break;
+ }
+ }
+
+ if (!replaced) {
+ // there is no update, so append the new data
+
+ // the data of the last appended record
+ var lastRecord = rawData[rawData.length - 1];
+
+ // the new record that keeps the same data as the last one but updates the value for the updated company
+ var newRecord = [data.year, lastRecord[1], lastRecord[2]];
+ newRecord[columnIndex] = data.value;
+ rawData.push(newRecord);
+ }
+
+ if (rawData.length > 20) {
+ // show at most 20 years back. The first record is special (the headers), so cut the second one
+ rawData.splice(1, 1);
+ }
+
+ updateChart();
+ };
+
+ Wicket.Event.subscribe("/websocket/open", function(jqEvent) {
+ // show the initial state of the chart
+ updateChart();
+ });
+
+ Wicket.Event.subscribe("/websocket/message", function(jqEvent, message) {
+ // new record is pushed by the server
+
+ var record = jQuery.parseJSON(message);
+ if (record && record.year) {
+ updateChartData(record);
+ }
+ });
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/resources/org/apache/wicket/examples/homepage/HomePage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/resources/org/apache/wicket/examples/homepage/HomePage.html b/wicket-examples/src/main/resources/org/apache/wicket/examples/homepage/HomePage.html
index d83ae2c..1175eab 100644
--- a/wicket-examples/src/main/resources/org/apache/wicket/examples/homepage/HomePage.html
+++ b/wicket-examples/src/main/resources/org/apache/wicket/examples/homepage/HomePage.html
@@ -63,10 +63,10 @@
<tr><td align="right"><a href="mappers">Wicket 1.5 Request Mappers</a></td><td> - Shows custom request mappers.</td></tr>
<tr><td align="right"><a href="events">Wicket 1.5 Events</a></td><td> - Shows inter-component events</td></tr>
<tr><td align="right"><a href="resourceaggregation">Resource decoration</a></td><td> - Shows aggregation of css and js resources</td></tr>
- <tr><td align="right"><a href="atmosphere">Atmosphere</a></td><td> - Atmosphere Framework integration</td></tr>
<tr><td align="right"><a href="cdi">CDI</a></td><td> - Context Dependency and Injection integration</td></tr>
<tr><td align="right"><a href="bean-validation">Bean Validation</a></td><td> - Bean Validation integration (JSR 303)</td></tr>
<tr><td align="right"><a href="videos">HTML5 Media Tags</a></td><td> - Integration for HTML5 Media Tags</td></tr>
+ <tr><td align="right"><a href="websockets">Web Sockets</a></td><td> - Integration for JSR356 Web Sockets</td></tr>
</tbody>
</table>
</div>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/WEB-INF/web.xml b/wicket-examples/src/main/webapp/WEB-INF/web.xml
index 807f820..e23b1a1 100644
--- a/wicket-examples/src/main/webapp/WEB-INF/web.xml
+++ b/wicket-examples/src/main/webapp/WEB-INF/web.xml
@@ -457,8 +457,19 @@
</filter>
<!-- couple the session filter to the helloworld servlet -->
+ <filter>
+ <filter-name>wicket.wicket-native-websockets</filter-name>
+ <filter-class>org.apache.wicket.protocol.ws.javax.JavaxWebSocketFilter</filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+ <param-value>org.apache.wicket.examples.websocket.JSR356Application</param-value>
+ </init-param>
+ </filter>
-
+ <filter-mapping>
+ <filter-name>wicket.wicket-native-websockets</filter-name>
+ <url-pattern>/websockets/*</url-pattern>
+ </filter-mapping>
@@ -866,53 +877,6 @@
<url-pattern>/servlettest/*</url-pattern>
</servlet-mapping>
- <servlet>
- <servlet-name>AtmosphereApplication</servlet-name>
- <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
- <init-param>
- <param-name>applicationClassName</param-name>
- <param-value>org.apache.wicket.examples.atmosphere.AtmosphereApplication</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.useWebSocket</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.useNative</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.cpr.sessionSupport</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity</param-name>
- <param-value>30000</param-value>
- </init-param>
- <init-param>
- <param-name>filterMappingUrlPattern</param-name>
- <param-value>/atmosphere/*</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.websocket.WebSocketProtocol</param-name>
- <param-value>org.atmosphere.websocket.protocol.EchoProtocol</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name>
- <param-value>org.atmosphere.client.TrackMessageSizeInterceptor</param-value>
- </init-param>
- <init-param>
- <param-name>org.atmosphere.client.TrackMessageSizeInterceptor.delimiter</param-name>
- <param-value><![CDATA[<|msg|>]]></param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>AtmosphereApplication</servlet-name>
- <url-pattern>/atmosphere/*</url-pattern>
- </servlet-mapping>
-
<session-config>
<session-timeout>5</session-timeout>
</session-config>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java b/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
index f274e40..18e6c26 100644
--- a/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
+++ b/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
@@ -20,6 +20,7 @@ import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
+import org.apache.wicket.protocol.ws.javax.WicketServerEndpointConfig;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
@@ -30,6 +31,8 @@ import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
+import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
/**
* Separate startup class for people that want to run the examples directly. Use parameter
@@ -42,7 +45,7 @@ public class StartExamples
*
* @param args
*/
- public static void main(String[] args)
+ public static void main(String[] args) throws Exception
{
System.setProperty("wicket.configuration", "development");
@@ -94,6 +97,9 @@ public class StartExamples
bb.setContextPath("/");
bb.setWar("src/main/webapp");
+ ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb);
+ serverContainer.addEndpoint(new WicketServerEndpointConfig());
+
// uncomment next line if you want to test with JSESSIONID encoded in the urls
// ((AbstractSessionManager)
// bb.getSessionHandler().getSessionManager()).setUsingCookies(false);
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/pom.xml b/wicket-native-websocket/pom.xml
index b81fe33..3c4309b 100644
--- a/wicket-native-websocket/pom.xml
+++ b/wicket-native-websocket/pom.xml
@@ -30,6 +30,5 @@
<modules>
<module>wicket-native-websocket-core</module>
<module>wicket-native-websocket-javax</module>
- <module>wicket-native-websocket-example</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/pom.xml b/wicket-native-websocket/wicket-native-websocket-example/pom.xml
deleted file mode 100644
index 97106fb..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/pom.xml
+++ /dev/null
@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-native-websocket</artifactId>
- <version>8.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>wicket-native-websocket-example</artifactId>
- <packaging>war</packaging>
- <name>Wicket Native WebSocket Example</name>
-
- <properties>
- <jetty.version>9.2.3.v20140905</jetty.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <!-- WICKET DEPENDENCIES -->
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>org.apache.wicket</groupId>-->
- <!--<artifactId>wicket-native-websocket-jetty9</artifactId>-->
- <!--<version>${wicket.version}</version>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.apache.wicket</groupId>-->
- <!--<artifactId>wicket-native-websocket-tomcat</artifactId>-->
- <!--<version>${wicket.version}</version>-->
- <!--</dependency>-->
-
- <!--<dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-websocket</artifactId>
- <version>8.5.8</version>
- <scope>provided</scope>
- </dependency>-->
-
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-native-websocket-javax</artifactId>
- </dependency>
-
- <!-- LOGGING DEPENDENCIES - LOG4J -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
-
- <!-- JUNIT DEPENDENCY FOR TESTING -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- </dependency>
-
- <!-- JETTY DEPENDENCIES FOR TESTING -->
- <dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-all</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**</include>
- </includes>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- </testResource>
- <testResource>
- <directory>src/test/java</directory>
- <includes>
- <include>**</include>
- </includes>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <inherited>true</inherited>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>${jetty.version}</version>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.html
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.html b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.html
deleted file mode 100644
index 72e6466..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<!DOCTYPE html>
-<html xmlns:wicket="http://wicket.apache.org">
- <head>
- <meta charset="utf-8" />
- <title>Apache Wicket Quickstart</title>
- <link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold' rel='stylesheet' type='text/css' />
- <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
- </head>
- <body>
- <div id="hd">
- <div id="logo">
- <img src="logo.png" width="50px" height="50px" alt="Wicket Logo" />
- <h1>Apache Wicket</h1>
- </div>
- </div>
- <wicket:link>
- <ul>
- <li><a href="WebSocketBehaviorDemoPage.html">demo with WebSocketBehavior</a></li>
- <li><a href="WebSocketResourceDemoPage.html">demo with WebSocketResource</a></li>
- </ul>
- </wicket:link>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.java
deleted file mode 100644
index 26f3626..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/HomePage.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import org.apache.wicket.markup.html.WebPage;
-
-public class HomePage extends WebPage
-{
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/JSR356Application.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/JSR356Application.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/JSR356Application.java
deleted file mode 100644
index 7ebd05d..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/JSR356Application.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import org.apache.wicket.protocol.ws.example.charts.ChartWebSocketResource;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.https.HttpsConfig;
-import org.apache.wicket.protocol.https.HttpsMapper;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-/**
- * Application object for your web application.
- * If you want to run this application without deploying, run the com.wicketinaction.StartNativeWebSocketExample class.
- */
-public class JSR356Application extends WebApplication
-{
- private ScheduledExecutorService scheduledExecutorService;
-
- @Override
- public Class<HomePage> getHomePage()
- {
- return HomePage.class;
- }
-
- @Override
- public void init()
- {
- super.init();
-
- scheduledExecutorService = Executors.newScheduledThreadPool(1);
-
- setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)));
-
- mountPage("/behavior", WebSocketBehaviorDemoPage.class);
- mountPage("/resource", WebSocketResourceDemoPage.class);
-
- getSharedResources().add(ChartWebSocketResource.NAME, new ChartWebSocketResource());
- }
-
- @Override
- protected void onDestroy() {
- scheduledExecutorService.shutdownNow();
-
- super.onDestroy();
- }
-
- public ScheduledExecutorService getScheduledExecutorService()
- {
- return scheduledExecutorService;
- }
-
- public static JSR356Application get()
- {
- return (JSR356Application) WebApplication.get();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.html
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.html b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.html
deleted file mode 100644
index 8ec9a88..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<!DOCTYPE html>
-<html xmlns:wicket="http://wicket.apache.org">
- <head>
- <meta charset="utf-8" />
- <title>Apache Wicket Quickstart</title>
- <link href='https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold' rel='stylesheet' type='text/css' />
- <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
- </head>
- <body>
- <div id="hd">
- <div id="logo">
- <img src="logo.png" width="50px" height="50px" alt="Wicket Logo" />
- <h1>Apache Wicket</h1>
- </div>
- </div>
- <div wicket:id="chartPanel"></div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.java
deleted file mode 100644
index f3c9db1..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketBehaviorDemoPage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.wicket.protocol.ws.example.charts.ChartUpdater;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.protocol.https.RequireHttps;
-import org.apache.wicket.protocol.ws.api.WebSocketBehavior;
-import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
-import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
-import org.apache.wicket.protocol.ws.api.message.TextMessage;
-import org.apache.wicket.protocol.ws.example.charts.WebSocketChart;
-
-@RequireHttps
-public class WebSocketBehaviorDemoPage extends WebPage
-{
- public WebSocketBehaviorDemoPage()
- {
- WebSocketChart chartPanel = new WebSocketChart("chartPanel");
- chartPanel.add(new WebSocketBehavior()
- {
- @Override
- protected void onConnect(ConnectedMessage message)
- {
- super.onConnect(message);
-
- ScheduledExecutorService service = JSR356Application.get().getScheduledExecutorService();
- ChartUpdater.start(message, service);
- }
- });
- add(chartPanel);
-
- add(new WebSocketBehavior()
- {
- @Override
- protected void onMessage(WebSocketRequestHandler handler, TextMessage message)
- {
- super.onMessage(handler, message);
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.html
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.html b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.html
deleted file mode 100644
index 5281758..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<!DOCTYPE html>
-<html xmlns:wicket="http://wicket.apache.org">
- <head>
- <meta charset="utf-8" />
- <title>Apache Wicket Quickstart</title>
- <link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold' rel='stylesheet' type='text/css' />
- <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
- </head>
- <body>
- <div id="hd">
- <div id="logo">
- <img src="logo.png" width="50px" height="50px" alt="Wicket Logo" />
- <h1>Apache Wicket</h1>
- </div>
- </div>
- <div wicket:id="chartPanel"></div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.java
deleted file mode 100644
index c921078..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WebSocketResourceDemoPage.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import org.apache.wicket.protocol.ws.example.charts.ChartWebSocketResource;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.protocol.https.RequireHttps;
-import org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior;
-import org.apache.wicket.protocol.ws.example.charts.WebSocketChart;
-
-@RequireHttps
-public class WebSocketResourceDemoPage extends WebPage
-{
- public WebSocketResourceDemoPage()
- {
- WebSocketChart chartPanel = new WebSocketChart("chartPanel");
- chartPanel.add(new BaseWebSocketBehavior(ChartWebSocketResource.NAME));
- add(chartPanel);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WrappingFilter.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WrappingFilter.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WrappingFilter.java
deleted file mode 100644
index 69b224f..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/WrappingFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-/**
- *
- */
-public class WrappingFilter implements Filter
-{
- @Override
- public void init(FilterConfig filterConfig) throws ServletException
- {
- }
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- {
- request = new HttpServletRequestWrapper((HttpServletRequest) request);
- chain.doFilter(request, response);
- }
-
- @Override
- public void destroy()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/18acedc4/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartUpdater.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartUpdater.java b/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartUpdater.java
deleted file mode 100644
index 5b34992..0000000
--- a/wicket-native-websocket/wicket-native-websocket-example/src/main/java/org/apache/wicket/protocol/ws/example/charts/ChartUpdater.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.protocol.ws.example.charts;
-
-import java.io.IOException;
-import java.util.Random;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.protocol.ws.WebSocketSettings;
-import org.apache.wicket.protocol.ws.api.IWebSocketConnection;
-import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
-import org.apache.wicket.protocol.ws.api.registry.IKey;
-import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry;
-
-/**
- * A helper class that uses the web connection to push data to the
- * client.
- * To keep the demo simpler it doesn't use #onClose() to stop
- * the thread.
- */
-public class ChartUpdater
-{
- public static void start(ConnectedMessage message, ScheduledExecutorService scheduledExecutorService)
- {
- Record[] data = generateData();
-
- // create an asynchronous task that will write the data to the client
- UpdateTask updateTask = new UpdateTask(message.getApplication(), message.getSessionId(), message.getKey(), data);
- scheduledExecutorService.schedule(updateTask, 1, TimeUnit.SECONDS);
- }
-
-
-
- /**
- * Generates some random data to send to the client
- * @return records with random data
- */
- private static Record[] generateData()
- {
- Random randomGenerator = new Random();
- Record[] data = new Record[1000];
- for (int i = 0; i < 1000; i++)
- {
- Record r = new Record();
- r.year = 2000 + i;
- r.field = (i % 2 == 0) ? "Company 1" : "Company 2";
- r.value = randomGenerator.nextInt(1500);
- data[i] = r;
- }
- return data;
- }
-
-
- /**
- * A task that sends data to the client by pushing it to the web socket connection
- */
- private static class UpdateTask implements Runnable
- {
- private static final String JSON_SKELETON = "{ \"year\": \"%s\", \"field\": \"%s\", \"value\": %s }";
-
- /**
- * The following fields are needed to be able to lookup the IWebSocketConnection from
- * IWebSocketConnectionRegistry
- */
- private final String applicationName;
- private final String sessionId;
- private final IKey key;
-
- /**
- * The data that has to be sent to the client
- */
- private final Record[] data;
-
- private UpdateTask(Application application, String sessionId, IKey key, Record[] data)
- {
- this.applicationName = application.getName();
- this.sessionId = sessionId;
- this.key = key;
- this.data = data;
- }
-
- @Override
- public void run()
- {
- Application application = Application.get(applicationName);
- WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
- IWebSocketConnectionRegistry webSocketConnectionRegistry = webSocketSettings.getConnectionRegistry();
- IWebSocketConnection connection = webSocketConnectionRegistry.getConnection(application, sessionId, key);
-
- int dataIndex = 0;
-
- while (dataIndex < data.length)
- {
- try
- {
- Record record = data[dataIndex++];
- String json = String.format(JSON_SKELETON, record.year, record.field, record.value);
-
- if (connection == null || !connection.isOpen())
- {
- // stop if the web socket connection is closed
- return;
- }
- connection.sendMessage(json);
-
- // sleep for a while to simulate work
- TimeUnit.SECONDS.sleep(1);
- }
- catch (InterruptedException x)
- {
- Thread.currentThread().interrupt();
- break;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- break;
- }
- }
- }
- }
-
- /**
- * The data that is being sent to the client in JSON format
- */
- private static class Record
- {
- private int year;
- private String field;
- private int value;
- }
-}