Search in sources :

Example 1 with IJdbcSecurityPlugin

use of org.jaffa.persistence.engines.jdbcengine.security.IJdbcSecurityPlugin 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);
        }
    }
}
Also used : Param(org.jaffa.persistence.engines.jdbcengine.configservice.initdomain.Param) DataSourceCreationException(org.jaffa.persistence.engines.jdbcengine.datasource.exceptions.DataSourceCreationException) IJdbcSecurityPlugin(org.jaffa.persistence.engines.jdbcengine.security.IJdbcSecurityPlugin) DataSourceCreationException(org.jaffa.persistence.engines.jdbcengine.datasource.exceptions.DataSourceCreationException) SQLException(java.sql.SQLException)

Aggregations

SQLException (java.sql.SQLException)1 Param (org.jaffa.persistence.engines.jdbcengine.configservice.initdomain.Param)1 DataSourceCreationException (org.jaffa.persistence.engines.jdbcengine.datasource.exceptions.DataSourceCreationException)1 IJdbcSecurityPlugin (org.jaffa.persistence.engines.jdbcengine.security.IJdbcSecurityPlugin)1