diff --git a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandler.java b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandler.java index 15cc1a2718c46..383f7f909230c 100644 --- a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandler.java +++ b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandler.java @@ -21,8 +21,8 @@ * Sharding event handler. * * @author zhangliang - * @param type of sharding start event - * @param type of sharding finish event + * @param type of start event + * @param type of finish event */ public interface ShardingEventHandler { diff --git a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandlerLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandlerLoader.java new file mode 100644 index 0000000000000..7814b042112f4 --- /dev/null +++ b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/ShardingEventHandlerLoader.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016-2018 shardingsphere.io. + *

+ * Licensed 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 io.shardingsphere.core.spi.event; + +/** + * Sharding event handler loader. + * + * @author zhangliang + * @param type of start event + * @param type of finish event + */ +public interface ShardingEventHandlerLoader { + + /** + * Handle start event. + * + * @param event start event + */ + void start(S event); + + /** + * Handle finish event. + * + * @param event finish event + */ + void finish(F event); +} diff --git a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/close/CloseConnectionEventHandlerLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/close/CloseConnectionEventHandlerLoader.java index 66314a9aad6c6..4af2a892d6ef7 100644 --- a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/close/CloseConnectionEventHandlerLoader.java +++ b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/close/CloseConnectionEventHandlerLoader.java @@ -17,6 +17,8 @@ package io.shardingsphere.core.spi.event.connection.close; +import io.shardingsphere.core.spi.event.ShardingEventHandlerLoader; + import java.util.ServiceLoader; /** @@ -24,7 +26,7 @@ * * @author zhangliang */ -public final class CloseConnectionEventHandlerLoader { +public final class CloseConnectionEventHandlerLoader implements ShardingEventHandlerLoader { private static final CloseConnectionEventHandlerLoader INSTANCE = new CloseConnectionEventHandlerLoader(); @@ -43,22 +45,14 @@ public static CloseConnectionEventHandlerLoader getInstance() { return INSTANCE; } - /** - * Handle close connection start event. - * - * @param event get connection start event - */ + @Override public void start(final CloseConnectionStartEvent event) { for (CloseConnectionEventHandler each : serviceLoader) { each.start(event); } } - /** - * Handle close connection finish event. - * - * @param event get connection finish event - */ + @Override public void finish(final CloseConnectionFinishEvent event) { for (CloseConnectionEventHandler each : serviceLoader) { each.finish(event); diff --git a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/get/GetConnectionEventHandlerLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/get/GetConnectionEventHandlerLoader.java index 54e5a4abebafb..71d6f8d6d205e 100644 --- a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/get/GetConnectionEventHandlerLoader.java +++ b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/connection/get/GetConnectionEventHandlerLoader.java @@ -17,6 +17,8 @@ package io.shardingsphere.core.spi.event.connection.get; +import io.shardingsphere.core.spi.event.ShardingEventHandlerLoader; + import java.util.ServiceLoader; /** @@ -24,7 +26,7 @@ * * @author zhangliang */ -public final class GetConnectionEventHandlerLoader { +public final class GetConnectionEventHandlerLoader implements ShardingEventHandlerLoader { private static final GetConnectionEventHandlerLoader INSTANCE = new GetConnectionEventHandlerLoader(); @@ -43,22 +45,14 @@ public static GetConnectionEventHandlerLoader getInstance() { return INSTANCE; } - /** - * Handle get connection start event. - * - * @param event get connection start event - */ + @Override public void start(final GetConnectionStartEvent event) { for (GetConnectionEventHandler each : serviceLoader) { each.start(event); } } - /** - * Handle get connection finish event. - * - * @param event get connection finish event - */ + @Override public void finish(final GetConnectionFinishEvent event) { for (GetConnectionEventHandler each : serviceLoader) { each.finish(event); diff --git a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/executor/SQLExecutionEventHandlerLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/executor/SQLExecutionEventHandlerLoader.java index 87abf9333d072..4b5823f12ff5e 100644 --- a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/executor/SQLExecutionEventHandlerLoader.java +++ b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/executor/SQLExecutionEventHandlerLoader.java @@ -17,6 +17,8 @@ package io.shardingsphere.core.spi.event.executor; +import io.shardingsphere.core.spi.event.ShardingEventHandlerLoader; + import java.util.ServiceLoader; /** @@ -24,7 +26,7 @@ * * @author zhangliang */ -public final class SQLExecutionEventHandlerLoader { +public final class SQLExecutionEventHandlerLoader implements ShardingEventHandlerLoader { private static final SQLExecutionEventHandlerLoader INSTANCE = new SQLExecutionEventHandlerLoader(); @@ -43,22 +45,14 @@ public static SQLExecutionEventHandlerLoader getInstance() { return INSTANCE; } - /** - * Handle SQL execution start event. - * - * @param event SQL execution start event - */ + @Override public void start(final SQLExecutionStartEvent event) { for (SQLExecutionEventHandler each : serviceLoader) { each.start(event); } } - /** - * Handle SQL execution finish event. - * - * @param event SQL execution finish event - */ + @Override public void finish(final SQLExecutionFinishEvent event) { for (SQLExecutionEventHandler each : serviceLoader) { each.finish(event); diff --git a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/parsing/ParsingEventHandlerLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/parsing/ParsingEventHandlerLoader.java index 21aed92609b27..66c4d6cd6e5a1 100644 --- a/sharding-core/src/main/java/io/shardingsphere/core/spi/event/parsing/ParsingEventHandlerLoader.java +++ b/sharding-core/src/main/java/io/shardingsphere/core/spi/event/parsing/ParsingEventHandlerLoader.java @@ -17,6 +17,8 @@ package io.shardingsphere.core.spi.event.parsing; +import io.shardingsphere.core.spi.event.ShardingEventHandlerLoader; + import java.util.ServiceLoader; /** @@ -24,7 +26,7 @@ * * @author zhangliang */ -public final class ParsingEventHandlerLoader { +public final class ParsingEventHandlerLoader implements ShardingEventHandlerLoader { private static final ParsingEventHandlerLoader INSTANCE = new ParsingEventHandlerLoader(); @@ -43,22 +45,14 @@ public static ParsingEventHandlerLoader getInstance() { return INSTANCE; } - /** - * Handle parsing start event. - * - * @param event parsing start event - */ + @Override public void start(final ParsingStartEvent event) { for (ParsingEventHandler each : serviceLoader) { each.start(event); } } - /** - * Handle parsing finish event. - * - * @param event parsing finish event - */ + @Override public void finish(final ParsingFinishEvent event) { for (ParsingEventHandler each : serviceLoader) { each.finish(event);