FileDocCategorySizeDatePackage
InvocationLogInterceptor.javaAPI DocJBoss 4.2.13183Fri Jul 13 21:02:26 BST 2007org.jboss.aspects.logging

InvocationLogInterceptor

public class InvocationLogInterceptor extends Object implements org.jboss.aop.advice.Interceptor
An interceptor that tests whether logging should be done to the invocation response.
author
Adrian Brock.
version
$Revision: 57186 $

Fields Summary
Constructors Summary
Methods Summary
public java.lang.StringgetName()

      return "InvocationLogInterceptor";
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      Object started = invocation.getMetaData(ThreadLocalAppender.LOG, ThreadLocalAppender.LOG);

      ArrayList log = null;
      if (started != null)
      {
         // Some earlier invocation started the logging
         if (ThreadLocalAppender.getList() != null)
            started = null;
         else
         {
            // We are the first, start the logging
            log = new ArrayList();
            ThreadLocalAppender.setList(log);
         }
      }

      try
      {
         // Perform the invocation and attach the log when we started it
         Object response = invocation.invokeNext();
         if (started != null)
            invocation.addResponseAttachment(ThreadLocalAppender.LOG, log);
         return response;
      }
      finally
      {
         // If we started the logging, stop it
         if (started != null)
            ThreadLocalAppender.setList(null);
      }