001package io.avaje.inject.aop; 002 003import java.lang.annotation.Annotation; 004import java.lang.reflect.Method; 005 006/** 007 * Provides method interception such that logic can be provided both before and after method invocation. 008 * <p> 009 * MethodInterceptor instances are provided by {@link AspectProvider#interceptor(Method, Annotation)}. 010 */ 011@FunctionalInterface 012public interface MethodInterceptor { 013 014 /** 015 * Implementation can perform before and after invocation logic. 016 * <p> 017 * If a method interceptor wants to replace the result it does this via {@link Invocation#result(Object)}. 018 * This is a little different to traditional method interceptors (i.e. <code>org.org.aopalliance.intercept.MethodInterceptor</code>). 019 * It is done this way to handle implied generic return types in the generated source code. 020 * 021 * @param invocation The invocation being intercepted 022 * @throws Throwable If the interception or underlying invocation throws an exception 023 */ 024 void invoke(Invocation invocation) throws Throwable; 025}