This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 7b3569984 Remove the websocket push notification example
7b3569984 is described below

commit 7b356998414ae451342ac79286be51d1acaa0b7d
Author: Mridul Pathak <[email protected]>
AuthorDate: Sun Oct 25 09:20:37 2026 +0530

    Remove the websocket push notification example
    
    The example websocket endpoint used javax.websocket, which Tomcat 10 and 11 
don't serve, so the endpoint returned 404 and every example screen opened a 
failing connection. Its tomcat-embed-websocket 9 dependency also put a second 
copy of the Tomcat 9 core classes on the runtime classpath. OFBIZ-7467 was 
closed as Abandoned, so remove the endpoint, the push notification service and 
its SECAs, the script and the dependency instead of migrating them.
---
 example/build.gradle                               |  4 -
 example/servicedef/secas.xml                       | 10 ---
 example/servicedef/services.xml                    |  9 ---
 .../org/apache/ofbiz/example/ExampleServices.java  | 49 ------------
 .../apache/ofbiz/example/ExampleWebSockets.java    | 93 ----------------------
 .../webapp/example/js/ExamplePushNotifications.js  | 67 ----------------
 example/widget/example/CommonScreens.xml           |  8 --
 7 files changed, 240 deletions(-)

diff --git a/example/build.gradle b/example/build.gradle
index 438e40404..206a20649 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -21,10 +21,6 @@ plugins {
     id 'ofbiz-node-conventions'
 }
 
-dependencies {
-    pluginLibsCompile 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.123' 
// Moving to Tomcat 10 needs more work or maybe removing websocket that does 
not work anyway, see OFBIZ-7073
-}
-
 node {
     nodeProjectDir = file("vite-react-app")
 }
diff --git a/example/servicedef/secas.xml b/example/servicedef/secas.xml
index 74382b1fd..3ff9d155f 100644
--- a/example/servicedef/secas.xml
+++ b/example/servicedef/secas.xml
@@ -31,14 +31,4 @@ under the License.
         <action service="createExampleStatus" mode="sync"/>
     </eca>
     -->
-    <!-- Send push notification on create example -->
-    <eca service="updateExample" event="global-commit-post-run">
-        <set field-name="message" value="Example is updated"/>
-        <action service="sendExamplePushNotifications" mode="sync"/>
-    </eca>
-    <!-- Send push notification on update example -->
-    <eca service="createExample" event="global-commit-post-run">
-        <set field-name="message" value="New example created"/>
-        <action service="sendExamplePushNotifications" mode="sync"/>
-    </eca>
 </service-eca>
diff --git a/example/servicedef/services.xml b/example/servicedef/services.xml
index bd0d25c77..e22bc2299 100644
--- a/example/servicedef/services.xml
+++ b/example/servicedef/services.xml
@@ -137,15 +137,6 @@ under the License.
         <implements service="permissionInterface"/>
     </service>
 
-
-    <!-- Send push notification service -->
-    <service name="sendExamplePushNotifications" engine="java"
-                location="org.apache.ofbiz.example.ExampleServices" 
invoke="sendExamplePushNotifications" auth="true">
-        <attribute name="exampleId" mode="IN" type="String" 
optional="true"></attribute>
-        <attribute name="message" mode="IN" type="String" 
optional="true"></attribute>
-        <attribute name="successMessage" mode="IN" type="String" 
optional="true"></attribute>
-    </service>
-
     <!-- ExampleType services -->
     <service name="createExampleType" default-entity-name="ExampleType" 
engine="entity-auto" invoke="create" auth="true">
         <description>Create a record of ExampleType</description>
diff --git 
a/example/src/main/java/org/apache/ofbiz/example/ExampleServices.java 
b/example/src/main/java/org/apache/ofbiz/example/ExampleServices.java
deleted file mode 100644
index d54f7f858..000000000
--- a/example/src/main/java/org/apache/ofbiz/example/ExampleServices.java
+++ /dev/null
@@ -1,49 +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.ofbiz.example;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Set;
-
-import javax.websocket.Session;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.service.DispatchContext;
-import org.apache.ofbiz.service.ServiceUtil;
-
-public class ExampleServices {
-    private static final String MODULE = ExampleServices.class.getName();
-
-    public static Map<String, Object> 
sendExamplePushNotifications(DispatchContext dctx, Map<String, ? extends 
Object> context) {
-        String exampleId = (String) context.get("exampleId");
-        String message = (String) context.get("message");
-        Set<Session> clients = 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();
-    }
-}
diff --git 
a/example/src/main/java/org/apache/ofbiz/example/ExampleWebSockets.java 
b/example/src/main/java/org/apache/ofbiz/example/ExampleWebSockets.java
deleted file mode 100644
index 61b36b637..000000000
--- a/example/src/main/java/org/apache/ofbiz/example/ExampleWebSockets.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.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.apache.ofbiz.base.util.Debug;
-
-@ServerEndpoint("/ws/pushNotifications")
-public class ExampleWebSockets {
-
-    private static final String MODULE = ExampleWebSockets.class.getName();
-    private static Set<Session> clients = Collections.synchronizedSet(new 
HashSet<Session>());
-
-
-    /**
-     * On message.
-     * @param session the session
-     * @param msg the msg
-     * @param last the last
-     */
-    @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);
-            }
-        }
-    }
-
-    /**
-     * On open.
-     * @param session the session
-     */
-    @OnOpen
-    public void onOpen(Session session) {
-        // Add session to the connected sessions clients set
-        clients.add(session);
-    }
-
-    /**
-     * On close.
-     * @param session the session
-     */
-    @OnClose
-    public void onClose(Session session) {
-        // Remove session from the connected sessions clients set
-        clients.remove(session);
-    }
-
-    public static Set<Session> getClients() {
-        return clients;
-    }
-}
-
diff --git a/example/webapp/example/js/ExamplePushNotifications.js 
b/example/webapp/example/js/ExamplePushNotifications.js
deleted file mode 100644
index 5859a8c5f..000000000
--- a/example/webapp/example/js/ExamplePushNotifications.js
+++ /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.
- */
-
-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('<div/>')
-        .addClass('pushNotification')
-        .css({'position': 'fixed', 'top': '5%', 'right': '2%', 'background': 
'lightgrey', 'border-radius': '10px', 'z-index': '9999'}));
-
-    jQuery('.pushNotification')
-        .append(jQuery('<a href="javascript:void(0);" 
class="closeNotification"/>')
-        .css({'color': 'black', 'font-size': '15px', 'position': 'fixed', 
'right': '2%'}).append('close'));
-
-    jQuery('.pushNotification')
-        .append(jQuery('<p/>')
-        .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 97d6f2263..40f7e4d7d 100644
--- a/example/widget/example/CommonScreens.xml
+++ b/example/widget/example/CommonScreens.xml
@@ -46,14 +46,6 @@ under the License.
                 <set field="helpAnchor" from-field="helpAnchor" 
default-value="_example"/>
             </actions>
             <widgets>
-                <section>
-                    <condition>
-                        <if-has-permission permission="EXAMPLE" 
action="_VIEW"/>
-                    </condition>
-                    <actions>
-                        <set field="layoutSettings.javaScripts[]" 
value="/example/js/ExamplePushNotifications.js" global="true"/>
-                    </actions>
-                </section>
                 <include-screen name="ApplicationDecorator" 
location="component://commonext/widget/CommonScreens.xml"/>
             </widgets>
         </section>

Reply via email to