Package org.springframework.web.servlet

# Class HandlerExecutionChain

java.lang.Object
org.springframework.web.servlet.HandlerExecutionChain

public class HandlerExecutionChain extends Object
Handler execution chain, consisting of handler object and any handler interceptors. Returned by HandlerMapping's `HandlerMapping.getHandler(jakarta.servlet.http.HttpServletRequest)` method.

Since:
  20.06.2003
Author:
  Juergen Hoeller
See Also:
  - `HandlerInterceptor`

## Constructor Summary

Constructors
Constructor
Description
`HandlerExecutionChain(Object handler)`
Create a new HandlerExecutionChain.
`HandlerExecutionChain(Object handler, List<HandlerInterceptor> interceptorList)`
Create a new HandlerExecutionChain.
`HandlerExecutionChain(Object handler, HandlerInterceptor... interceptors)`
Create a new HandlerExecutionChain.

## Method Summary

Modifier and Type
Method
Description
`void`
`addInterceptor(int index, HandlerInterceptor interceptor)`
Add the given interceptor at the specified index of this chain.
`void`
`addInterceptor(HandlerInterceptor interceptor)`
Add the given interceptor to the end of this chain.
`void`
`addInterceptors(HandlerInterceptor... interceptors)`
Add the given interceptors to the end of this chain.
`Object`
`getHandler()`
Return the handler object to execute.
`List<HandlerInterceptor>`
`getInterceptorList()`
Return the list of interceptors to apply (in the given order).
`HandlerInterceptor[]`
`getInterceptors()`
Return the array of interceptors to apply (in the given order).
`String`
`toString()`
Delegates to the handler's `toString()` implementation.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### HandlerExecutionChain

public HandlerExecutionChain(Object handler)
Create a new HandlerExecutionChain.

Parameters:
  `handler` - the handler object to execute

### HandlerExecutionChain

public HandlerExecutionChain(Object handler, @Nullable HandlerInterceptor... interceptors)
Create a new HandlerExecutionChain.

Parameters:
  `handler` - the handler object to execute
  `interceptors` - the array of interceptors to apply (in the given order) before the handler itself executes

### HandlerExecutionChain

public HandlerExecutionChain(Object handler, List<HandlerInterceptor> interceptorList)
Create a new HandlerExecutionChain.

Parameters:
  `handler` - the handler object to execute
  `interceptorList` - the list of interceptors to apply (in the given order) before the handler itself executes
Since:
  5.3

## Method Details

### getHandler

public Object getHandler()
Return the handler object to execute.

### addInterceptor

public void addInterceptor(HandlerInterceptor interceptor)
Add the given interceptor to the end of this chain.

### addInterceptor

public void addInterceptor(int index, HandlerInterceptor interceptor)
Add the given interceptor at the specified index of this chain.

Since:
  5.2

### addInterceptors

public void addInterceptors(HandlerInterceptor... interceptors)
Add the given interceptors to the end of this chain.

### getInterceptors

@Nullable public HandlerInterceptor[] getInterceptors()
Return the array of interceptors to apply (in the given order).

Returns:
  the array of HandlerInterceptors instances (may be `null`)

### getInterceptorList

public List<HandlerInterceptor> getInterceptorList()
Return the list of interceptors to apply (in the given order).

Returns:
  the list of HandlerInterceptors instances (potentially empty)
Since:
  5.3

### toString

public String toString()
Delegates to the handler's `toString()` implementation.

Overrides:
  `toString` in class `Object`