1 4 package demo.jmx; 5 6 import java.util.HashMap ; 7 import java.util.Map ; 8 import org.aopalliance.intercept.MethodInterceptor; 9 import org.aopalliance.intercept.MethodInvocation; 10 11 15 public class CounterHistoryAdvice 16 implements MethodInterceptor 17 { 18 private Map queues = new HashMap (); 19 20 public void setQueues(Map queues) 21 { 22 this.queues = queues; 23 } 24 25 29 public Object invoke(MethodInvocation invocation) 30 throws Throwable 31 { 32 String error = null; 33 try 34 { 35 return invocation.proceed(); 36 37 } 38 catch(Throwable t) 39 { 40 error = t.toString(); 41 throw t; 42 43 } 44 finally 45 { 46 String name = ((ICounter) invocation.getThis()).getName(); 47 HistoryQueue historyQueue = (HistoryQueue) queues.get(name); 48 if(historyQueue!=null) historyQueue.updateHistory(0, error); 49 } 50 } 51 } 52 | Popular Tags |