Search in sources :

Example 1 with DatabaseIdProvider

use of org.apache.ibatis.mapping.DatabaseIdProvider in project mybatis-3 by mybatis.

the class XMLConfigBuilder method databaseIdProviderElement.

private void databaseIdProviderElement(XNode context) throws Exception {
    DatabaseIdProvider databaseIdProvider = null;
    if (context != null) {
        String type = context.getStringAttribute("type");
        // awful patch to keep backward compatibility
        if ("VENDOR".equals(type)) {
            type = "DB_VENDOR";
        }
        Properties properties = context.getChildrenAsProperties();
        databaseIdProvider = (DatabaseIdProvider) resolveClass(type).newInstance();
        databaseIdProvider.setProperties(properties);
    }
    Environment environment = configuration.getEnvironment();
    if (environment != null && databaseIdProvider != null) {
        String databaseId = databaseIdProvider.getDatabaseId(environment.getDataSource());
        configuration.setDatabaseId(databaseId);
    }
}
Also used : Environment(org.apache.ibatis.mapping.Environment) Properties(java.util.Properties) DatabaseIdProvider(org.apache.ibatis.mapping.DatabaseIdProvider)

Aggregations

Properties (java.util.Properties)1 DatabaseIdProvider (org.apache.ibatis.mapping.DatabaseIdProvider)1 Environment (org.apache.ibatis.mapping.Environment)1