FileDocCategorySizeDatePackage
TraceThreadAspect.javaAPI DocJBoss 4.2.13045Fri Jul 13 21:02:30 BST 2007org.jboss.aspects.asynchronous.aspects.jboss

TraceThreadAspect

public class TraceThreadAspect extends Object
author
{Claude Hussenet Independent Consultant}.
version
$Revision: 57186 $

Fields Summary
private static final Log
log
private static SimpleDateFormat
formatter
Constructors Summary
public TraceThreadAspect()


     
Methods Summary
public static java.lang.StringgetCurrentDate()


      return formatter.format(new Date(System.currentTimeMillis()));

   
public java.lang.Objecttrace(org.jboss.aop.joinpoint.MethodInvocation methodInvocation)


      String className = null;

      if (methodInvocation.getTargetObject() != null)

         className = methodInvocation.getTargetObject().getClass().getName();

      else

         className = methodInvocation.getMethod().getDeclaringClass().getName();

      StringBuffer txt =

      new StringBuffer(Thread.currentThread().toString())

      .append(" ")

      .append(methodInvocation.getMethod().getReturnType().getName())

      .append(" ")

      .append(className)

      .append(".")

      .append(methodInvocation.getMethod().getName())

      .append("(");

      Class[] parameterTypes =

      methodInvocation.getActualMethod().getParameterTypes();

      for (int i = 0; i < parameterTypes.length; i++)
      {

         txt.append(parameterTypes[i].getName());

         if (i + 1 < parameterTypes.length)

            txt.append(",");

      }

      txt.append(")");

      log.info(new StringBuffer("TRACE ENTER: ").append(getCurrentDate()).append(" ").append(txt));

      Object rsp = methodInvocation.invokeNext();

      log.info(new StringBuffer("TRACE EXIT: ").append(getCurrentDate()).append(" ").append(txt));

      return rsp;