Skip to content

Improve setter method on Configuration #657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.ibatis.executor.ErrorContext;
import org.apache.ibatis.executor.loader.ProxyFactory;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.io.VFS;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.parsing.XNode;
Expand Down Expand Up @@ -139,7 +141,9 @@ private void loadCustomVfs(Properties props) throws ClassNotFoundException {
String[] clazzes = value.split(",");
for (String clazz : clazzes) {
if (!clazz.isEmpty()) {
configuration.setVfsImpl(Resources.classForName(clazz));
@SuppressWarnings("unchecked")
Class<? extends VFS> vfsImpl = (Class<? extends VFS>)Resources.classForName(clazz);
configuration.setVfsImpl(vfsImpl);
}
}
}
Expand Down Expand Up @@ -251,7 +255,9 @@ private void settingsElement(Properties props) throws Exception {
configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
configuration.setLogPrefix(props.getProperty("logPrefix"));
configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
@SuppressWarnings("unchecked")
Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl"));
configuration.setLogImpl(logImpl);
configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/apache/ibatis/session/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,9 @@ public Class<? extends Log> getLogImpl() {
return logImpl;
}

@SuppressWarnings("unchecked")
public void setLogImpl(Class<?> logImpl) {
public void setLogImpl(Class<? extends Log> logImpl) {
if (logImpl != null) {
this.logImpl = (Class<? extends Log>) logImpl;
this.logImpl = logImpl;
LogFactory.useCustomLogging(this.logImpl);
}
}
Expand All @@ -226,10 +225,9 @@ public Class<? extends VFS> getVfsImpl() {
return this.vfsImpl;
}

@SuppressWarnings("unchecked")
public void setVfsImpl(Class<?> vfsImpl) {
public void setVfsImpl(Class<? extends VFS> vfsImpl) {
if (vfsImpl != null) {
this.vfsImpl = (Class<? extends VFS>) vfsImpl;
this.vfsImpl = vfsImpl;
VFS.addImplClass(this.vfsImpl);
}
}
Expand Down