Class ChainableMethodAdvice

java.lang.Object
com.liferay.portal.kernel.aop.ChainableMethodAdvice

public abstract class ChainableMethodAdvice extends Object
Provides method advice to implement an aspect for services.
Author:
Shuyang Zhou, Brian Wing Shun Chan
  • Field Details

    • nullResult

      protected static Object nullResult
  • Constructor Details

    • ChainableMethodAdvice

      public ChainableMethodAdvice()
  • Method Details

    • createMethodContext

      public abstract Object createMethodContext(Object target, Method method, Map<Class<? extends Annotation>,Annotation> annotations)
      Creates the context to be used when invoking this advice. The context can be useful for caching information derived from reflective calls on the method. Returning null disables this advice for all invocations on the target and method. The context object can be obtained by calling AopMethodInvocation.getAdviceMethodContext(). The context should be immutable as it is reused by concurrent calls to invoke(AopMethodInvocation, Object[]), and it must not hold the target, which is replaced whenever the advised service is wrapped or unwrapped.
      Parameters:
      target - the target for the context
      method - the method for the context
      annotations - a map of the method's annotations
      Returns:
      the context object for use during method invocations or null to disable this advice for the method
    • invoke

      public Object invoke(AopMethodInvocation aopMethodInvocation, Object[] arguments) throws Throwable
      Throws:
      Throwable
    • afterReturning

      protected Object afterReturning(AopMethodInvocation aopMethodInvocation, Object[] arguments, Object result) throws Throwable
      Returns the result to propagate to the caller, which allows this advice to replace the intercepted method's return value. An advice that only observes the result must return result unchanged, and returning null propagates null. nullResult applies only to before(AopMethodInvocation, Object[]), where null instead means that the invocation should proceed.
      Parameters:
      aopMethodInvocation - the method invocation being advised
      arguments - the arguments the method was invoked with
      result - the result from the rest of the invocation chain
      Returns:
      the result to propagate to the caller
      Throws:
      Throwable
    • afterThrowing

      protected void afterThrowing(AopMethodInvocation aopMethodInvocation, Object[] arguments, Throwable throwable) throws Throwable
      Throws:
      Throwable
    • before

      protected Object before(AopMethodInvocation aopMethodInvocation, Object[] arguments) throws Throwable
      Throws:
      Throwable
    • duringFinally

      protected void duringFinally(AopMethodInvocation aopMethodInvocation, Object[] arguments)