Difference between invoke() and invokeActionOnly() methods

In any Interceptor class invoke() will includes interceptors, action and result execution, while invokeActionOnly() skip the interceptor and go straight to the action.

For ex:-

System.out.println("Before Interceptor invoke");

String result = invocation.invoke();

System.out.println("After Interceptor invoke");

In this After interceptor invokation It will execute action then again it comes to interceptor and displays message "After Interceptor invoke"

System.out.println("Before Interceptor invoke");

String result = invocation.invokeActionOnly();

System.out.println("After Interceptor invoke");

In this After interceptor invocation It will execute action then It will skip the interceptor.If it is in first interceptor of interceptor stack.Then after first interceptor in stack it will skip execution and Other interceptors in stack will never call.

No comments: