use of org.glassfish.api.jdbc.SQLTraceRecord in project Payara by payara.
the class ProfiledConnectionWrapper40 method getProxyObject.
// TODO refactor this method and move to a higher level
private <T> T getProxyObject(final Object actualObject, Class<T>[] ifaces) throws Exception {
T result;
InvocationHandler ih = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
SQLTraceRecord record = new SQLTraceRecord();
record.setMethodName(method.getName());
record.setParams(args);
record.setClassName(actualObject.getClass().getName());
record.setThreadName(Thread.currentThread().getName());
record.setThreadID(Thread.currentThread().getId());
record.setTimeStamp(System.currentTimeMillis());
try {
long startTime = System.currentTimeMillis();
Object methodResult = method.invoke(actualObject, args);
record.setExecutionTime(System.currentTimeMillis() - startTime);
return methodResult;
} catch (InvocationTargetException ex) {
Throwable cause = ex.getCause();
if (cause != null) {
throw cause;
} else {
throw ex;
}
} finally {
sqlTraceDelegator.sqlTrace(record);
}
}
};
result = (T) Proxy.newProxyInstance(actualObject.getClass().getClassLoader(), ifaces, ih);
return result;
}
use of org.glassfish.api.jdbc.SQLTraceRecord in project Payara by payara.
the class JdbcObjectsFactory method getProxyObject.
protected <T> T getProxyObject(final Object actualObject, Class<T>[] ifaces, final SQLTraceDelegator sqlTraceDelegator) throws Exception {
T result;
InvocationHandler ih = new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
SQLTraceRecord record = new SQLTraceRecord();
record.setMethodName(method.getName());
record.setParams(args);
record.setClassName(actualObject.getClass().getName());
record.setThreadName(Thread.currentThread().getName());
record.setThreadID(Thread.currentThread().getId());
record.setTimeStamp(System.currentTimeMillis());
long startTime = System.currentTimeMillis();
Object methodResult = method.invoke(actualObject, args);
record.setExecutionTime(System.currentTimeMillis() - startTime);
sqlTraceDelegator.sqlTrace(record);
return methodResult;
}
};
result = (T) Proxy.newProxyInstance(actualObject.getClass().getClassLoader(), ifaces, ih);
return result;
}
use of org.glassfish.api.jdbc.SQLTraceRecord in project Payara by payara.
the class ProfiledConnectionWrapper30 method getProxyObject.
// TODO refactor this method and move to a higher level
private <T> T getProxyObject(final Object actualObject, Class<T>[] ifaces) throws Exception {
T result;
InvocationHandler ih = new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
SQLTraceRecord record = new SQLTraceRecord();
record.setMethodName(method.getName());
record.setParams(args);
record.setClassName(actualObject.getClass().getName());
record.setThreadName(Thread.currentThread().getName());
record.setThreadID(Thread.currentThread().getId());
record.setTimeStamp(System.currentTimeMillis());
try {
long startTime = System.currentTimeMillis();
Object methodResult = method.invoke(actualObject, args);
record.setExecutionTime(System.currentTimeMillis() - startTime);
return methodResult;
} catch (InvocationTargetException ex) {
Throwable cause = ex.getCause();
if (cause != null) {
throw cause;
} else {
throw ex;
}
} finally {
sqlTraceDelegator.sqlTrace(record);
}
}
};
result = (T) Proxy.newProxyInstance(actualObject.getClass().getClassLoader(), ifaces, ih);
return result;
}
Aggregations