org.jlot.stats.client.MessageSourceStatsAspect Maven / Gradle / Ivy
package org.jlot.stats.client;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.SuppressAjWarnings;
@Aspect
public class MessageSourceStatsAspect
{
private static StatsHarvester statsHarvester = new StatsHarvester();
private static boolean active = false;
@Pointcut("execution(public String org.springframework.context.MessageSource.getMessage(..))")
public void getMessage ( )
{}
@Before("getMessage()")
@SuppressAjWarnings()
public void harvest ( JoinPoint joinPoint )
{
if (active)
{
String code = (String) joinPoint.getArgs()[0];
statsHarvester.collect(code);
}
}
public static void setActive ( boolean active )
{
MessageSourceStatsAspect.active = active;
}
public static StatsHarvester getStatsHarvester ( )
{
return statsHarvester;
}
}