use of org.jaffa.persistence.engines.jdbcengine.datasource.exceptions.DataSourceCreationException in project jaffa-framework by jaffa-projects.
the class DataSourceFactory method initialize.
private static synchronized void initialize(Database database) throws DataSourceCreationException {
if (c_connectionFactory == null) {
try {
// create an instance of the JDBC Security Plugin, while instantiating the ConnectionFactory
if (database.getJdbcSecurityPlugin() != null && database.getJdbcSecurityPlugin().getValue() != null && database.getJdbcSecurityPlugin().getValue().length() > 0)
c_jdbcSecurityPlugin = (IJdbcSecurityPlugin) Class.forName(database.getJdbcSecurityPlugin().getValue()).newInstance();
} catch (Exception e) {
String str = "Error in creating an instance of the JDBC Security Plugin for the class: " + database.getJdbcSecurityPlugin();
log.error(str, e);
throw new DataSourceCreationException(DataSourceCreationException.JDBC_PLUGIN_CREATION_FAILED, new Object[] { database.getJdbcSecurityPlugin() }, e);
}
try {
// now instantiate the ConnectionFactory and set its properties
IConnectionFactory connectionFactory = (IConnectionFactory) Class.forName(database.getConnectionFactory().getClassName()).newInstance();
if (database.getConnectionFactory().getParam() != null) {
for (Iterator<?> i = database.getConnectionFactory().getParam().iterator(); i.hasNext(); ) {
Param param = (Param) i.next();
BeanHelper.setField(connectionFactory, param.getName(), param.getValue());
}
}
c_connectionFactory = connectionFactory;
} catch (Exception e) {
String str = "Error in creating an instance of the ConnectionFactory for the class: " + database.getConnectionFactory().getClassName();
log.error(str, e);
throw new DataSourceCreationException(DataSourceCreationException.CONNECTION_FACTORY_CREATION_FAILED, new Object[] { database.getConnectionFactory().getClassName() }, e);
}
}
}
Aggregations