Skip to content

Commit 32b8d86

Browse files
committed
Merge pull request #105 from eddumelendez/gh-104
Add vfsImpl property in SqlSessionFactoryBean
2 parents 698aa21 + 5c643b0 commit 32b8d86

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
3030
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
3131
import org.apache.ibatis.executor.ErrorContext;
32+
import org.apache.ibatis.io.VFS;
3233
import org.apache.ibatis.logging.Log;
3334
import org.apache.ibatis.logging.LogFactory;
3435
import org.apache.ibatis.mapping.DatabaseIdProvider;
@@ -64,7 +65,8 @@
6465
* @author Putthibong Boonbong
6566
* @author Hunter Presnall
6667
* @author Eduardo Macarron
67-
*
68+
* @author Eddú Meléndez
69+
*
6870
* @see #setConfigLocation
6971
* @see #setDataSource
7072
* @version $Id$
@@ -107,13 +109,15 @@ public class SqlSessionFactoryBean implements FactoryBean<SqlSessionFactory>, In
107109
//issue #19. No default provider.
108110
private DatabaseIdProvider databaseIdProvider;
109111

112+
private Class<? extends VFS> vfs;
113+
110114
private ObjectFactory objectFactory;
111115

112116
private ObjectWrapperFactory objectWrapperFactory;
113117

114118
/**
115119
* Sets the ObjectFactory.
116-
*
120+
*
117121
* @since 1.1.2
118122
* @param objectFactory
119123
*/
@@ -123,7 +127,7 @@ public void setObjectFactory(ObjectFactory objectFactory) {
123127

124128
/**
125129
* Sets the ObjectWrapperFactory.
126-
*
130+
*
127131
* @since 1.1.2
128132
* @param objectWrapperFactory
129133
*/
@@ -143,7 +147,7 @@ public DatabaseIdProvider getDatabaseIdProvider() {
143147

144148
/**
145149
* Sets the DatabaseIdProvider.
146-
* As of version 1.2.2 this variable is not initialized by default.
150+
* As of version 1.2.2 this variable is not initialized by default.
147151
*
148152
* @since 1.1.0
149153
* @param databaseIdProvider
@@ -152,6 +156,14 @@ public void setDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) {
152156
this.databaseIdProvider = databaseIdProvider;
153157
}
154158

159+
public Class<? extends VFS> getVfs() {
160+
return this.vfs;
161+
}
162+
163+
public void setVfs(Class<? extends VFS> vfs) {
164+
this.vfs = vfs;
165+
}
166+
155167
/**
156168
* Mybatis plugin list.
157169
*
@@ -425,15 +437,19 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException {
425437
}
426438
}
427439
}
428-
440+
429441
if (this.databaseIdProvider != null) {//fix #64 set databaseId before parse mapper xmls
430442
try {
431443
configuration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource));
432444
} catch (SQLException e) {
433445
throw new NestedIOException("Failed getting a databaseId", e);
434446
}
435447
}
436-
448+
449+
if (this.vfs != null) {
450+
configuration.setVfsImpl(this.vfs);
451+
}
452+
437453
if (xmlConfigBuilder != null) {
438454
try {
439455
xmlConfigBuilder.parse();

src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.math.BigDecimal;
2121
import java.math.BigInteger;
2222

23+
import org.apache.ibatis.io.JBoss6VFS;
2324
import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
2425
import org.apache.ibatis.reflection.factory.ObjectFactory;
2526
import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory;
@@ -136,6 +137,7 @@ public void testSetConfigLocation() throws Exception {
136137
assertSame(factory.getConfiguration().getEnvironment().getDataSource(), dataSource);
137138
assertSame(factory.getConfiguration().getEnvironment().getTransactionFactory().getClass(),
138139
org.mybatis.spring.transaction.SpringManagedTransactionFactory.class);
140+
assertSame(factory.getConfiguration().getVfsImpl(), JBoss6VFS.class);
139141

140142
// properties explicitly set differently than the defaults in the config xml
141143
assertFalse(factory.getConfiguration().isCacheEnabled());

src/test/java/org/mybatis/spring/mybatis-config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<setting name="cacheEnabled" value="false" />
2929
<setting name="useGeneratedKeys" value="true" />
3030
<setting name="defaultExecutorType" value="REUSE" />
31+
<setting name="vfsImpl" value="org.apache.ibatis.io.JBoss6VFS"/>
3132
</settings>
3233

3334
<mappers>

0 commit comments

Comments
 (0)