001 package org.shiftone.jrat.core.config;
002
003 import org.shiftone.jrat.core.spi.MethodHandler;
004
005 import java.util.Collection;
006
007 /**
008 * @author jeff@shiftone.org (Jeff Drost)
009 */
010 public class CompositeMethodHandler implements MethodHandler {
011
012 private final MethodHandler[] handlers;
013
014 public CompositeMethodHandler(Collection methodHandlers) {
015 this((MethodHandler[]) methodHandlers.toArray(new MethodHandler[methodHandlers.size()]));
016 }
017
018 private CompositeMethodHandler(MethodHandler[] handlers) {
019 this.handlers = handlers;
020 }
021
022 public void onMethodStart(Object obj) {
023
024 for (int i = 0; i < handlers.length; i++) {
025 handlers[i].onMethodStart(obj);
026 }
027
028 }
029
030 public void onMethodFinish(Object target, long durationNanos, Throwable throwable) {
031
032 for (int i = 0; i < handlers.length; i++) {
033 handlers[i].onMethodFinish(target, durationNanos, throwable);
034 }
035
036 }
037 }