* @param tAtomDsConfDO
* @return
*/
@SuppressWarnings("rawtypes")
protected static LocalTxDataSourceDO convertTAtomDsConf2JbossConf(TAtomDsConfDO tAtomDsConfDO, String dbName) {
LocalTxDataSourceDO localTxDataSourceDO = new LocalTxDataSourceDO();
if (TStringUtil.isNotBlank(dbName)) {
localTxDataSourceDO.setJndiName(dbName);
}
localTxDataSourceDO.setUserName(tAtomDsConfDO.getUserName());
localTxDataSourceDO.setPassword(tAtomDsConfDO.getPasswd());
localTxDataSourceDO.setDriverClass(tAtomDsConfDO.getDriverClass());
localTxDataSourceDO.setExceptionSorterClassName(tAtomDsConfDO.getSorterClass());
//�������ݿ���������conURL��setConnectionProperties
if (AtomDbTypeEnum.ORACLE == tAtomDsConfDO.getDbTypeEnum()) {
String conUlr = TAtomConURLTools.getOracleConURL(tAtomDsConfDO.getIp(), tAtomDsConfDO.getPort(),
tAtomDsConfDO.getDbName(), tAtomDsConfDO.getOracleConType());
localTxDataSourceDO.setConnectionURL(conUlr);
//�����oracleû������ConnectionProperties����Ը�Ĭ�ϵ�
if (!tAtomDsConfDO.getConnectionProperties().isEmpty()) {
localTxDataSourceDO.setConnectionProperties(tAtomDsConfDO.getConnectionProperties());
} else {
localTxDataSourceDO.setConnectionProperties(TAtomConstants.DEFAULT_ORACLE_CONNECTION_PROPERTIES);
}
} else if (AtomDbTypeEnum.MYSQL == tAtomDsConfDO.getDbTypeEnum()) {
String conUlr = TAtomConURLTools.getMySqlConURL(tAtomDsConfDO.getIp(), tAtomDsConfDO.getPort(),
tAtomDsConfDO.getDbName(), tAtomDsConfDO.getConnectionProperties());
localTxDataSourceDO.setConnectionURL(conUlr);
//��������ҵ�mysqlDriver�е�Valid��ʹ�ã���������valid
try {
Class validClass = Class.forName(TAtomConstants.DEFAULT_MYSQL_VALID_CONNECTION_CHECKERCLASS);
if (null != validClass) {
localTxDataSourceDO
.setValidConnectionCheckerClassName(TAtomConstants.DEFAULT_MYSQL_VALID_CONNECTION_CHECKERCLASS);
} else {
logger.warn("MYSQL Driver is Not Suport "
+ TAtomConstants.DEFAULT_MYSQL_VALID_CONNECTION_CHECKERCLASS);
}
} catch (ClassNotFoundException e) {
logger.warn("MYSQL Driver is Not Suport " + TAtomConstants.DEFAULT_MYSQL_VALID_CONNECTION_CHECKERCLASS);
} catch (NoClassDefFoundError e) {
logger.warn("MYSQL Driver is Not Suport " + TAtomConstants.DEFAULT_MYSQL_VALID_CONNECTION_CHECKERCLASS);
}
//��������ҵ�mysqlDriver�е�integrationSorter��ʹ�÷���ʹ��Ĭ�ϵ�
try {
Class integrationSorterCalss = Class.forName(TAtomConstants.MYSQL_INTEGRATION_SORTER_CLASS);
if (null != integrationSorterCalss) {
localTxDataSourceDO.setExceptionSorterClassName(TAtomConstants.MYSQL_INTEGRATION_SORTER_CLASS);
} else {
localTxDataSourceDO.setExceptionSorterClassName(TAtomConstants.DEFAULT_MYSQL_SORTER_CLASS);
logger.warn("MYSQL Driver is Not Suport " + TAtomConstants.MYSQL_INTEGRATION_SORTER_CLASS
+ " use default sorter " + TAtomConstants.DEFAULT_MYSQL_SORTER_CLASS);
}
} catch (ClassNotFoundException e) {
logger.warn("MYSQL Driver is Not Suport " + TAtomConstants.MYSQL_INTEGRATION_SORTER_CLASS
+ " use default sorter " + TAtomConstants.DEFAULT_MYSQL_SORTER_CLASS);
} catch (NoClassDefFoundError e){
logger.warn("MYSQL Driver is Not Suport " + TAtomConstants.MYSQL_INTEGRATION_SORTER_CLASS
+ " use default sorter " + TAtomConstants.DEFAULT_MYSQL_SORTER_CLASS);
}
}
localTxDataSourceDO.setMinPoolSize(tAtomDsConfDO.getMinPoolSize());
localTxDataSourceDO.setMaxPoolSize(tAtomDsConfDO.getMaxPoolSize());
localTxDataSourceDO.setPreparedStatementCacheSize(tAtomDsConfDO.getPreparedStatementCacheSize());
if (tAtomDsConfDO.getIdleTimeout() > 0) {
localTxDataSourceDO.setIdleTimeoutMinutes(tAtomDsConfDO.getIdleTimeout());
}
if (tAtomDsConfDO.getBlockingTimeout() > 0) {
localTxDataSourceDO.setBlockingTimeoutMillis(tAtomDsConfDO.getBlockingTimeout());
}
return localTxDataSourceDO;
}