use of com.ibatis.sqlmap.engine.scope.SessionScope in project druid by alibaba.
the class IbatisUtils method set.
public static void set(SqlMapSessionImpl session, SqlMapClientImpl client) {
if (sessionField == null) {
for (Field field : SqlMapSessionImpl.class.getDeclaredFields()) {
if (field.getName().equals("session") || field.getName().equals("sessionScope")) {
sessionField = field;
sessionField.setAccessible(true);
break;
}
}
}
if (sessionField != null) {
SessionScope sessionScope;
try {
sessionScope = (SessionScope) sessionField.get(session);
if (sessionScope != null) {
if (sessionScope.getSqlMapClient() != null && sessionScope.getSqlMapClient().getClass() == SqlMapClientImpl.class) {
sessionScope.setSqlMapClient(client);
}
if (sessionScope.getSqlMapExecutor() != null && sessionScope.getSqlMapExecutor().getClass() == SqlMapClientImpl.class) {
sessionScope.setSqlMapExecutor(client);
}
if (sessionScope.getSqlMapTxMgr() != null && sessionScope.getSqlMapTxMgr().getClass() == SqlMapClientImpl.class) {
sessionScope.setSqlMapTxMgr(client);
}
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
Aggregations