All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ee.telekom.workflow.util.StatisticsLoggingAspect Maven / Gradle / Ivy

Go to download

Telekom-workflow-engine core provides the runtime environment for workflow execution together with all the supporting services (clustering, persistence, error handling etc).

There is a newer version: 1.6.3
Show newest version
package ee.telekom.workflow.util;

import java.lang.invoke.MethodHandles;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Writes a DEBUG log entry after every ee.telekom.workflow package @Service class public method call.
 * The row contains the elapsed milliseconds and an exception message if thrown.
 * 
 * @author Erko Hansar
 */
@Aspect
public class StatisticsLoggingAspect{

    private static final Logger log = LoggerFactory.getLogger( MethodHandles.lookup().lookupClass() );

    @Pointcut("execution(public * ee.telekom.workflow..*(..))")
    public void publicWorkflowMethod(){
    }

    @Around("publicWorkflowMethod() && @within(org.springframework.stereotype.Service)")
    public Object aroundServiceMethod( ProceedingJoinPoint pjp ) throws Throwable{
        long start = System.currentTimeMillis();
        Throwable error = null;
        try{
            return pjp.proceed();
        }
        catch( Throwable t ){
            error = t;
            throw t;
        }
        finally{
            if( log.isDebugEnabled() ){
                long elapsed = System.currentTimeMillis() - start;
                log.debug( pjp.toShortString() + " took " + elapsed + " ms" + (error != null ? ", exception: " + error : "") );
            }
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy