package org.globus.progtutorial.services.core.core_sd.impl;


import org.codehaus.aspectwerkz.xmldef.advice.AroundAdvice;
import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
import org.codehaus.aspectwerkz.joinpoint.MethodJoinPoint;
import java.io.*;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class LoggingAdvice extends AroundAdvice {

    static Log logger = LogFactory.getLog(MathProvider.class.getName());

    public LoggingAdvice() {
        super();
    }

    public Object execute(final JoinPoint joinPoint) throws Throwable {

        MethodJoinPoint jp = (MethodJoinPoint)joinPoint;

        try{
            logger.info("AspectInstance:"+this.toString()+" --> " + jp.getTargetClass().getName() + "::" +             jp.getMethodName()+"("+ (jp.getParameters()[0]).toString()+")");
        }catch(Exception e){
            logger.info("--> " + jp.getTargetClass().getName() + "::" + jp.getMethodName());
        }
        final Object result = joinPoint.proceed();

        return result;
    }

}