<!--支持spring注解-->
<context:annotation-config />
<context:component-scan base-package="xx" />
<!--支持aspectj注解,注意设置proxy-target-class为true,强制使用cglib-->
<aop:aspectj-autoproxy proxy-target-class="true"/>
@Aspect
@Component
public class TickLogInterceptorWithAspectJ
{
public void pointCut()
{
}
@Around("execution(* xx..*.CarMaker.make*(..))")
public Object tick(ProceedingJoinPoint joinPoint)
{
System.out.println(MessageFormat.format("enter method: {0}.{1}, params: {2}",
joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(),
getParamsString(joinPoint.getArgs())));
try
{
Object o = joinPoint.proceed(joinPoint.getArgs());
System.out.println(MessageFormat.format("exit method: {0}.{1}, result: {2}",
joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(),
o));
return o;
}
catch (Throwable e)
{
return null;
}
}
private String getParamsString(Object[] params)
{
return Joiner.on(",").join(Arrays.asList(params));
}
}