Skip to content

Commit

Permalink
for #1172, simplify spi loader
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Sep 25, 2018
1 parent 5c6cb19 commit e5f4ce2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
package io.shardingsphere.core.bootstrap;

import io.shardingsphere.core.event.ShardingEventListenerRegistrySPILoader;
import io.shardingsphere.core.spi.connection.close.SPICloseConnectionHook;
import io.shardingsphere.core.spi.connection.get.SPIGetConnectionHook;
import io.shardingsphere.core.spi.executor.SPISQLExecutionHook;
import io.shardingsphere.core.spi.parsing.SPIParsingHook;
import io.shardingsphere.core.spi.root.SPIRootInvokeHook;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

Expand All @@ -34,5 +39,10 @@ public final class ShardingBootstrap {
*/
public static void init() {
ShardingEventListenerRegistrySPILoader.registerListeners();
new SPIRootInvokeHook();
new SPIParsingHook();
new SPIGetConnectionHook();
new SPISQLExecutionHook();
new SPICloseConnectionHook();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
*/
public final class SPICloseConnectionHook implements CloseConnectionHook {

private static final ServiceLoader<CloseConnectionHook> SERVICE_LOADER;

static {
SERVICE_LOADER = ServiceLoader.load(CloseConnectionHook.class);
}
private static final ServiceLoader<CloseConnectionHook> SERVICE_LOADER = ServiceLoader.load(CloseConnectionHook.class);

@Override
public void start(final String dataSourceName, final DataSourceMetaData dataSourceMetaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
*/
public final class SPIGetConnectionHook implements GetConnectionHook {

private static final ServiceLoader<GetConnectionHook> SERVICE_LOADER;

static {
SERVICE_LOADER = ServiceLoader.load(GetConnectionHook.class);
}
private static final ServiceLoader<GetConnectionHook> SERVICE_LOADER = ServiceLoader.load(GetConnectionHook.class);

@Override
public void start(final String dataSourceName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
*/
public final class SPISQLExecutionHook implements SQLExecutionHook {

private static final ServiceLoader<SQLExecutionHook> SERVICE_LOADER;

static {
SERVICE_LOADER = ServiceLoader.load(SQLExecutionHook.class);
}
private static final ServiceLoader<SQLExecutionHook> SERVICE_LOADER = ServiceLoader.load(SQLExecutionHook.class);

@Override
public void start(final RouteUnit routeUnit, final List<Object> parameters, final DataSourceMetaData dataSourceMetaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
*/
public final class SPIParsingHook implements ParsingHook {

private static final ServiceLoader<ParsingHook> SERVICE_LOADER;

static {
SERVICE_LOADER = ServiceLoader.load(ParsingHook.class);
}
private static final ServiceLoader<ParsingHook> SERVICE_LOADER = ServiceLoader.load(ParsingHook.class);

@Override
public void start(final String sql) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
*/
public final class SPIRootInvokeHook implements RootInvokeHook {

private static final ServiceLoader<RootInvokeHook> SERVICE_LOADER;

static {
SERVICE_LOADER = ServiceLoader.load(RootInvokeHook.class);
}
private static final ServiceLoader<RootInvokeHook> SERVICE_LOADER = ServiceLoader.load(RootInvokeHook.class);

@Override
public void start() {
Expand Down

0 comments on commit e5f4ce2

Please sign in to comment.