This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 108ac979ee5 Refactor NamedRuleItemChangedEventCreator and
UniqueRuleItemChangedEventCreator (#26795)
108ac979ee5 is described below
commit 108ac979ee513c81d7647f38152a6396fa013cae
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jul 6 19:12:47 2023 +0800
Refactor NamedRuleItemChangedEventCreator and
UniqueRuleItemChangedEventCreator (#26795)
* Refactor RuleItemChangedSubscriber
* Refactor NamedRuleItemChangedEventCreator and
UniqueRuleItemChangedEventCreator
---
.../event/BroadcastRuleChangedEventCreator.java | 8 ++--
.../event/table/BroadcastTableEventCreator.java | 40 ----------------
.../CompatibleEncryptRuleChangedEventCreator.java | 12 ++---
.../event/EncryptRuleChangedEventCreator.java | 12 ++---
.../encryptor/CompatibleEncryptorEventCreator.java | 42 -----------------
.../table/CompatibleEncryptTableEventCreator.java | 42 -----------------
.../event/encryptor/EncryptorEventCreator.java | 40 ----------------
.../event/table/EncryptTableEventCreator.java | 40 ----------------
.../mask/event/MaskRuleChangedEventCreator.java | 12 ++---
.../mask/event/algorithm/MaskEventCreator.java | 40 ----------------
.../mask/event/table/MaskTableCreator.java | 40 ----------------
.../ReadwriteSplittingRuleChangedEventCreator.java | 12 ++---
.../ReadwriteSplittingDataSourceEventCreator.java | 40 ----------------
...ReadwriteSplittingLoadBalancerEventCreator.java | 40 ----------------
.../event/ShadowRuleChangedEventCreator.java | 26 +++++-----
.../DefaultShadowAlgorithmEventCreator.java | 40 ----------------
.../algorithm/ShadowAlgorithmEventCreator.java | 40 ----------------
.../datasource/ShadowDataSourceEventCreator.java | 40 ----------------
.../event/table/ShadowTableEventCreator.java | 40 ----------------
.../event/ShardingRuleChangedEventCreator.java | 55 +++++++++++-----------
.../auditor/AuditShardingEventCreator.java | 40 ----------------
.../keygenerator/KeyGeneratorEventCreator.java | 40 ----------------
.../sharding/ShardingAlgorithmEventCreator.java | 40 ----------------
.../event/cache/ShardingCacheEventCreator.java | 40 ----------------
...DefaultShardingAuditorStrategyEventCreator.java | 40 ----------------
...efaultDatabaseShardingStrategyEventCreator.java | 40 ----------------
.../DefaultKeyGenerateStrategyEventCreator.java | 40 ----------------
.../DefaultShardingColumnEventCreator.java | 40 ----------------
.../DefaultTableShardingStrategyEventCreator.java | 40 ----------------
.../table/auto/ShardingAutoTableEventCreator.java | 40 ----------------
.../ShardingTableReferenceEventCreator.java | 40 ----------------
.../table/sharding/ShardingTableEventCreator.java | 40 ----------------
.../event/SingleRuleChangedEventCreator.java | 8 ++--
.../event/config/SingleTableEventCreator.java | 40 ----------------
.../event/NamedRuleItemChangedEventCreator.java | 12 ++++-
.../event/UniqueRuleItemChangedEventCreator.java | 12 ++++-
.../mode/subsciber/RuleItemChangedSubscriber.java | 4 +-
37 files changed, 94 insertions(+), 1123 deletions(-)
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleChangedEventCreator.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleChangedEventCreator.java
index aa97fce5fd1..01c6ff67bce 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleChangedEventCreator.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleChangedEventCreator.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.broadcast.event;
-import
org.apache.shardingsphere.broadcast.event.table.BroadcastTableEventCreator;
import
org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodePathProvider;
+import
org.apache.shardingsphere.broadcast.subscriber.BroadcastTableChangedGenerator;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
@@ -31,12 +31,12 @@ public final class BroadcastRuleChangedEventCreator
implements RuleChangedEventC
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType) {
- return
getUniqueRuleItemChangedEventCreator(itemType).create(databaseName, event);
+ return new UniqueRuleItemChangedEventCreator().create(databaseName,
event, getRuleItemConfigurationChangedGeneratorType(itemType));
}
- private UniqueRuleItemChangedEventCreator
getUniqueRuleItemChangedEventCreator(final String itemType) {
+ private String getRuleItemConfigurationChangedGeneratorType(final String
itemType) {
if (itemType.equals(BroadcastRuleNodePathProvider.TABLES)) {
- return new BroadcastTableEventCreator();
+ return BroadcastTableChangedGenerator.TYPE;
}
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/table/BroadcastTableEventCreator.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/table/BroadcastTableEventCreator.java
deleted file mode 100644
index 3ea8020a8e4..00000000000
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/table/BroadcastTableEventCreator.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.shardingsphere.broadcast.event.table;
-
-import
org.apache.shardingsphere.broadcast.subscriber.BroadcastTableChangedGenerator;
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-
-/**
- * Broadcast table event creator.
- */
-public final class BroadcastTableEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), BroadcastTableChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
BroadcastTableChangedGenerator.TYPE);
- }
-}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleChangedEventCreator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleChangedEventCreator.java
index 8ad9239fc2f..1d71e758692 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleChangedEventCreator.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleChangedEventCreator.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.encrypt.event;
-import
org.apache.shardingsphere.encrypt.event.compatible.encryptor.CompatibleEncryptorEventCreator;
-import
org.apache.shardingsphere.encrypt.event.compatible.table.CompatibleEncryptTableEventCreator;
import
org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodePathProvider;
+import
org.apache.shardingsphere.encrypt.subscriber.compatible.CompatibleEncryptTableChangedGenerator;
+import
org.apache.shardingsphere.encrypt.subscriber.compatible.CompatibleEncryptorChangedGenerator;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
@@ -34,15 +34,15 @@ public final class CompatibleEncryptRuleChangedEventCreator
implements RuleChang
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType, final String itemName) {
- return
getNamedRuleItemChangedEventCreator(itemType).create(databaseName, itemName,
event);
+ return new NamedRuleItemChangedEventCreator().create(databaseName,
itemName, event, getRuleItemConfigurationChangedGeneratorType(itemType));
}
- private NamedRuleItemChangedEventCreator
getNamedRuleItemChangedEventCreator(final String itemType) {
+ private String getRuleItemConfigurationChangedGeneratorType(final String
itemType) {
switch (itemType) {
case EncryptRuleNodePathProvider.TABLES:
- return new CompatibleEncryptTableEventCreator();
+ return CompatibleEncryptTableChangedGenerator.TYPE;
case EncryptRuleNodePathProvider.ENCRYPTORS:
- return new CompatibleEncryptorEventCreator();
+ return CompatibleEncryptorChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleChangedEventCreator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleChangedEventCreator.java
index d1d19759517..4d1f9667197 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleChangedEventCreator.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleChangedEventCreator.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.encrypt.event;
-import org.apache.shardingsphere.encrypt.event.encryptor.EncryptorEventCreator;
-import org.apache.shardingsphere.encrypt.event.table.EncryptTableEventCreator;
import
org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodePathProvider;
+import
org.apache.shardingsphere.encrypt.subscriber.EncryptTableChangedGenerator;
+import org.apache.shardingsphere.encrypt.subscriber.EncryptorChangedGenerator;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
@@ -32,15 +32,15 @@ public final class EncryptRuleChangedEventCreator
implements RuleChangedEventCre
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType, final String itemName) {
- return
getNamedRuleItemChangedEventCreator(itemType).create(databaseName, itemName,
event);
+ return new NamedRuleItemChangedEventCreator().create(databaseName,
itemName, event, getRuleItemConfigurationChangedGeneratorType(itemType));
}
- private NamedRuleItemChangedEventCreator
getNamedRuleItemChangedEventCreator(final String itemType) {
+ private String getRuleItemConfigurationChangedGeneratorType(final String
itemType) {
switch (itemType) {
case EncryptRuleNodePathProvider.TABLES:
- return new EncryptTableEventCreator();
+ return EncryptTableChangedGenerator.TYPE;
case EncryptRuleNodePathProvider.ENCRYPTORS:
- return new EncryptorEventCreator();
+ return EncryptorChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/compatible/encryptor/CompatibleEncryptorEventCreator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/compatible/encryptor/CompatibleEncryptorEventCreator.java
deleted file mode 100644
index 6f4a46280aa..00000000000
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/compatible/encryptor/CompatibleEncryptorEventCreator.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.shardingsphere.encrypt.event.compatible.encryptor;
-
-import
org.apache.shardingsphere.encrypt.subscriber.compatible.CompatibleEncryptorChangedGenerator;
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-
-/**
- * Compatible encryptor event creator.
- * @deprecated compatible support will remove in next version.
- */
-@Deprecated
-public final class CompatibleEncryptorEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
encryptorName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, encryptorName,
event.getKey(), event.getValue(), CompatibleEncryptorChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, encryptorName,
CompatibleEncryptorChangedGenerator.TYPE);
- }
-}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/compatible/table/CompatibleEncryptTableEventCreator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/compatible/table/CompatibleEncryptTableEventCreator.java
deleted file mode 100644
index 01a59c8078c..00000000000
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/compatible/table/CompatibleEncryptTableEventCreator.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.shardingsphere.encrypt.event.compatible.table;
-
-import
org.apache.shardingsphere.encrypt.subscriber.compatible.CompatibleEncryptTableChangedGenerator;
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-
-/**
- * Compatible encrypt table event creator.
- * @deprecated compatible support will remove in next version.
- */
-@Deprecated
-public final class CompatibleEncryptTableEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
groupName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, groupName,
event.getKey(), event.getValue(), CompatibleEncryptTableChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, groupName,
CompatibleEncryptTableChangedGenerator.TYPE);
- }
-}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/encryptor/EncryptorEventCreator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/encryptor/EncryptorEventCreator.java
deleted file mode 100644
index 684c5bc3759..00000000000
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/encryptor/EncryptorEventCreator.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.shardingsphere.encrypt.event.encryptor;
-
-import org.apache.shardingsphere.encrypt.subscriber.EncryptorChangedGenerator;
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-
-/**
- * Encryptor event creator.
- */
-public final class EncryptorEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
encryptorName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, encryptorName,
event.getKey(), event.getValue(), EncryptorChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, encryptorName,
EncryptorChangedGenerator.TYPE);
- }
-}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/table/EncryptTableEventCreator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/table/EncryptTableEventCreator.java
deleted file mode 100644
index 004965a52d5..00000000000
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/table/EncryptTableEventCreator.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.shardingsphere.encrypt.event.table;
-
-import
org.apache.shardingsphere.encrypt.subscriber.EncryptTableChangedGenerator;
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-
-/**
- * Encrypt table event creator.
- */
-public final class EncryptTableEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
groupName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, groupName,
event.getKey(), event.getValue(), EncryptTableChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, groupName,
EncryptTableChangedGenerator.TYPE);
- }
-}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleChangedEventCreator.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleChangedEventCreator.java
index 3fae974ebc7..89cbf382fcb 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleChangedEventCreator.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleChangedEventCreator.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.mask.event;
import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.mask.event.algorithm.MaskEventCreator;
-import org.apache.shardingsphere.mask.event.table.MaskTableCreator;
import
org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodePathProvider;
+import org.apache.shardingsphere.mask.subscriber.MaskAlgorithmChangedGenerator;
+import org.apache.shardingsphere.mask.subscriber.MaskTableChangedGenerator;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.spi.RuleChangedEventCreator;
@@ -32,15 +32,15 @@ public final class MaskRuleChangedEventCreator implements
RuleChangedEventCreato
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType, final String itemName) {
- return
getNamedRuleItemChangedEventCreator(itemType).create(databaseName, itemName,
event);
+ return new NamedRuleItemChangedEventCreator().create(databaseName,
itemName, event, getRuleItemConfigurationChangedGeneratorType(itemType));
}
- private NamedRuleItemChangedEventCreator
getNamedRuleItemChangedEventCreator(final String itemType) {
+ private String getRuleItemConfigurationChangedGeneratorType(final String
itemType) {
switch (itemType) {
case MaskRuleNodePathProvider.TABLES:
- return new MaskTableCreator();
+ return MaskTableChangedGenerator.TYPE;
case MaskRuleNodePathProvider.ALGORITHMS:
- return new MaskEventCreator();
+ return MaskAlgorithmChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/algorithm/MaskEventCreator.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/algorithm/MaskEventCreator.java
deleted file mode 100644
index e7e74ea3aba..00000000000
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/algorithm/MaskEventCreator.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.shardingsphere.mask.event.algorithm;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mask.subscriber.MaskAlgorithmChangedGenerator;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-
-/**
- * Mask event creator.
- */
-public final class MaskEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
algorithmName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, algorithmName,
event.getKey(), event.getValue(), MaskAlgorithmChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, algorithmName,
MaskAlgorithmChangedGenerator.TYPE);
- }
-}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/table/MaskTableCreator.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/table/MaskTableCreator.java
deleted file mode 100644
index b31d48d4e00..00000000000
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/table/MaskTableCreator.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.shardingsphere.mask.event.table;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mask.subscriber.MaskTableChangedGenerator;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-
-/**
- * Mask table creator.
- */
-public final class MaskTableCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
tableName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, tableName,
event.getKey(), event.getValue(), MaskTableChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, tableName,
MaskTableChangedGenerator.TYPE);
- }
-}
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleChangedEventCreator.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleChangedEventCreator.java
index 0f4651a43a7..575b545aa48 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleChangedEventCreator.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleChangedEventCreator.java
@@ -21,9 +21,9 @@ import
org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.spi.RuleChangedEventCreator;
-import
org.apache.shardingsphere.readwritesplitting.event.datasource.ReadwriteSplittingDataSourceEventCreator;
-import
org.apache.shardingsphere.readwritesplitting.event.loadbalance.ReadwriteSplittingLoadBalancerEventCreator;
import
org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodePathProvider;
+import
org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingDataSourceChangedGenerator;
+import
org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingLoadBalancerChangedGenerator;
/**
* Readwrite-splitting rule changed event creator.
@@ -32,15 +32,15 @@ public final class
ReadwriteSplittingRuleChangedEventCreator implements RuleChan
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType, final String itemName) {
- return
getNamedRuleItemChangedEventCreator(itemType).create(databaseName, itemName,
event);
+ return new NamedRuleItemChangedEventCreator().create(databaseName,
itemName, event, getRuleItemConfigurationChangedGeneratorType(itemType));
}
- private NamedRuleItemChangedEventCreator
getNamedRuleItemChangedEventCreator(final String itemType) {
+ private String getRuleItemConfigurationChangedGeneratorType(final String
itemType) {
switch (itemType) {
case ReadwriteSplittingRuleNodePathProvider.DATA_SOURCES:
- return new ReadwriteSplittingDataSourceEventCreator();
+ return ReadwriteSplittingDataSourceChangedGenerator.TYPE;
case ReadwriteSplittingRuleNodePathProvider.LOAD_BALANCERS:
- return new ReadwriteSplittingLoadBalancerEventCreator();
+ return ReadwriteSplittingLoadBalancerChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/datasource/ReadwriteSplittingDataSourceEventCreator.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/datasource/ReadwriteSplittingDataSourceEventCreator.java
deleted file mode 100644
index 5d23d8f4b97..00000000000
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/datasource/ReadwriteSplittingDataSourceEventCreator.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.shardingsphere.readwritesplitting.event.datasource;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingDataSourceChangedGenerator;
-
-/**
- * Readwrite-splitting data source event creator.
- */
-public final class ReadwriteSplittingDataSourceEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
groupName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, groupName,
event.getKey(), event.getValue(),
ReadwriteSplittingDataSourceChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, groupName,
ReadwriteSplittingDataSourceChangedGenerator.TYPE);
- }
-}
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/loadbalance/ReadwriteSplittingLoadBalancerEventCreator.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/loadbalance/ReadwriteSplittingLoadBalancerEventCreator.java
deleted file mode 100644
index 948e13bf2eb..00000000000
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/loadbalance/ReadwriteSplittingLoadBalancerEventCreator.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.shardingsphere.readwritesplitting.event.loadbalance;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingLoadBalancerChangedGenerator;
-
-/**
- * Readwrite-splitting load-balancer event creator.
- */
-public final class ReadwriteSplittingLoadBalancerEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
loadBalancerName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, loadBalancerName,
event.getKey(), event.getValue(),
ReadwriteSplittingLoadBalancerChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, loadBalancerName,
ReadwriteSplittingLoadBalancerChangedGenerator.TYPE);
- }
-}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleChangedEventCreator.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleChangedEventCreator.java
index 0bc8c1a60f2..5e25bf97434 100644
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleChangedEventCreator.java
+++
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleChangedEventCreator.java
@@ -22,11 +22,11 @@ import
org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.spi.RuleChangedEventCreator;
-import
org.apache.shardingsphere.shadow.event.algorithm.DefaultShadowAlgorithmEventCreator;
-import
org.apache.shardingsphere.shadow.event.algorithm.ShadowAlgorithmEventCreator;
-import
org.apache.shardingsphere.shadow.event.datasource.ShadowDataSourceEventCreator;
-import org.apache.shardingsphere.shadow.event.table.ShadowTableEventCreator;
import
org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodePathProvider;
+import
org.apache.shardingsphere.shadow.subscriber.DefaultShadowAlgorithmNameChangedGenerator;
+import
org.apache.shardingsphere.shadow.subscriber.ShadowAlgorithmChangedGenerator;
+import
org.apache.shardingsphere.shadow.subscriber.ShadowDataSourceChangedGenerator;
+import org.apache.shardingsphere.shadow.subscriber.ShadowTableChangedGenerator;
/**
* Shadow rule changed event creator.
@@ -35,30 +35,30 @@ public final class ShadowRuleChangedEventCreator implements
RuleChangedEventCrea
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType, final String itemName) {
- return
getNamedRuleItemChangedEventCreator(itemType).create(databaseName, itemName,
event);
+ return new NamedRuleItemChangedEventCreator().create(databaseName,
itemName, event, getNamedRuleItemConfigurationChangedGeneratorType(itemType));
}
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType) {
- return
getUniqueRuleItemChangedEventCreator(itemType).create(databaseName, event);
+ return new UniqueRuleItemChangedEventCreator().create(databaseName,
event, getUniqueRuleItemConfigurationChangedGeneratorType(itemType));
}
- private NamedRuleItemChangedEventCreator
getNamedRuleItemChangedEventCreator(final String itemType) {
+ private String getNamedRuleItemConfigurationChangedGeneratorType(final
String itemType) {
switch (itemType) {
case ShadowRuleNodePathProvider.DATA_SOURCES:
- return new ShadowDataSourceEventCreator();
+ return ShadowDataSourceChangedGenerator.TYPE;
case ShadowRuleNodePathProvider.TABLES:
- return new ShadowTableEventCreator();
+ return ShadowTableChangedGenerator.TYPE;
case ShadowRuleNodePathProvider.ALGORITHMS:
- return new ShadowAlgorithmEventCreator();
+ return ShadowAlgorithmChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
}
- private UniqueRuleItemChangedEventCreator
getUniqueRuleItemChangedEventCreator(final String itemType) {
- if (itemType.equals(ShadowRuleNodePathProvider.DATA_SOURCES)) {
- return new DefaultShadowAlgorithmEventCreator();
+ private String getUniqueRuleItemConfigurationChangedGeneratorType(final
String itemType) {
+ if (itemType.equals(ShadowRuleNodePathProvider.DEFAULT_ALGORITHM)) {
+ return DefaultShadowAlgorithmNameChangedGenerator.TYPE;
}
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/DefaultShadowAlgorithmEventCreator.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/DefaultShadowAlgorithmEventCreator.java
deleted file mode 100644
index fb0d33f075e..00000000000
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/DefaultShadowAlgorithmEventCreator.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.shardingsphere.shadow.event.algorithm;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.shadow.subscriber.DefaultShadowAlgorithmNameChangedGenerator;
-
-/**
- * Default shadow algorithm event creator.
- */
-public final class DefaultShadowAlgorithmEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), DefaultShadowAlgorithmNameChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
DefaultShadowAlgorithmNameChangedGenerator.TYPE);
- }
-}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/ShadowAlgorithmEventCreator.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/ShadowAlgorithmEventCreator.java
deleted file mode 100644
index 096af5b7399..00000000000
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/algorithm/ShadowAlgorithmEventCreator.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.shardingsphere.shadow.event.algorithm;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.shadow.subscriber.ShadowAlgorithmChangedGenerator;
-
-/**
- * Shadow algorithm event creator.
- */
-public final class ShadowAlgorithmEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
algorithmName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, algorithmName,
event.getKey(), event.getValue(), ShadowAlgorithmChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, algorithmName,
ShadowAlgorithmChangedGenerator.TYPE);
- }
-}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/datasource/ShadowDataSourceEventCreator.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/datasource/ShadowDataSourceEventCreator.java
deleted file mode 100644
index 965b18fff99..00000000000
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/datasource/ShadowDataSourceEventCreator.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.shardingsphere.shadow.event.datasource;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.shadow.subscriber.ShadowDataSourceChangedGenerator;
-
-/**
- * Shadow data source event creator.
- */
-public final class ShadowDataSourceEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
dataSourceName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, dataSourceName,
event.getKey(), event.getValue(), ShadowDataSourceChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, dataSourceName,
ShadowDataSourceChangedGenerator.TYPE);
- }
-}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/ShadowTableEventCreator.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/ShadowTableEventCreator.java
deleted file mode 100644
index c36fb148061..00000000000
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/table/ShadowTableEventCreator.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.shardingsphere.shadow.event.table;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import org.apache.shardingsphere.shadow.subscriber.ShadowTableChangedGenerator;
-
-/**
- * Shadow table event creator.
- */
-public final class ShadowTableEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
tableName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, tableName,
event.getKey(), event.getValue(), ShadowTableChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, tableName,
ShadowTableChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleChangedEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleChangedEventCreator.java
index 25719e78beb..24378a2d301 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleChangedEventCreator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleChangedEventCreator.java
@@ -22,19 +22,18 @@ import
org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.spi.RuleChangedEventCreator;
-import
org.apache.shardingsphere.sharding.event.algorithm.auditor.AuditShardingEventCreator;
-import
org.apache.shardingsphere.sharding.event.algorithm.keygenerator.KeyGeneratorEventCreator;
-import
org.apache.shardingsphere.sharding.event.algorithm.sharding.ShardingAlgorithmEventCreator;
-import
org.apache.shardingsphere.sharding.event.cache.ShardingCacheEventCreator;
-import
org.apache.shardingsphere.sharding.event.strategy.audit.DefaultShardingAuditorStrategyEventCreator;
-import
org.apache.shardingsphere.sharding.event.strategy.database.DefaultDatabaseShardingStrategyEventCreator;
-import
org.apache.shardingsphere.sharding.event.strategy.keygenerate.DefaultKeyGenerateStrategyEventCreator;
-import
org.apache.shardingsphere.sharding.event.strategy.shardingcolumn.DefaultShardingColumnEventCreator;
-import
org.apache.shardingsphere.sharding.event.strategy.table.DefaultTableShardingStrategyEventCreator;
-import
org.apache.shardingsphere.sharding.event.table.auto.ShardingAutoTableEventCreator;
-import
org.apache.shardingsphere.sharding.event.table.binding.ShardingTableReferenceEventCreator;
-import
org.apache.shardingsphere.sharding.event.table.sharding.ShardingTableEventCreator;
import
org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodePathProvider;
+import
org.apache.shardingsphere.sharding.subscriber.DefaultDatabaseShardingStrategyChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.DefaultKeyGenerateStrategyChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.DefaultShardingAuditorStrategyChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.DefaultShardingColumnChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.DefaultTableShardingStrategyChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.ShardingAlgorithmChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.ShardingAuditorChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.ShardingAutoTableChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.ShardingCacheChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.ShardingTableChangedGenerator;
+import
org.apache.shardingsphere.sharding.subscriber.ShardingTableReferenceChangedGenerator;
/**
* Sharding rule changed event creator.
@@ -43,47 +42,47 @@ public final class ShardingRuleChangedEventCreator
implements RuleChangedEventCr
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType, final String itemName) {
- return
getNamedRuleItemChangedEventCreator(itemType).create(databaseName, itemName,
event);
+ return new NamedRuleItemChangedEventCreator().create(databaseName,
itemName, event, getNamedRuleItemConfigurationChangedGeneratorType(itemType));
}
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType) {
- return
getUniqueRuleItemChangedEventCreator(itemType).create(databaseName, event);
+ return new UniqueRuleItemChangedEventCreator().create(databaseName,
event, getUniqueRuleItemConfigurationChangedGeneratorType(itemType));
}
- private NamedRuleItemChangedEventCreator
getNamedRuleItemChangedEventCreator(final String itemType) {
+ private String getNamedRuleItemConfigurationChangedGeneratorType(final
String itemType) {
switch (itemType) {
case ShardingRuleNodePathProvider.TABLES:
- return new ShardingTableEventCreator();
+ return ShardingTableChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.AUTO_TABLES:
- return new ShardingAutoTableEventCreator();
+ return ShardingAutoTableChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.BINDING_TABLES:
- return new ShardingTableReferenceEventCreator();
+ return ShardingTableReferenceChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.ALGORITHMS:
- return new ShardingAlgorithmEventCreator();
+ return ShardingAlgorithmChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.KEY_GENERATORS:
- return new KeyGeneratorEventCreator();
+ return DefaultKeyGenerateStrategyChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.AUDITORS:
- return new AuditShardingEventCreator();
+ return ShardingAuditorChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
}
- private UniqueRuleItemChangedEventCreator
getUniqueRuleItemChangedEventCreator(final String itemType) {
+ private String getUniqueRuleItemConfigurationChangedGeneratorType(final
String itemType) {
switch (itemType) {
case ShardingRuleNodePathProvider.DEFAULT_DATABASE_STRATEGY:
- return new DefaultDatabaseShardingStrategyEventCreator();
+ return DefaultDatabaseShardingStrategyChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.DEFAULT_TABLE_STRATEGY:
- return new DefaultTableShardingStrategyEventCreator();
+ return DefaultTableShardingStrategyChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.DEFAULT_KEY_GENERATE_STRATEGY:
- return new DefaultKeyGenerateStrategyEventCreator();
+ return DefaultKeyGenerateStrategyChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.DEFAULT_AUDIT_STRATEGY:
- return new DefaultShardingAuditorStrategyEventCreator();
+ return DefaultShardingAuditorStrategyChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.DEFAULT_SHARDING_COLUMN:
- return new DefaultShardingColumnEventCreator();
+ return DefaultShardingColumnChangedGenerator.TYPE;
case ShardingRuleNodePathProvider.SHARDING_CACHE:
- return new ShardingCacheEventCreator();
+ return ShardingCacheChangedGenerator.TYPE;
default:
throw new UnsupportedOperationException(itemType);
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AuditShardingEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AuditShardingEventCreator.java
deleted file mode 100644
index 2755483bc87..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/auditor/AuditShardingEventCreator.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.shardingsphere.sharding.event.algorithm.auditor;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.ShardingAuditorChangedGenerator;
-
-/**
- * Audit sharding event creator.
- */
-public final class AuditShardingEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
algorithmName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, algorithmName,
event.getKey(), event.getValue(), ShardingAuditorChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, algorithmName,
ShardingAuditorChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/KeyGeneratorEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/KeyGeneratorEventCreator.java
deleted file mode 100644
index b0bc23593f5..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/keygenerator/KeyGeneratorEventCreator.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.shardingsphere.sharding.event.algorithm.keygenerator;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.KeyGeneratorChangedGenerator;
-
-/**
- * Key generator event creator.
- */
-public final class KeyGeneratorEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
algorithmName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, algorithmName,
event.getKey(), event.getValue(), KeyGeneratorChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, algorithmName,
KeyGeneratorChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/ShardingAlgorithmEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/ShardingAlgorithmEventCreator.java
deleted file mode 100644
index a54287af159..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/algorithm/sharding/ShardingAlgorithmEventCreator.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.shardingsphere.sharding.event.algorithm.sharding;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.ShardingAlgorithmChangedGenerator;
-
-/**
- * Sharding algorithm event creator.
- */
-public final class ShardingAlgorithmEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
algorithmName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, algorithmName,
event.getKey(), event.getValue(), ShardingAlgorithmChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, algorithmName,
ShardingAlgorithmChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/ShardingCacheEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/ShardingCacheEventCreator.java
deleted file mode 100644
index 9fb617eb18e..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/cache/ShardingCacheEventCreator.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.shardingsphere.sharding.event.cache;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.ShardingCacheChangedGenerator;
-
-/**
- * Sharding cache event creator.
- */
-public final class ShardingCacheEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), ShardingCacheChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
ShardingCacheChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DefaultShardingAuditorStrategyEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DefaultShardingAuditorStrategyEventCreator.java
deleted file mode 100644
index 07c3bfa6003..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/audit/DefaultShardingAuditorStrategyEventCreator.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.shardingsphere.sharding.event.strategy.audit;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.DefaultShardingAuditorStrategyChangedGenerator;
-
-/**
- * Default sharding auditor strategy event creator.
- */
-public final class DefaultShardingAuditorStrategyEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), DefaultShardingAuditorStrategyChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
DefaultShardingAuditorStrategyChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DefaultDatabaseShardingStrategyEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DefaultDatabaseShardingStrategyEventCreator.java
deleted file mode 100644
index 02fda6efacb..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/database/DefaultDatabaseShardingStrategyEventCreator.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.shardingsphere.sharding.event.strategy.database;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.DefaultDatabaseShardingStrategyChangedGenerator;
-
-/**
- * Default database sharding strategy event creator.
- */
-public final class DefaultDatabaseShardingStrategyEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), DefaultDatabaseShardingStrategyChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
DefaultDatabaseShardingStrategyChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DefaultKeyGenerateStrategyEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DefaultKeyGenerateStrategyEventCreator.java
deleted file mode 100644
index 6bfb7293bba..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/keygenerate/DefaultKeyGenerateStrategyEventCreator.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.shardingsphere.sharding.event.strategy.keygenerate;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.DefaultKeyGenerateStrategyChangedGenerator;
-
-/**
- * Default key generate strategy event creator.
- */
-public final class DefaultKeyGenerateStrategyEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), DefaultKeyGenerateStrategyChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
DefaultKeyGenerateStrategyChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DefaultShardingColumnEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DefaultShardingColumnEventCreator.java
deleted file mode 100644
index dcdb4352102..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/shardingcolumn/DefaultShardingColumnEventCreator.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.shardingsphere.sharding.event.strategy.shardingcolumn;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.DefaultShardingColumnChangedGenerator;
-
-/**
- * Default sharding column event creator.
- */
-public final class DefaultShardingColumnEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), DefaultShardingColumnChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
DefaultShardingColumnChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DefaultTableShardingStrategyEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DefaultTableShardingStrategyEventCreator.java
deleted file mode 100644
index 8ef2b17266d..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/strategy/table/DefaultTableShardingStrategyEventCreator.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.shardingsphere.sharding.event.strategy.table;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.DefaultTableShardingStrategyChangedGenerator;
-
-/**
- * Default table sharding strategy event creator.
- */
-public final class DefaultTableShardingStrategyEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), DefaultTableShardingStrategyChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
DefaultTableShardingStrategyChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/ShardingAutoTableEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/ShardingAutoTableEventCreator.java
deleted file mode 100644
index a80f8b113bd..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/auto/ShardingAutoTableEventCreator.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.shardingsphere.sharding.event.table.auto;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.ShardingAutoTableChangedGenerator;
-
-/**
- * Sharding auto table event creator.
- */
-public final class ShardingAutoTableEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
tableName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, tableName,
event.getKey(), event.getValue(), ShardingAutoTableChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, tableName,
ShardingAutoTableChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/ShardingTableReferenceEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/ShardingTableReferenceEventCreator.java
deleted file mode 100644
index 6d3d9bf28f5..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/binding/ShardingTableReferenceEventCreator.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.shardingsphere.sharding.event.table.binding;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.ShardingTableReferenceChangedGenerator;
-
-/**
- * Sharding table reference creator.
- */
-public final class ShardingTableReferenceEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
tableName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, tableName,
event.getKey(), event.getValue(), ShardingTableReferenceChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, tableName,
ShardingTableReferenceChangedGenerator.TYPE);
- }
-}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/ShardingTableEventCreator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/ShardingTableEventCreator.java
deleted file mode 100644
index 6885cddaae8..00000000000
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/table/sharding/ShardingTableEventCreator.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.shardingsphere.sharding.event.table.sharding;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import
org.apache.shardingsphere.sharding.subscriber.ShardingTableChangedGenerator;
-
-/**
- * Sharding table event creator.
- */
-public final class ShardingTableEventCreator implements
NamedRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final String
tableName, final DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterNamedRuleItemEvent(databaseName, tableName,
event.getKey(), event.getValue(), ShardingTableChangedGenerator.TYPE);
- }
- return new DropNamedRuleItemEvent(databaseName, tableName,
ShardingTableChangedGenerator.TYPE);
- }
-}
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleChangedEventCreator.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleChangedEventCreator.java
index ebd8c620bf7..15c48ec1aee 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleChangedEventCreator.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleChangedEventCreator.java
@@ -21,8 +21,8 @@ import
org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
import org.apache.shardingsphere.mode.spi.RuleChangedEventCreator;
-import org.apache.shardingsphere.single.event.config.SingleTableEventCreator;
import
org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodePathProvider;
+import org.apache.shardingsphere.single.subscriber.SingleTableChangedGenerator;
/**
* Single rule changed event creator.
@@ -31,12 +31,12 @@ public final class SingleRuleChangedEventCreator implements
RuleChangedEventCrea
@Override
public GovernanceEvent create(final String databaseName, final
DataChangedEvent event, final String itemType) {
- return
getUniqueRuleItemChangedEventCreator(itemType).create(databaseName, event);
+ return new UniqueRuleItemChangedEventCreator().create(databaseName,
event, getRuleItemConfigurationChangedGeneratorType(itemType));
}
- private UniqueRuleItemChangedEventCreator
getUniqueRuleItemChangedEventCreator(final String itemType) {
+ private String getRuleItemConfigurationChangedGeneratorType(final String
itemType) {
if (itemType.equals(SingleRuleNodePathProvider.TABLES)) {
- return new SingleTableEventCreator();
+ return SingleTableChangedGenerator.TYPE;
}
throw new UnsupportedOperationException(itemType);
}
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/SingleTableEventCreator.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/SingleTableEventCreator.java
deleted file mode 100644
index 0d5500d4523..00000000000
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/config/SingleTableEventCreator.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.shardingsphere.single.event.config;
-
-import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
-import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-import org.apache.shardingsphere.single.subscriber.SingleTableChangedGenerator;
-
-/**
- * Single table event creator.
- */
-public final class SingleTableEventCreator implements
UniqueRuleItemChangedEventCreator {
-
- @Override
- public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event) {
- if (Type.ADDED == event.getType() || Type.UPDATED == event.getType()) {
- return new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), SingleTableChangedGenerator.TYPE);
- }
- return new DropUniqueRuleItemEvent(databaseName,
SingleTableChangedGenerator.TYPE);
- }
-}
diff --git
a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/NamedRuleItemChangedEventCreator.java
b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/NamedRuleItemChangedEventCreator.java
index c85cbd08776..82df9526c56 100644
---
a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/NamedRuleItemChangedEventCreator.java
+++
b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/NamedRuleItemChangedEventCreator.java
@@ -18,11 +18,14 @@
package org.apache.shardingsphere.mode.event;
import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
+import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterNamedRuleItemEvent;
+import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropNamedRuleItemEvent;
+import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
/**
* Named rule item changed event creator.
*/
-public interface NamedRuleItemChangedEventCreator {
+public final class NamedRuleItemChangedEventCreator {
/**
* Create named rule item changed event.
@@ -30,7 +33,12 @@ public interface NamedRuleItemChangedEventCreator {
* @param databaseName database name
* @param itemName item name
* @param event data changed event
+ * @param type rule item type
* @return named rule item changed event
*/
- RuleItemChangedEvent create(String databaseName, String itemName,
DataChangedEvent event);
+ public RuleItemChangedEvent create(final String databaseName, final String
itemName, final DataChangedEvent event, final String type) {
+ return Type.ADDED == event.getType() || Type.UPDATED == event.getType()
+ ? new AlterNamedRuleItemEvent(databaseName, itemName,
event.getKey(), event.getValue(), type)
+ : new DropNamedRuleItemEvent(databaseName, itemName, type);
+ }
}
diff --git
a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/UniqueRuleItemChangedEventCreator.java
b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/UniqueRuleItemChangedEventCreator.java
index a432aa86f01..2da86e5a86d 100644
---
a/mode/api/src/main/java/org/apache/shardingsphere/mode/event/UniqueRuleItemChangedEventCreator.java
+++
b/mode/api/src/main/java/org/apache/shardingsphere/mode/event/UniqueRuleItemChangedEventCreator.java
@@ -18,18 +18,26 @@
package org.apache.shardingsphere.mode.event;
import org.apache.shardingsphere.infra.rule.event.rule.RuleItemChangedEvent;
+import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterUniqueRuleItemEvent;
+import
org.apache.shardingsphere.infra.rule.event.rule.drop.DropUniqueRuleItemEvent;
+import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
/**
* Unique rule item changed event creator.
*/
-public interface UniqueRuleItemChangedEventCreator {
+public final class UniqueRuleItemChangedEventCreator {
/**
* Create named rule item changed event.
*
* @param databaseName database name
* @param event data changed event
+ * @param type rule item type
* @return named rule item changed event
*/
- RuleItemChangedEvent create(String databaseName, DataChangedEvent event);
+ public RuleItemChangedEvent create(final String databaseName, final
DataChangedEvent event, final String type) {
+ return Type.ADDED == event.getType() || Type.UPDATED == event.getType()
+ ? new AlterUniqueRuleItemEvent(databaseName, event.getKey(),
event.getValue(), type)
+ : new DropUniqueRuleItemEvent(databaseName, type);
+ }
}
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
index ce6fabee390..e7cb5657524 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
@@ -43,10 +43,10 @@ public final class RuleItemChangedSubscriber {
@SuppressWarnings({"UnstableApiUsage", "rawtypes", "unchecked"})
@Subscribe
public void renew(final AlterRuleItemEvent event) {
- RuleItemConfigurationChangedGenerator generator =
TypedSPILoader.getService(RuleItemConfigurationChangedGenerator.class,
event.getType());
if
(!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey())))
{
return;
}
+ RuleItemConfigurationChangedGenerator generator =
TypedSPILoader.getService(RuleItemConfigurationChangedGenerator.class,
event.getType());
String yamlContent =
contextManager.getInstanceContext().getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(),
event.getActiveVersion());
ShardingSphereDatabase database =
contextManager.getMetaDataContexts().getMetaData().getDatabases().get(event.getDatabaseName());
RuleConfiguration currentRuleConfig =
generator.findRuleConfiguration(database);
@@ -64,10 +64,10 @@ public final class RuleItemChangedSubscriber {
@SuppressWarnings({"UnstableApiUsage", "rawtypes", "unchecked"})
@Subscribe
public void renew(final DropRuleItemEvent event) {
- RuleItemConfigurationChangedGenerator generator =
TypedSPILoader.getService(RuleItemConfigurationChangedGenerator.class,
event.getType());
if
(!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName()))
{
return;
}
+ RuleItemConfigurationChangedGenerator generator =
TypedSPILoader.getService(RuleItemConfigurationChangedGenerator.class,
event.getType());
ShardingSphereDatabase database =
contextManager.getMetaDataContexts().getMetaData().getDatabases().get(event.getDatabaseName());
RuleConfiguration currentRuleConfig =
generator.findRuleConfiguration(database);
synchronized (this) {