}
return null;
}
private DataSourceDescription createDataSourceDescription(DataSource ds) {
DataSourceDescription dsDescription = new DataSourceDescription();
dsDescription.setName(ds.getName());
dsDescription.setClassName(ds.getClassName());
if (ds.getDescription() != null) {
dsDescription.setDescription(ds.getDescription().trim());
}
if (ds.getUrl() != null) {
dsDescription.setUrl(ds.getUrl().trim());
}
if (ds.getUser() != null) {
dsDescription.setUser(ds.getUser().trim());
}
if (ds.getPassword() != null) {
dsDescription.setPassword(ds.getPassword().trim());
}
if (ds.getDatabaseName() != null) {
dsDescription.setDatabaseName(ds.getDatabaseName().trim());
}
if (ds.getServerName() != null) {
dsDescription.setServerName(ds.getServerName().trim());
}
if (ds.getPortNumber() != null) {
dsDescription.setPortNumber(ds.getPortNumber());
}
if (ds.getLoginTimeout() != null) {
dsDescription.setLoginTimeout(ds.getLoginTimeout());
}
List<Property> props = ds.getProperty();
if (props != null) {
Map<String, String> properties = new HashMap<String, String>();
for (Property prop : props) {
properties.put(prop.getName().trim(),
prop.getValue().trim());
}
dsDescription.setProperties(properties);
}
// transaction properties
if (ds.getTransactional()) {
dsDescription.setTransactional(ds.getTransactional());
}
if (ds.getIsolationLevel() != null) {
switch (ds.getIsolationLevel()) {
case TRANSACTION_READ_COMMITTED:
dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
break;
case TRANSACTION_READ_UNCOMMITTED:
dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED);
break;
case TRANSACTION_REPEATABLE_READ:
dsDescription.setIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ);
break;
case TRANSACTION_SERIALIZABLE:
dsDescription.setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
break;
}
}
// pool properties
if (ds.getInitialPoolSize() != null) {
dsDescription.setInitialPoolSize(ds.getInitialPoolSize());
}
dsDescription.setMaxPoolSize(ds.getMaxPoolSize() != null? ds.getMaxPoolSize(): defaultMaxSize);
dsDescription.setMinPoolSize(ds.getMinPoolSize() != null? ds.getMinPoolSize(): defaultMinSize);
if (ds.getMaxStatements() != null) {
dsDescription.setMaxStatements(ds.getMaxStatements());
}
dsDescription.setMaxIdleTime(ds.getMaxIdleTime() != null? ds.getMaxIdleTime(): defaultIdleTimeoutMinutes);
//geronimo specific properties
dsDescription.setBlockingTimeoutMilliseconds(defaultBlockingTimeoutMilliseconds);
dsDescription.setXaThreadCaching(defaultXAThreadCaching);
dsDescription.setXaTransactionCaching(defaultXATransactionCaching);
return dsDescription;
}