diff --git a/example/build.xml b/example/build.xml
index 73fe77cb7..fdd103f14 100644
--- a/example/build.xml
+++ b/example/build.xml
@@ -27,7 +27,7 @@ under the License.
-
+
@@ -36,6 +36,7 @@ under the License.
+
diff --git a/example/servicedef/secas.xml b/example/servicedef/secas.xml
index 706e434e7..e6a1a2d5f 100644
--- a/example/servicedef/secas.xml
+++ b/example/servicedef/secas.xml
@@ -31,4 +31,14 @@ under the License.
-->
+
+
+
+
+
+
+
+
+
+
diff --git a/example/servicedef/services.xml b/example/servicedef/services.xml
index b7ab6df9f..d44d21555 100644
--- a/example/servicedef/services.xml
+++ b/example/servicedef/services.xml
@@ -126,4 +126,11 @@ under the License.
location="component://example/minilang/example/ExampleServices.xml" invoke="testCreateExampleService">
+
+
+
+
+
+
diff --git a/example/src/org/ofbiz/example/ExampleServices.java b/example/src/org/ofbiz/example/ExampleServices.java
new file mode 100644
index 000000000..c20b714d8
--- /dev/null
+++ b/example/src/org/ofbiz/example/ExampleServices.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.ofbiz.example;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+import javax.websocket.Session;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.ServiceUtil;
+
+public class ExampleServices {
+ public static final String module = ExampleServices.class.getName();
+
+ public static Map sendExamplePushNotifications(DispatchContext dctx, Map context) {
+ String exampleId = (String) context.get("exampleId");
+ String message = (String) context.get("message");
+ Set clients = (Set) ExampleWebSockets.getClients();
+ try {
+ synchronized (clients) {
+ for (Session client : clients) {
+ client.getBasicRemote().sendText(message + ": " + exampleId);
+ }
+ }
+ } catch (IOException e) {
+ Debug.logError(e.getMessage(), module);
+ }
+ return ServiceUtil.returnSuccess();
+ }
+}
\ No newline at end of file
diff --git a/example/src/org/ofbiz/example/ExampleWebSockets.java b/example/src/org/ofbiz/example/ExampleWebSockets.java
new file mode 100644
index 000000000..4bed2fbd9
--- /dev/null
+++ b/example/src/org/ofbiz/example/ExampleWebSockets.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.ofbiz.example;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.websocket.OnClose;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.ServerEndpoint;
+
+import org.ofbiz.base.util.Debug;
+
+@ServerEndpoint("/ws/pushNotifications")
+public class ExampleWebSockets {
+
+ public static final String module = ExampleWebSockets.class.getName();
+ private static Set clients = Collections.synchronizedSet(new HashSet());
+
+
+ @OnMessage
+ public void onMessage(Session session, String msg, boolean last) {
+ try {
+ if (session.isOpen()) {
+ synchronized (clients) {
+ for(Session client : clients){
+ if (!client.equals(session)){
+ client.getBasicRemote().sendText(msg);
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ try {
+ session.close();
+ } catch (IOException ioe) {
+ Debug.logError(ioe.getMessage(), module);
+ }
+ }
+ }
+
+ @OnOpen
+ public void onOpen (Session session) {
+ // Add session to the connected sessions clients set
+ clients.add(session);
+ }
+
+ @OnClose
+ public void onClose (Session session) {
+ // Remove session from the connected sessions clients set
+ clients.remove(session);
+ }
+
+ public static Set getClients () {
+ return clients;
+ }
+}
+
diff --git a/example/webapp/example/WEB-INF/web.xml b/example/webapp/example/WEB-INF/web.xml
index fee6eba22..e22b479a6 100644
--- a/example/webapp/example/WEB-INF/web.xml
+++ b/example/webapp/example/WEB-INF/web.xml
@@ -49,7 +49,7 @@ under the License.
disableContextSecurityN
allowedPaths
- /error:/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css
+ /error:/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css:/js:/ws
errorCode403
redirectPath/control/main
diff --git a/example/webapp/example/js/ExamplePushNotifications.js b/example/webapp/example/js/ExamplePushNotifications.js
new file mode 100644
index 000000000..5859a8c5f
--- /dev/null
+++ b/example/webapp/example/js/ExamplePushNotifications.js
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+var webSocket;
+
+// Create a new instance of the websocket
+webSocket = new WebSocket('wss://' + window.location.host + '/example/ws/pushNotifications');
+
+webSocket.onopen = function(event){
+ // Do any operation on open
+};
+
+webSocket.onmessage = function(event) {
+
+ // Remove already present notification
+ jQuery('.pushNotification').remove();
+
+ // Create notification on the fly, this notification markup can be added in Messages.ftl and its css can be theme based.
+ jQuery("body")
+ .append(jQuery('')
+ .addClass('pushNotification')
+ .css({'position': 'fixed', 'top': '5%', 'right': '2%', 'background': 'lightgrey', 'border-radius': '10px', 'z-index': '9999'}));
+
+ jQuery('.pushNotification')
+ .append(jQuery('')
+ .css({'color': 'black', 'font-size': '15px', 'position': 'fixed', 'right': '2%'}).append('close'));
+
+ jQuery('.pushNotification')
+ .append(jQuery('')
+ .addClass('msg')
+ .css({'font-size': '15px', 'padding': '30px 20px 30px 20px'}));
+
+ jQuery('.pushNotification').find('.msg').append(event.data);
+
+ // show notification
+ jQuery('.pushNotification').fadeIn();
+
+ // Remove notification after 5 seconds
+ setTimeout(function() {
+ jQuery('.pushNotification').remove();
+ }, 5000 );
+
+ // Added observer for close link.
+ jQuery('.closeNotification').click(function() {
+ jQuery(this).parent('.pushNotification').remove();
+ });
+};
+
+webSocket.onerror = function(event){
+ // Do any operation on error
+};
diff --git a/example/widget/example/CommonScreens.xml b/example/widget/example/CommonScreens.xml
index cb876b9b2..1336d71f7 100644
--- a/example/widget/example/CommonScreens.xml
+++ b/example/widget/example/CommonScreens.xml
@@ -45,6 +45,14 @@ under the License.
+