001 package org.shiftone.jrat.provider.tree; 002 003 004 import org.shiftone.jrat.core.MethodKey; 005 import org.shiftone.jrat.core.spi.MethodHandler; 006 import org.shiftone.jrat.util.Assert; 007 008 009 /** 010 * @author jeff@shiftone.org (Jeff Drost) 011 */ 012 public class TreeMethodHandler implements MethodHandler { 013 014 private final TreeMethodHandlerFactory factory; 015 private final MethodKey methodKey; 016 017 public TreeMethodHandler(TreeMethodHandlerFactory factory, MethodKey methodKey) { 018 019 Assert.assertNotNull("factory", factory); 020 Assert.assertNotNull("methodKey", methodKey); 021 022 this.factory = factory; 023 this.methodKey = methodKey; 024 } 025 026 027 public void onMethodStart(Object obj) { 028 029 Delegate delegate = factory.getDelegate(); 030 031 delegate.onMethodStart(methodKey); 032 } 033 034 035 public void onMethodFinish(Object obj, long durationNanos, Throwable throwable) { 036 037 Delegate delegate = factory.getDelegate(); 038 039 delegate.onMethodFinish(methodKey, durationNanos, throwable == null); 040 } 041 }