private static List<ConfigProperty> createConfigProperties(CommonDataSource cds,
List<ConfigProperty> originalProperties)
{
DataSource ds = null;
XaDataSource xads = null;
if (cds instanceof DataSource)
{
ds = (DataSource) cds;
}
if (cds instanceof XaDataSource)
{
xads = (XaDataSource) cds;
}
if (originalProperties != null)
{
List<ConfigProperty> configProperties = new ArrayList<ConfigProperty>(originalProperties.size());
for (ConfigProperty property : originalProperties)
{
ConfigPropertyFactory.Prototype prototype = ConfigPropertyFactory.Prototype.forName(property
.getConfigPropertyName().getValue());
switch (prototype)
{
case USERNAME : {
if (ds != null)
{
Credential security = ds.getSecurity();
if (security != null && security.getUserName() != null &&
!security.getUserName().trim().equals(""))
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
security.getUserName()));
}
}
break;
}
case PASSWORD : {
if (ds != null)
{
Credential security = ds.getSecurity();
if (security != null && security.getPassword() != null &&
!security.getPassword().trim().equals(""))
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
security.getPassword()));
}
}
break;
}
case XADATASOURCEPROPERTIES : {
if (xads != null && xads.getXaDataSourceProperty() != null)
{
StringBuffer valueBuf = new StringBuffer();
for (Entry<String, String> xaConfigProperty : xads.getXaDataSourceProperty().entrySet())
{
valueBuf.append(xaConfigProperty.getKey());
valueBuf.append("=");
valueBuf.append(xaConfigProperty.getValue());
valueBuf.append(";");
}
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, valueBuf.toString()));
}
break;
}
case URLDELIMITER : {
if (ds != null && ds.getUrlDelimiter() != null && !ds.getUrlDelimiter().trim().equals(""))
{
configProperties
.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getUrlDelimiter()));
}
break;
}
case URLSELECTORSTRATEGYCLASSNAME : {
if (ds != null && ds.getUrlSelectorStrategyClassName() != null &&
!ds.getUrlSelectorStrategyClassName().trim().equals(""))
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
ds.getUrlSelectorStrategyClassName()));
}
break;
}
case XADATASOURCECLASS : {
if (xads != null && xads.getXaDataSourceClass() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
xads.getXaDataSourceClass()));
}
break;
}
case TRANSACTIONISOLATION : {
if (ds != null && ds.getTransactionIsolation() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds
.getTransactionIsolation().name()));
}
break;
}
case PREPAREDSTATEMENTCACHESIZE : {
if (ds != null && ds.getStatement() != null &&
ds.getStatement().getPreparedStatementsCacheSize() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getStatement()
.getPreparedStatementsCacheSize()));
}
break;
}
case SHAREPREPAREDSTATEMENTS : {
if (ds != null && ds.getStatement() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
ds.getStatement() != null && ds.getStatement().isSharePreparedStatements()));
}
break;
}
case NEWCONNECTIONSQL : {
if (ds != null && ds.getNewConnectionSql() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
ds.getNewConnectionSql()));
}
break;
}
case CHECKVALIDCONNECTIONSQL : {
if (ds != null && ds.getValidation() != null &&
ds.getValidation().getCheckValidConnectionSql() != null &&
!ds.getValidation().getCheckValidConnectionSql().trim().equals(""))
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getValidation()
.getCheckValidConnectionSql()));
}
break;
}
case VALIDCONNECTIONCHECKERCLASSNAME : {
if (ds != null && ds.getValidation() != null &&
ds.getValidation().getValidConnectionChecker() != null &&
ds.getValidation().getValidConnectionChecker().getClassName() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getValidation()
.getValidConnectionChecker().getClassName()));
}
break;
}
case VALIDCONNECTIONCHECKERPROPERTIES : {
if (ds != null && ds.getValidation() != null &&
ds.getValidation().getValidConnectionChecker() != null &&
ds.getValidation().getValidConnectionChecker().getClassName() != null)
{
StringBuffer valueBuf = new StringBuffer();
for (Entry<String, String> connProperty : ds.getValidation().getValidConnectionChecker()
.getConfigPropertiesMap().entrySet())
{
valueBuf.append(connProperty.getKey());
valueBuf.append("=");
valueBuf.append(connProperty.getValue());
valueBuf.append(";");
}
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, valueBuf.toString()));
}
break;
}
case EXCEPTIONSORTERCLASSNAME : {
if (ds != null && ds.getValidation() != null && ds.getValidation().getExceptionSorter() != null &&
ds.getValidation().getExceptionSorter().getClassName() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getValidation()
.getExceptionSorter().getClassName()));
}
break;
}
case EXCEPTIONSORTERPROPERTIES : {
if (ds != null && ds.getValidation() != null && ds.getValidation().getExceptionSorter() != null)
{
StringBuffer valueBuf = new StringBuffer();
for (Entry<String, String> connProperty : ds.getValidation().getExceptionSorter()
.getConfigPropertiesMap().entrySet())
{
valueBuf.append(connProperty.getKey());
valueBuf.append("=");
valueBuf.append(connProperty.getValue());
valueBuf.append(";");
}
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, valueBuf.toString()));
}
break;
}
case STALECONNECTIONCHECKERCLASSNAME : {
if (ds != null && ds.getValidation() != null &&
ds.getValidation().getStaleConnectionChecker() != null &&
ds.getValidation().getStaleConnectionChecker().getClassName() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getValidation()
.getStaleConnectionChecker().getClassName()));
}
break;
}
case STALECONNECTIONCHECKERPROPERTIES : {
if (ds != null && ds.getValidation() != null &&
ds.getValidation().getStaleConnectionChecker() != null)
{
StringBuffer valueBuf = new StringBuffer();
for (Entry<String, String> connProperty : ds.getValidation().getStaleConnectionChecker()
.getConfigPropertiesMap().entrySet())
{
valueBuf.append(connProperty.getKey());
valueBuf.append("=");
valueBuf.append(connProperty.getValue());
valueBuf.append(";");
}
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, valueBuf.toString()));
}
break;
}
case TRACKSTATEMENTS : {
if (ds != null && ds.getStatement() != null && ds.getStatement().getTrackStatements() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getStatement()
.getTrackStatements().name()));
}
break;
}
case TRANSACTIONQUERYTIMEOUT : {
if (ds != null && ds.getTimeOut() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getTimeOut()
.isSetTxQueryTimeout()));
}
break;
}
case QUERYTIMEOUT : {
if (ds != null && ds.getTimeOut() != null && ds.getTimeOut().getQueryTimeout() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getTimeOut()
.getQueryTimeout()));
}
break;
}
case USETRYLOCK : {
if (ds != null && ds.getTimeOut() != null && ds.getTimeOut().getUseTryLock() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getTimeOut()
.getUseTryLock()));
}
break;
}
case DRIVERCLASS : {
if (ds != null && ds.getDriverClass() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype, ds.getDriverClass()));
}
break;
}
case DATASOURCECLASS : {
if (ds != null && ds.getDataSourceClass() != null)
{
configProperties.add(ConfigPropertyFactory.createConfigProperty(prototype,
ds.getDataSourceClass()));
}
break;
}
case URLPROPERTY :
if (xads != null && xads.getUrlProperty() != null && !xads.getUrlProperty().trim().equals(""))
{
configProperties
.add(ConfigPropertyFactory.createConfigProperty(prototype, xads.getUrlProperty()));
}
break;
case CONNECTIONPROPERTIES : {