Example usage for org.apache.ibatis.io Resources getResourceAsReader

List of usage examples for org.apache.ibatis.io Resources getResourceAsReader

Introduction

In this page you can find the example usage for org.apache.ibatis.io Resources getResourceAsReader.

Prototype

public static Reader getResourceAsReader(ClassLoader loader, String resource) throws IOException 

Source Link

Document

Returns a resource on the classpath as a Reader object

Usage

From source file:net.hasor.db.orm.mybatis3.MyBatisModule.java

License:Apache License

private static SingleProvider<SqlSessionFactory> defaultSessionFactory(final String sqlmapConfig)
        throws IOException {
    Hasor.assertIsNotNull(sqlmapConfig, "sqlmapConfig is null.");
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    final Reader reader = Hasor.assertIsNotNull(Resources.getResourceAsReader(loader, sqlmapConfig),
            "could not find resource '" + sqlmapConfig + "'");
    return new SingleProvider<SqlSessionFactory>(new Provider<SqlSessionFactory>() {
        public SqlSessionFactory get() {
            return new SqlSessionFactoryBuilder().build(reader);
        }//from   w w w .  j av  a 2 s.  co  m
    });
}