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.naming.InitialContext;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -11,6 +12,17 @@ import static com.moparisthebest.jdbc.TryClose.tryClose;
|
|||||||
|
|
||||||
public class QueryMapper implements Closeable {
|
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 ResultSetMapper cm;
|
||||||
protected final Connection conn;
|
protected final Connection conn;
|
||||||
protected final Context context;
|
protected final Context context;
|
||||||
@ -20,7 +32,6 @@ public class QueryMapper implements Closeable {
|
|||||||
Context context = null;
|
Context context = null;
|
||||||
if (conn == null && jndiName != null)
|
if (conn == null && jndiName != null)
|
||||||
try {
|
try {
|
||||||
//todo: EnsureContext.setup();
|
|
||||||
context = new InitialContext();
|
context = new InitialContext();
|
||||||
DataSource ds = (DataSource) context.lookup(jndiName);
|
DataSource ds = (DataSource) context.lookup(jndiName);
|
||||||
conn = ds.getConnection();
|
conn = ds.getConnection();
|
||||||
|
Loading…
Reference in New Issue
Block a user