提交 0b3f8f2a 编写于 作者: C cherrylzhao

#1363 Add init DBCP Converter implement.

上级 9f007850
......@@ -21,9 +21,9 @@ import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.transaction.TransactionType;
import io.shardingsphere.spi.xa.BackendDataSourceFactory;
import io.shardingsphere.transaction.manager.ShardingTransactionManagerRegistry;
import io.shardingsphere.transaction.manager.xa.convert.DataSourceParameterFactory;
import javax.sql.DataSource;
import javax.sql.XADataSource;
import java.util.HashMap;
import java.util.Map;
......@@ -32,15 +32,12 @@ public final class XABackendDataSourceConvert implements BackendDataSourceFactor
private static XATransactionManager XA_MANAGER = (XATransactionManager) ShardingTransactionManagerRegistry.getInstance().getShardingTransactionManager(TransactionType.XA);
@Override
public Map<String, DataSource> build(final Map<String, DataSource> dataSourceMap, DatabaseType databaseType) {
public Map<String, DataSource> build(final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType) {
Map<String, DataSource> result = new HashMap<>(dataSourceMap.size(), 1);
for (Map.Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
// result.put(entry.getKey(), TM_MANAGER.wrapDataSource())
DataSource dataSource = XA_MANAGER.wrapDataSource(XADatasourceFactory.build(databaseType), entry.getKey(), DataSourceParameterFactory.build(entry.getValue()));
result.put(entry.getKey(), dataSource);
}
return null;
}
private XADataSource newXADataSource(DatabaseType databaseType) {
return null;
return result;
}
}
......@@ -44,7 +44,6 @@ public interface XATransactionManager extends ShardingTransactionManager<XATrans
* @param dataSourceName data source name
* @param dataSourceParameter data source parameter
* @return XA data source
* @throws Exception if can not wrap the data source
*/
DataSource wrapDataSource(XADataSource xaDataSource, String dataSourceName, DataSourceParameter dataSourceParameter) throws Exception;
DataSource wrapDataSource(XADataSource xaDataSource, String dataSourceName, DataSourceParameter dataSourceParameter);
}
/*
* 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.transaction.manager.xa.convert;
import io.shardingsphere.core.rule.DataSourceParameter;
import javax.sql.DataSource;
/**
* Convert implement of Commons DBCP.
*
* @author zhaojun
*/
public final class DBCPConverter implements Convertor {
@Override
public DataSourceParameter convertTo(DataSource dataSource) {
return null;
}
}
......@@ -19,6 +19,8 @@ package io.shardingsphere.transaction.manager.xa.convert;
import io.shardingsphere.core.rule.DataSourceParameter;
import javax.sql.DataSource;
/**
* Get property of common datasource pool then convert to {@code DataSourceParameter}.
*
......@@ -29,16 +31,21 @@ public class DataSourceParameterFactory {
/**
* Create datasource parameter.
*
* @param poolType pool type
* @param dataSource data source
* @return datasource parameter
*/
public static DataSourceParameter build(final PoolType poolType) {
switch (poolType) {
public static DataSourceParameter build(final DataSource dataSource) {
switch (getPoolType(dataSource)) {
case HIKARI:
case DRUID:
case DBCP:
return new DBCPConverter().convertTo(dataSource);
default:
return null;
}
}
private static PoolType getPoolType(final DataSource dataSource) {
return null;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册