Loading sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/api/OrchestrationCloseableDataSourceUtil.java 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright 1999-2015 dangdang.com. * <p> * 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. * </p> */ package io.shardingjdbc.orchestration.api; import io.shardingjdbc.orchestration.internal.OrchestrationMasterSlaveDataSource; import io.shardingjdbc.orchestration.internal.OrchestrationShardingDataSource; import javax.sql.DataSource; /** * Orchestration closeable datasource util. * * @author caohao */ public final class OrchestrationCloseableDataSourceUtil { public static void closeQuietly(final DataSource dataSource) { if (dataSource instanceof OrchestrationShardingDataSource) { ((OrchestrationShardingDataSource) dataSource).close(); } if (dataSource instanceof OrchestrationMasterSlaveDataSource) { ((OrchestrationMasterSlaveDataSource) dataSource).close(); } } } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/masterslave/YamlOrchestrationMasterSlaveIntegrateTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package io.shardingjdbc.orchestration.yaml.masterslave; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.shardingjdbc.orchestration.api.OrchestrationCloseableDataSourceUtil; import io.shardingjdbc.orchestration.api.OrchestrationMasterSlaveDataSourceFactory; import io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest; import lombok.RequiredArgsConstructor; Loading Loading @@ -73,5 +74,6 @@ public class YamlOrchestrationMasterSlaveIntegrateTest extends AbstractYamlDataS stm.executeQuery("SELECT * FROM t_order_item"); stm.executeQuery("SELECT * FROM t_config"); } OrchestrationCloseableDataSourceUtil.closeQuietly(dataSource); } } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingIntegrateTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package io.shardingjdbc.orchestration.yaml.sharding; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.shardingjdbc.orchestration.api.OrchestrationCloseableDataSourceUtil; import io.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory; import io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest; import lombok.RequiredArgsConstructor; Loading Loading @@ -76,5 +77,6 @@ public class YamlOrchestrationShardingIntegrateTest extends AbstractYamlDataSour stm.executeQuery("SELECT * FROM t_order_item"); stm.executeQuery("SELECT * FROM config"); } OrchestrationCloseableDataSourceUtil.closeQuietly(dataSource); } } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingWithMasterSlaveIntegrateTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package io.shardingjdbc.orchestration.yaml.sharding; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.shardingjdbc.orchestration.api.OrchestrationCloseableDataSourceUtil; import io.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory; import io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest; import lombok.RequiredArgsConstructor; Loading Loading @@ -83,5 +84,6 @@ public class YamlOrchestrationShardingWithMasterSlaveIntegrateTest extends Abstr stm.executeQuery("SELECT * FROM t_order_item"); stm.executeQuery("SELECT * FROM config"); } OrchestrationCloseableDataSourceUtil.closeQuietly(dataSource); } } Loading
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/api/OrchestrationCloseableDataSourceUtil.java 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright 1999-2015 dangdang.com. * <p> * 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. * </p> */ package io.shardingjdbc.orchestration.api; import io.shardingjdbc.orchestration.internal.OrchestrationMasterSlaveDataSource; import io.shardingjdbc.orchestration.internal.OrchestrationShardingDataSource; import javax.sql.DataSource; /** * Orchestration closeable datasource util. * * @author caohao */ public final class OrchestrationCloseableDataSourceUtil { public static void closeQuietly(final DataSource dataSource) { if (dataSource instanceof OrchestrationShardingDataSource) { ((OrchestrationShardingDataSource) dataSource).close(); } if (dataSource instanceof OrchestrationMasterSlaveDataSource) { ((OrchestrationMasterSlaveDataSource) dataSource).close(); } } }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/masterslave/YamlOrchestrationMasterSlaveIntegrateTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package io.shardingjdbc.orchestration.yaml.masterslave; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.shardingjdbc.orchestration.api.OrchestrationCloseableDataSourceUtil; import io.shardingjdbc.orchestration.api.OrchestrationMasterSlaveDataSourceFactory; import io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest; import lombok.RequiredArgsConstructor; Loading Loading @@ -73,5 +74,6 @@ public class YamlOrchestrationMasterSlaveIntegrateTest extends AbstractYamlDataS stm.executeQuery("SELECT * FROM t_order_item"); stm.executeQuery("SELECT * FROM t_config"); } OrchestrationCloseableDataSourceUtil.closeQuietly(dataSource); } }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingIntegrateTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package io.shardingjdbc.orchestration.yaml.sharding; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.shardingjdbc.orchestration.api.OrchestrationCloseableDataSourceUtil; import io.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory; import io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest; import lombok.RequiredArgsConstructor; Loading Loading @@ -76,5 +77,6 @@ public class YamlOrchestrationShardingIntegrateTest extends AbstractYamlDataSour stm.executeQuery("SELECT * FROM t_order_item"); stm.executeQuery("SELECT * FROM config"); } OrchestrationCloseableDataSourceUtil.closeQuietly(dataSource); } }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingWithMasterSlaveIntegrateTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package io.shardingjdbc.orchestration.yaml.sharding; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.shardingjdbc.orchestration.api.OrchestrationCloseableDataSourceUtil; import io.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory; import io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest; import lombok.RequiredArgsConstructor; Loading Loading @@ -83,5 +84,6 @@ public class YamlOrchestrationShardingWithMasterSlaveIntegrateTest extends Abstr stm.executeQuery("SELECT * FROM t_order_item"); stm.executeQuery("SELECT * FROM config"); } OrchestrationCloseableDataSourceUtil.closeQuietly(dataSource); } }