mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-24 18:02:18 -05:00
Lazy load SQLChecker so it doesn't error if it won't be used
This commit is contained in:
parent
bf7be50d89
commit
7b1b83fddd
@ -72,10 +72,12 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
||||
//IFJAVA8_END
|
||||
private JdbcMapper.DatabaseType defaultDatabaseType;
|
||||
private String defaultArrayNumberTypeName, defaultArrayStringTypeName;
|
||||
private SQLChecker sqlChecker;
|
||||
private Set<String> allowedMaxRowParamNames;
|
||||
private CompileTimeResultSetMapper rsm;
|
||||
|
||||
private String sqlCheckerClass;
|
||||
private SQLChecker sqlChecker;
|
||||
|
||||
public JdbcMapperProcessor() {
|
||||
//out.println("JdbcMapperProcessor running!");
|
||||
}
|
||||
@ -142,15 +144,8 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
||||
defaultArrayStringTypeName = processingEnv.getOptions().get("jdbcMapper.arrayStringTypeName");
|
||||
if (defaultArrayStringTypeName == null || defaultArrayStringTypeName.isEmpty())
|
||||
defaultArrayStringTypeName = defaultDatabaseType.arrayStringTypeName;
|
||||
final String sqlCheckerClass = processingEnv.getOptions().get("jdbcMapper.sqlCheckerClass");
|
||||
if(sqlCheckerClass != null) {
|
||||
try {
|
||||
sqlChecker = (SQLChecker) Class.forName(sqlCheckerClass).newInstance();
|
||||
} catch (Throwable e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
|
||||
"Error instantiating class specified by jdbcMapper.sqlCheckerClass, needs to implement SQLChecker and have a public no-arg constructor:" + toString(e));
|
||||
}
|
||||
}
|
||||
|
||||
sqlCheckerClass = processingEnv.getOptions().get("jdbcMapper.sqlCheckerClass");
|
||||
|
||||
String allowedMaxRowParamNames = processingEnv.getOptions().get("JdbcMapper.allowedMaxRowParamNames");
|
||||
if (allowedMaxRowParamNames == null || allowedMaxRowParamNames.isEmpty())
|
||||
@ -638,9 +633,21 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
||||
|
||||
w.write("\t}\n");
|
||||
|
||||
if(sqlChecker != null && eeMethod.getAnnotation(JdbcMapper.SkipSQLCheck.class) == null)
|
||||
if(sqlCheckerClass != null && eeMethod.getAnnotation(JdbcMapper.SkipSQLCheck.class) == null) {
|
||||
if(sqlChecker == null) {
|
||||
// *can* this run in parallel? unsure, probably doesn't hurt though
|
||||
synchronized (this) {
|
||||
try {
|
||||
sqlChecker = (SQLChecker) Class.forName(sqlCheckerClass).newInstance();
|
||||
} catch (Throwable e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
|
||||
"Error instantiating class specified by jdbcMapper.sqlCheckerClass, needs to implement SQLChecker and have a public no-arg constructor:" + toString(e), eeMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
sqlChecker.checkSql(processingEnv, genClass, mapper, databaseType, eeMethod, sqlStatement, bindParams, arrayInList);
|
||||
}
|
||||
}
|
||||
|
||||
// look on super classes and interfaces recursively
|
||||
if (lookupCloseMethod)
|
||||
|
Loading…
Reference in New Issue
Block a user