concept intercept() in category java

This is an excerpt from Manning's book Struts 2 in Action.
Now that the ActionInvocation has been created and populated with all the objects and information it needs, we can start the invocation. The ActionInvocation exposes the invoke() method, which is called by the framework to start the execution of the action. When the framework calls this method, the ActionInvocation starts the invocation process by executing the first interceptor in the stack. Note that the invoke() method doesn’t always map to the first interceptor; it’s the responsibility of the ActionInvocation itself to keep track of what stage the invocation process has reached and pass control to the appropriate interceptor in the stack. It does this by calling that interceptor’s intercept() method.
Looking at some code will make these three stages more concrete. The following code snippet shows the intercept() method of the TimerInterceptor, one of the interceptors included in the struts-default package.
![]()
The TimerInterceptor times the execution of an action. The code is simple. The intercept() method, defined by the Interceptor interface, is the entry point into an interceptor’s execution. Note that the intercept method receives the ActionInvocation instance. When the intercept method is called, the interceptor’s preprocessing phase consists of recording the start time
. Next, the interceptor must decide whether it’ll pass control on to the rest of the interceptors and the action. Since this interceptor has no reason to halt the execution process, it always calls invoke(),passing control to whatever comes next in the chain
.
. Next, the interceptor must decide whether it’ll pass control on to the rest of the interceptors and the action. Since this interceptor has no reason to halt the execution process, it always calls invoke(),passing control to whatever comes next in the chain
.