public class DataSourceQueryCountListener extends Object implements QueryExecutionListener
Default implementation uses ThreadQueryCountHolder strategy that uses thread local to keep
QueryCount. QueryCount can be retrieved by QueryCountHolder.get(String).
Alternatively, SingleQueryCountHolder strategy can be used. This strategy uses single instance to keep
QueryCount; therefore, QueryCount holds accumulated total values from any threads until values are cleared.
In web application lifecycle, one http request is handled by one thread. Storing database access information into a thread local value provides metrics information per http request. On the other hand, using single instance to store database access information allows you to retrieve total accumulated numbers since application has started.
QueryCount holds following data:
QueryCount,
QueryCountHolder,
QueryCountStrategy,
CommonsQueryCountLoggingServletFilter,
CommonsQueryCountLoggingRequestListener,
CommonsQueryCountLoggingHandlerInterceptorDEFAULT| Constructor and Description |
|---|
DataSourceQueryCountListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterQuery(ExecutionInfo execInfo,
List<QueryInfo> queryInfoList) |
void |
beforeQuery(ExecutionInfo execInfo,
List<QueryInfo> queryInfoList) |
QueryCountStrategy |
getQueryCountStrategy() |
void |
setQueryCountStrategy(QueryCountStrategy queryCountStrategy) |
public void beforeQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList)
beforeQuery in interface QueryExecutionListenerpublic void afterQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList)
afterQuery in interface QueryExecutionListenerpublic QueryCountStrategy getQueryCountStrategy()
public void setQueryCountStrategy(QueryCountStrategy queryCountStrategy)
Copyright © 2023. All rights reserved.