1
|
package eu.dnetlib.oai.core;
|
2
|
|
3
|
import org.aopalliance.intercept.MethodInvocation;
|
4
|
import org.apache.commons.logging.Log;
|
5
|
import org.springframework.aop.interceptor.CustomizableTraceInterceptor;
|
6
|
|
7
|
/**
|
8
|
* This class intercepts calls to the OAICore to measure its execution time. It uses Spring AOP.
|
9
|
*
|
10
|
* @author alessia
|
11
|
*/
|
12
|
public class CoreInterceptor extends CustomizableTraceInterceptor {
|
13
|
|
14
|
private static final long serialVersionUID = -9063818317778608736L;
|
15
|
|
16
|
@Override
|
17
|
protected void writeToLog(final Log logger, final String message, final Throwable ex) {
|
18
|
if (ex != null) {
|
19
|
logger.error(message, ex);
|
20
|
} else {
|
21
|
logger.debug(message);
|
22
|
}
|
23
|
}
|
24
|
|
25
|
@Override
|
26
|
protected boolean isInterceptorEnabled(final MethodInvocation invocation, final Log logger) {
|
27
|
return true;
|
28
|
}
|
29
|
}
|