mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-22 17:12:16 -05:00
Do EnsureContext.setup() call from QueryMapper once
This commit is contained in:
parent
48e93aaa44
commit
2d9c00e8db
@ -4,6 +4,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
@ -11,6 +12,17 @@ import static com.moparisthebest.jdbc.TryClose.tryClose;
|
||||
|
||||
public class QueryMapper implements Closeable {
|
||||
|
||||
static {
|
||||
try{
|
||||
final Class<?> ensureContext = Class.forName(System.getProperty("QueryMapper.ensureContext.class", "com.gcl.containerless.EnsureContext"));
|
||||
final Method method = ensureContext.getMethod(System.getProperty("QueryMapper.ensureContext.method", "setup"));
|
||||
method.invoke(null);
|
||||
}catch(Throwable e){
|
||||
// ignore
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected final ResultSetMapper cm;
|
||||
protected final Connection conn;
|
||||
protected final Context context;
|
||||
@ -20,7 +32,6 @@ public class QueryMapper implements Closeable {
|
||||
Context context = null;
|
||||
if (conn == null && jndiName != null)
|
||||
try {
|
||||
//todo: EnsureContext.setup();
|
||||
context = new InitialContext();
|
||||
DataSource ds = (DataSource) context.lookup(jndiName);
|
||||
conn = ds.getConnection();
|
||||
|
Loading…
Reference in New Issue
Block a user