Skip to content

Commit

Permalink
for #1172, load spi for every new spi loader instance
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Sep 26, 2018
1 parent 93f8b6e commit bc7bea0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@
*/
public final class SPISQLExecutionHook implements SQLExecutionHook {

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

@Override
public synchronized void start(final RouteUnit routeUnit, final DataSourceMetaData dataSourceMetaData, final boolean isTrunkThread) {
for (SQLExecutionHook each : SERVICE_LOADER) {
public void start(final RouteUnit routeUnit, final DataSourceMetaData dataSourceMetaData, final boolean isTrunkThread) {
for (SQLExecutionHook each : serviceLoader) {
each.start(routeUnit, dataSourceMetaData, isTrunkThread);
}
}

@Override
public synchronized void finishSuccess() {
for (SQLExecutionHook each : SERVICE_LOADER) {
public void finishSuccess() {
for (SQLExecutionHook each : serviceLoader) {
each.finishSuccess();
}
}

@Override
public synchronized void finishFailure(final Exception cause) {
for (SQLExecutionHook each : SERVICE_LOADER) {
public void finishFailure(final Exception cause) {
for (SQLExecutionHook each : serviceLoader) {
each.finishFailure(cause);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
*/
public final class SPIParsingHook implements ParsingHook {

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

@Override
public void start(final String sql) {
for (ParsingHook each : SERVICE_LOADER) {
for (ParsingHook each : serviceLoader) {
each.start(sql);
}
}

@Override
public void finishSuccess() {
for (ParsingHook each : SERVICE_LOADER) {
for (ParsingHook each : serviceLoader) {
each.finishSuccess();
}
}

@Override
public void finishFailure(final Exception cause) {
for (ParsingHook each : SERVICE_LOADER) {
for (ParsingHook each : serviceLoader) {
each.finishFailure(cause);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
*/
public final class SPIRootInvokeHook implements RootInvokeHook {

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

@Override
public void start() {
for (RootInvokeHook each : SERVICE_LOADER) {
for (RootInvokeHook each : serviceLoader) {
each.start();
}
}

@Override
public void finish(final int connectionCount) {
for (RootInvokeHook each : SERVICE_LOADER) {
for (RootInvokeHook each : serviceLoader) {
each.finish(connectionCount);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ private String toString(final List<List<Object>> parameterSets) {
}

private List<String> toStringList(final List<List<Object>> parameterSets) {
List<String> parameterString = new LinkedList<>();
List<String> result = new LinkedList<>();
for (List<Object> each : parameterSets) {
parameterString.add(String.format("[%s]", Joiner.on(", ").join(each)));
result.add(String.format("[%s]", Joiner.on(", ").join(each)));
}
return parameterString;
return result;
}

@Override
Expand Down

0 comments on commit bc7bea0

Please sign in to comment.