Package com.liferay.portal.kernel.aop
Class ChainableMethodAdvice
java.lang.Object
com.liferay.portal.kernel.aop.ChainableMethodAdvice
Provides method advice to implement an aspect for services.
- Author:
- Shuyang Zhou, Brian Wing Shun Chan
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectafterReturning(AopMethodInvocation aopMethodInvocation, Object[] arguments, Object result) Returns the result to propagate to the caller, which allows this advice to replace the intercepted method's return value.protected voidafterThrowing(AopMethodInvocation aopMethodInvocation, Object[] arguments, Throwable throwable) protected Objectbefore(AopMethodInvocation aopMethodInvocation, Object[] arguments) abstract ObjectcreateMethodContext(Object target, Method method, Map<Class<? extends Annotation>, Annotation> annotations) Creates the context to be used when invoking this advice.protected voidduringFinally(AopMethodInvocation aopMethodInvocation, Object[] arguments) invoke(AopMethodInvocation aopMethodInvocation, Object[] arguments)
-
Field Details
-
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. Returningnulldisables this advice for all invocations on the target and method. The context object can be obtained by callingAopMethodInvocation.getAdviceMethodContext(). The context should be immutable as it is reused by concurrent calls toinvoke(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 contextmethod- the method for the contextannotations- a map of the method's annotations- Returns:
- the context object for use during method invocations or
nullto disable this advice for the method
-
invoke
- 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 returnresultunchanged, and returningnullpropagatesnull.nullResultapplies only tobefore(AopMethodInvocation, Object[]), wherenullinstead means that the invocation should proceed.- Parameters:
aopMethodInvocation- the method invocation being advisedarguments- the arguments the method was invoked withresult- 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
-