forked from apache/shardingsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
247 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ore/src/main/java/io/shardingsphere/core/metadata/table/TableMetaDataExecutorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2016-2018 shardingsphere.io. | ||
* <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.shardingsphere.core.metadata.table; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* Table meta data executor adapter. | ||
* | ||
* @author zhangliang | ||
*/ | ||
public interface TableMetaDataExecutorAdapter { | ||
|
||
/** | ||
* Get connection. | ||
* | ||
* @param dataSourceName data source name | ||
* @return connection | ||
* @throws SQLException SQL exception | ||
*/ | ||
Connection getConnection(String dataSourceName) throws SQLException; | ||
|
||
/** | ||
* Is auto close created connection or not. | ||
* @return auto close or not | ||
*/ | ||
boolean isAutoClose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...java/io/shardingsphere/core/jdbc/metadata/AutoClosedJDBCTableMetaDataExecutorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2016-2018 shardingsphere.io. | ||
* <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.shardingsphere.core.jdbc.metadata; | ||
|
||
import io.shardingsphere.core.metadata.table.TableMetaDataExecutorAdapter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.util.Map; | ||
|
||
/** | ||
* Table meta data executor adapter for JDBC and auto closed. | ||
* | ||
* @author zhangliang | ||
*/ | ||
@RequiredArgsConstructor | ||
public final class AutoClosedJDBCTableMetaDataExecutorAdapter implements TableMetaDataExecutorAdapter { | ||
|
||
private final Map<String, DataSource> dataSourceMap; | ||
|
||
@Override | ||
public Connection getConnection(final String dataSourceName) throws SQLException { | ||
return dataSourceMap.get(dataSourceName).getConnection(); | ||
} | ||
|
||
@Override | ||
public boolean isAutoClose() { | ||
return true; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
.../io/shardingsphere/core/jdbc/metadata/ConnectionHoldJDBCTableMetaDataExecutorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2016-2018 shardingsphere.io. | ||
* <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.shardingsphere.core.jdbc.metadata; | ||
|
||
import io.shardingsphere.core.metadata.table.TableMetaDataExecutorAdapter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.sql.Connection; | ||
import java.util.Map; | ||
|
||
/** | ||
* Table meta data executor adapter for JDBC and connection hold by creator. | ||
* | ||
* @author zhangliang | ||
*/ | ||
@RequiredArgsConstructor | ||
public final class ConnectionHoldJDBCTableMetaDataExecutorAdapter implements TableMetaDataExecutorAdapter { | ||
|
||
private final Map<String, Connection> connectionMap; | ||
|
||
@Override | ||
public Connection getConnection(final String dataSourceName) { | ||
return connectionMap.get(dataSourceName); | ||
} | ||
|
||
@Override | ||
public boolean isAutoClose() { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.