Skip to content

Commit 442b98d

Browse files
committed
Merge pull request #657 from kazuki43zoo/improve-Configuration
Improve setter method on Configuration
2 parents 92cd5af + 19bb3dc commit 442b98d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.apache.ibatis.executor.ErrorContext;
2727
import org.apache.ibatis.executor.loader.ProxyFactory;
2828
import org.apache.ibatis.io.Resources;
29+
import org.apache.ibatis.io.VFS;
30+
import org.apache.ibatis.logging.Log;
2931
import org.apache.ibatis.mapping.DatabaseIdProvider;
3032
import org.apache.ibatis.mapping.Environment;
3133
import org.apache.ibatis.parsing.XNode;
@@ -139,7 +141,9 @@ private void loadCustomVfs(Properties props) throws ClassNotFoundException {
139141
String[] clazzes = value.split(",");
140142
for (String clazz : clazzes) {
141143
if (!clazz.isEmpty()) {
142-
configuration.setVfsImpl(Resources.classForName(clazz));
144+
@SuppressWarnings("unchecked")
145+
Class<? extends VFS> vfsImpl = (Class<? extends VFS>)Resources.classForName(clazz);
146+
configuration.setVfsImpl(vfsImpl);
143147
}
144148
}
145149
}
@@ -251,7 +255,9 @@ private void settingsElement(Properties props) throws Exception {
251255
configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
252256
configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
253257
configuration.setLogPrefix(props.getProperty("logPrefix"));
254-
configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
258+
@SuppressWarnings("unchecked")
259+
Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl"));
260+
configuration.setLogImpl(logImpl);
255261
configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
256262
}
257263

src/main/java/org/apache/ibatis/session/Configuration.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,9 @@ public Class<? extends Log> getLogImpl() {
214214
return logImpl;
215215
}
216216

217-
@SuppressWarnings("unchecked")
218-
public void setLogImpl(Class<?> logImpl) {
217+
public void setLogImpl(Class<? extends Log> logImpl) {
219218
if (logImpl != null) {
220-
this.logImpl = (Class<? extends Log>) logImpl;
219+
this.logImpl = logImpl;
221220
LogFactory.useCustomLogging(this.logImpl);
222221
}
223222
}
@@ -226,10 +225,9 @@ public Class<? extends VFS> getVfsImpl() {
226225
return this.vfsImpl;
227226
}
228227

229-
@SuppressWarnings("unchecked")
230-
public void setVfsImpl(Class<?> vfsImpl) {
228+
public void setVfsImpl(Class<? extends VFS> vfsImpl) {
231229
if (vfsImpl != null) {
232-
this.vfsImpl = (Class<? extends VFS>) vfsImpl;
230+
this.vfsImpl = vfsImpl;
233231
VFS.addImplClass(this.vfsImpl);
234232
}
235233
}

0 commit comments

Comments
 (0)