You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2024/08/25 13:00:38 UTC

(shardingsphere) branch master updated: Remove DeliverEventSubscriberRegistry (#32673)

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

totalo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 1be850866e2 Remove DeliverEventSubscriberRegistry (#32673)
1be850866e2 is described below

commit 1be850866e2cd0f1227de869cab5fa7c28e3a188
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Aug 25 21:00:32 2024 +0800

    Remove DeliverEventSubscriberRegistry (#32673)
---
 .../subsciber/DeliverEventSubscriberRegistry.java  | 47 ----------------------
 .../ClusterDeliverEventSubscriberRegistry.java     | 23 +++++++++--
 2 files changed, 20 insertions(+), 50 deletions(-)

diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/subsciber/DeliverEventSubscriberRegistry.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/subsciber/DeliverEventSubscriberRegistry.java
deleted file mode 100644
index 36a50b0b3fa..00000000000
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/subsciber/DeliverEventSubscriberRegistry.java
+++ /dev/null
@@ -1,47 +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.shardingsphere.mode.event.subsciber;
-
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
-import org.apache.shardingsphere.infra.util.eventbus.EventSubscriber;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- * Deliver event subscriber registry.
- */
-public abstract class DeliverEventSubscriberRegistry implements EventSubscriberRegistry {
-    
-    private final EventBusContext eventBusContext;
-    
-    private final Collection<EventSubscriber> subscribers;
-    
-    protected DeliverEventSubscriberRegistry(final ContextManager contextManager, final EventSubscriber... subscribers) {
-        eventBusContext = contextManager.getComputeNodeInstanceContext().getEventBusContext();
-        this.subscribers = Arrays.asList(subscribers);
-    }
-    
-    /**
-     * Register subscribers.
-     */
-    public void register() {
-        subscribers.forEach(eventBusContext::register);
-    }
-}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/registry/ClusterDeliverEventSubscriberRegistry.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/registry/ClusterDeliverEventSubscriberRegistry.java
index 8ef25246e0e..67c29c40e8f 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/registry/ClusterDeliverEventSubscriberRegistry.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/registry/ClusterDeliverEventSubscriberRegistry.java
@@ -17,17 +17,34 @@
 
 package org.apache.shardingsphere.mode.manager.cluster.event.subscriber.registry;
 
+import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
+import org.apache.shardingsphere.infra.util.eventbus.EventSubscriber;
+import org.apache.shardingsphere.mode.event.subsciber.EventSubscriberRegistry;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.manager.cluster.event.subscriber.deliver.DeliverQualifiedDataSourceSubscriber;
 import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
-import org.apache.shardingsphere.mode.event.subsciber.DeliverEventSubscriberRegistry;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Cluster deliver event subscriber registry.
  */
-public final class ClusterDeliverEventSubscriberRegistry extends DeliverEventSubscriberRegistry {
+public final class ClusterDeliverEventSubscriberRegistry implements EventSubscriberRegistry {
+    
+    private final EventBusContext eventBusContext;
+    
+    private final Collection<EventSubscriber> subscribers;
     
     public ClusterDeliverEventSubscriberRegistry(final ContextManager contextManager) {
-        super(contextManager, new DeliverQualifiedDataSourceSubscriber((ClusterPersistRepository) contextManager.getPersistServiceFacade().getRepository()));
+        eventBusContext = contextManager.getComputeNodeInstanceContext().getEventBusContext();
+        subscribers = Collections.singleton(new DeliverQualifiedDataSourceSubscriber((ClusterPersistRepository) contextManager.getPersistServiceFacade().getRepository()));
+    }
+    
+    /**
+     * Register subscribers.
+     */
+    public void register() {
+        subscribers.forEach(eventBusContext::register);
     }
 }