From 12c41ea2ae231492b7e6864584968639fcfe65a3 Mon Sep 17 00:00:00 2001 From: "William E. Seyler" Date: Wed, 7 Feb 2024 11:55:05 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"[BACKLOG-39783]=20-=20Implemented=20a?= =?UTF-8?q?=20PentahoSystemPublisher=20that=20allows=20ar=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/core/system/PentahoSystem.java | 2 +- .../core/system/PentahoSystemPublisher.java | 66 ------------------- .../system/PentahoSystemPublisherTest.java | 23 ------- 3 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisher.java delete mode 100644 core/src/test/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisherTest.java diff --git a/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystem.java b/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystem.java index 49a4cb7acd1..66fb8d9882a 100644 --- a/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystem.java +++ b/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystem.java @@ -400,7 +400,7 @@ public static boolean init( final IApplicationContext pApplicationContext, final if ( debug ) { Logger.debug( PentahoSystem.class, "PentahoSystem Init Complete" ); //$NON-NLS-1$ } - PentahoSystemPublisher.getInstance().publish( PentahoSystemPublisher.START_UP_TOPIC, true ); + return true; } diff --git a/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisher.java b/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisher.java deleted file mode 100644 index f3a4671f9e5..00000000000 --- a/core/src/main/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisher.java +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * - * This program is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software - * Foundation. - * - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html - * or from the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * - * Copyright (c) 2002-2024 Hitachi Vantara. All rights reserved. - * - */ - -package org.pentaho.platform.engine.core.system; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; - -public class PentahoSystemPublisher { - public static final String START_UP_TOPIC = "system_startup"; - public static final String SHUT_DOWN_TOPIC = "system_shutdown"; - private final Map>> topicsSubscribers = new HashMap<>(); - private static PentahoSystemPublisher instance = null; - - public static PentahoSystemPublisher getInstance() { - if ( instance == null ) { - instance = new PentahoSystemPublisher(); - } - return instance; - } - - public int topicCount() { - return topicsSubscribers.size(); - } - - public void publish( String topic, T value ) { - ArrayList> subscribers = topicsSubscribers.get( topic ); - if ( subscribers == null ) { - return; - } - - for ( Consumer subscriberConsumer : subscribers ) { - subscriberConsumer.accept( value ); - } - } - - public synchronized void subscribe( String topicName, Consumer subscriberCallback ) { - ArrayList> subscribers = topicsSubscribers.get( topicName ); - if ( subscribers == null ) { - subscribers = new ArrayList<>(); - subscribers.add( subscriberCallback ); - topicsSubscribers.put( topicName, subscribers ); - } else { - subscribers.add( subscriberCallback ); - } - } -} diff --git a/core/src/test/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisherTest.java b/core/src/test/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisherTest.java deleted file mode 100644 index 871cb5661c8..00000000000 --- a/core/src/test/java/org/pentaho/platform/engine/core/system/PentahoSystemPublisherTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.pentaho.platform.engine.core.system; - -import org.junit.Assert; -import org.junit.Test; - -public class PentahoSystemPublisherTest { - @Test - public void subscribeTest() { - PentahoSystemPublisher.getInstance().subscribe( PentahoSystemPublisher.START_UP_TOPIC, this::startupSubscriber ); - PentahoSystemPublisher.getInstance().subscribe( PentahoSystemPublisher.SHUT_DOWN_TOPIC, this::shutdownSubscriber ); - Assert.assertEquals( 2, PentahoSystemPublisher.getInstance().topicCount() ); - PentahoSystemPublisher.getInstance().publish( PentahoSystemPublisher.START_UP_TOPIC, true ); - PentahoSystemPublisher.getInstance().publish( PentahoSystemPublisher.SHUT_DOWN_TOPIC, true ); - } - - private void shutdownSubscriber( boolean isStopping ) { - Assert.assertTrue( isStopping ); - } - - public void startupSubscriber( boolean isStarting ) { - Assert.assertTrue( isStarting ); - } -}