1 22 package org.jboss.aspects.logging; 23 24 import java.util.ArrayList ; 25 26 33 public class InvocationLogInterceptor 34 implements org.jboss.aop.advice.Interceptor 35 { 36 38 40 42 44 46 48 public String getName() 49 { 50 return "InvocationLogInterceptor"; 51 } 52 53 public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) 54 throws Throwable 55 { 56 Object started = invocation.getMetaData(ThreadLocalAppender.LOG, ThreadLocalAppender.LOG); 57 58 ArrayList log = null; 59 if (started != null) 60 { 61 if (ThreadLocalAppender.getList() != null) 63 started = null; 64 else 65 { 66 log = new ArrayList (); 68 ThreadLocalAppender.setList(log); 69 } 70 } 71 72 try 73 { 74 Object response = invocation.invokeNext(); 76 if (started != null) 77 invocation.addResponseAttachment(ThreadLocalAppender.LOG, log); 78 return response; 79 } 80 finally 81 { 82 if (started != null) 84 ThreadLocalAppender.setList(null); 85 } 86 } 87 88 90 92 94 } 96 | Popular Tags |