Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.method
Class HandlerMethod

    java.lang.Object
      org.springframework.web.method.HandlerMethod

Direct Known Subclasses:
  InvocableHandlerMethod

    public class HandlerMethod

extends java.lang.Object

Encapsulates information about a bean method consisting of a method and a bean. Provides convenient access to method parameters, the method return value, method annotations.

The class may be created with a bean instance or with a bean name (e.g. lazy bean, prototype bean). Use `createWithResolvedBean()` to obtain an `HandlerMethod` instance with a bean instance initialized through the bean factory.

Since:
  3.1
Author:
  Arjen Poutsma, Rossen Stoyanchev

Field Summary
`protected org.apache.commons.logging.Log` | `logger` Logger that is available to subclasses

Constructor Summary
`HandlerMethod(java.lang.Object bean, java.lang.reflect.Method method)` Constructs a new handler method with the given bean instance and method.
`HandlerMethod(java.lang.Object bean, java.lang.String methodName, java.lang.Class<?>... parameterTypes)` Constructs a new handler method with the given bean instance, method name and parameters.
`HandlerMethod(java.lang.String beanName, BeanFactory beanFactory, java.lang.reflect.Method method)` Constructs a new handler method with the given bean name and method.

Method Summary
`HandlerMethod` | `createWithResolvedBean()` If the provided instance contains a bean name rather than an object instance, the bean name is resolved before a `HandlerMethod` is created and returned.
`boolean` | `equals(java.lang.Object o)`
`java.lang.Object` | `getBean()` Returns the bean for this handler method.
`java.lang.Class<?>` | `getBeanType()` Returns the type of the handler for this handler method.
`protected java.lang.reflect.Method` | `getBridgedMethod()` If the bean method is a bridge method, this method returns the bridged (user-defined) method.
`java.lang.reflect.Method` | `getMethod()` Returns the method for this handler method.
`
`<A extends java.lang.annotation.Annotation> A`
` | `getMethodAnnotation(java.lang.Class<A> annotationType)` Returns a single annotation on the underlying method traversing its super methods if no annotation can be found on the given method itself.
`MethodParameter[]` | `getMethodParameters()` Returns the method parameters for this handler method.
`MethodParameter` | `getReturnType()` Return the HandlerMethod return type.
`MethodParameter` | `getReturnValueType(java.lang.Object returnValue)` Return the actual return value type.
`int` | `hashCode()`
`boolean` | `isVoid()` Returns `true` if the method return type is void, `false` otherwise.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### logger

    protected final org.apache.commons.logging.Log logger

  Logger that is available to subclasses

Constructor Detail

### HandlerMethod

    public HandlerMethod(java.lang.Object bean,
                         java.lang.reflect.Method method)

  Constructs a new handler method with the given bean instance and method.

  Parameters:
    `bean` - the object bean
    `method` - the method

### HandlerMethod

    public HandlerMethod(java.lang.Object bean,
                         java.lang.String methodName,
                         java.lang.Class<?>... parameterTypes)
                  throws java.lang.NoSuchMethodException

  Constructs a new handler method with the given bean instance, method name and parameters.

  Parameters:
    `bean` - the object bean
    `methodName` - the method name
    `parameterTypes` - the method parameter types
  Throws:
    `java.lang.NoSuchMethodException` - when the method cannot be found

### HandlerMethod

    public HandlerMethod(java.lang.String beanName,
                         BeanFactory beanFactory,
                         java.lang.reflect.Method method)

  Constructs a new handler method with the given bean name and method. The bean name will be lazily initialized when `createWithResolvedBean()` is called.

  Parameters:
    `beanName` - the bean name
    `beanFactory` - the bean factory to use for bean initialization
    `method` - the method for the bean

Method Detail

### getBean

    public java.lang.Object getBean()

  Returns the bean for this handler method.

### getMethod

    public java.lang.reflect.Method getMethod()

  Returns the method for this handler method.

### getBeanType

    public java.lang.Class<?> getBeanType()

  Returns the type of the handler for this handler method. Note that if the bean type is a CGLIB-generated class, the original, user-defined class is returned.

### getBridgedMethod

    protected java.lang.reflect.Method getBridgedMethod()

  If the bean method is a bridge method, this method returns the bridged (user-defined) method. Otherwise it returns the same method as `getMethod()`.

### getMethodParameters

    public MethodParameter[] getMethodParameters()

  Returns the method parameters for this handler method.

### getReturnType

    public MethodParameter getReturnType()

  Return the HandlerMethod return type.

### getReturnValueType

    public MethodParameter getReturnValueType(java.lang.Object returnValue)

  Return the actual return value type.

### isVoid

    public boolean isVoid()

  Returns `true` if the method return type is void, `false` otherwise.

### getMethodAnnotation

    public <A extends java.lang.annotation.Annotation> A getMethodAnnotation(java.lang.Class<A> annotationType)

  Returns a single annotation on the underlying method traversing its super methods if no annotation can be found on the given method itself.

  Parameters:
    `annotationType` - the type of annotation to introspect the method for.
  Returns:
    the annotation, or `null` if none found

### createWithResolvedBean

    public HandlerMethod createWithResolvedBean()

  If the provided instance contains a bean name rather than an object instance, the bean name is resolved before a `HandlerMethod` is created and returned.

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD