private static List<ConfigProperty> createConfigProperties(CommonDataSource cds,
List<? extends 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;
}