001    package tinlizard.util;
002    
003    import org.aspectj.lang.reflect.MethodSignature;
004    import java.lang.reflect.Method;
005    
006    import org.aspectj.lang.annotation.*;
007    import org.aspectj.lang.*;
008    
009    import tinlizard.dao.maven.ScmDaoImpl;
010    import org.apache.log4j.Logger;
011    
012    
013    @Aspect
014    public class ProfilerAspect {
015            private static final Logger LOG = Logger.getLogger(ProfilerAspect.class);
016        
017            
018            @Pointcut("execution(public * tinlizard.web.*Web.*(*))")
019            public void tinLizardMethod(ProceedingJoinPoint jp) {
020          
021            }
022      
023            @Around("tinLizardMethod(jp)")
024            public Object profileAdvice(ProceedingJoinPoint jp) {
025                    Object rval = null;
026          
027                    try {
028                            long t = 0;
029                            if(LOG.isInfoEnabled()) {
030                                    t = System.currentTimeMillis();
031                            }
032                            
033                            rval = jp.proceed();
034                            
035                            if(LOG.isInfoEnabled()) {
036                                    MethodSignature signature = (MethodSignature) jp.getSignature();
037                                    Method method = signature.getMethod();
038                                    long elapsed = System.currentTimeMillis() - t;
039                                    LOG.info(method.getDeclaringClass().getName() + "." + method.getName() + " Elapsed Time " + elapsed + " ms.");
040                            }
041                    } finally {
042                            
043                    }
044                    return rval;
045            }
046    }