Skip to content

Commit 3d4d149

Browse files
committed
Fixes #342.
1 parent fbf1051 commit 3d4d149

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/java/org/apache/ibatis/scripting/LanguageDriverRegistry.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void register(Class<?> cls) {
3232
throw new IllegalArgumentException("null is not a valid Language Driver");
3333
}
3434
if (!LanguageDriver.class.isAssignableFrom(cls)) {
35-
throw new ScriptingException(cls.getName() + " does not implements " + LanguageDriver.class.getName());
35+
throw new ScriptingException(cls.getName() + " does not implement " + LanguageDriver.class.getName());
3636
}
3737
LanguageDriver driver = LANGUAGE_DRIVER_MAP.get(cls);
3838
if (driver == null) {
@@ -45,6 +45,19 @@ public void register(Class<?> cls) {
4545
}
4646
}
4747

48+
public void register(LanguageDriver instance) {
49+
if (instance == null) {
50+
throw new IllegalArgumentException("null is not a valid Language Driver");
51+
}
52+
if (!LanguageDriver.class.isAssignableFrom(instance.getClass())) {
53+
throw new ScriptingException(instance.getClass().getName() + " does not implement " + LanguageDriver.class.getName());
54+
}
55+
LanguageDriver driver = LANGUAGE_DRIVER_MAP.get(instance.getClass());
56+
if (driver == null) {
57+
LANGUAGE_DRIVER_MAP.put(instance.getClass(), driver);
58+
}
59+
}
60+
4861
public LanguageDriver getDriver(Class<?> cls) {
4962
return LANGUAGE_DRIVER_MAP.get(cls);
5063
}

0 commit comments

Comments
 (0)