Class InvocableShellMethod
The class may be created with a bean instance or with a bean name
 (e.g. lazy-init bean, prototype bean). Use createWithResolvedBean()
 to obtain a HandlerMethod instance with a bean instance resolved
 through the associated BeanFactory.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classA MethodParameter with HandlerMethod-specific behavior.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final org.slf4j.LoggerPublic for wrapping with fallback logger.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionInvocableShellMethod(Object bean, Method method) Create an instance from a bean instance and a method.InvocableShellMethod(Object bean, String methodName, Class<?>... parameterTypes) Create an instance from a bean instance, method name, and parameter types.InvocableShellMethod(String beanName, org.springframework.beans.factory.BeanFactory beanFactory, Method method) Create an instance from a bean name, a method, and aBeanFactory.protectedInvocableShellMethod(InvocableShellMethod handlerMethod) Copy constructor for use in subclasses.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidassertTargetBean(Method method, Object targetBean, Object[] args) Assert that the target bean class is an instance of the class where the given method is declared.If the provided instance contains a bean name rather than an object instance, the bean name is resolved before aInvocableShellMethodis created and returned.protected ObjectInvoke the handler method with the given argument values.booleanprotected static ObjectfindProvidedArgument(org.springframework.core.MethodParameter parameter, Object... providedArgs) protected static StringformatArgumentError(org.springframework.core.MethodParameter param, String message) protected StringformatInvokeError(String text, Object[] args) getBean()Return the bean for this handler method.Class<?>This method returns the type of the handler for this handler method.protected MethodIf the bean method is a bridge method, this method returns the bridged (user-defined) method.Return the method for this handler method.<A extends Annotation>
 AgetMethodAnnotation(Class<A> annotationType) Return a single annotation on the underlying method traversing its super methods if no annotation can be found on the given method itself.protected Object[]getMethodArgumentValues(org.springframework.messaging.Message<?> message, Object... providedArgs) Get the method argument values for the current message, checking the provided argument values and falling back to the configured argument resolvers.org.springframework.core.MethodParameter[]Return the method parameters for this handler method.Return the HandlerMethod from which this HandlerMethod instance was resolved viacreateWithResolvedBean().org.springframework.core.MethodParameterReturn the HandlerMethod return type.org.springframework.core.MethodParametergetReturnValueType(Object returnValue) Return the actual return value type.Return a short representation of this handler method for log message purposes.inthashCode()<A extends Annotation>
 booleanhasMethodAnnotation(Class<A> annotationType) Return whether the parameter is declared with the given annotation type.Invoke the method after resolving its argument values in the context of the given message.booleanisVoid()Returntrueif the method return type is void,falseotherwise.voidsetConversionService(org.springframework.core.convert.ConversionService conversionService) Sets a conversion servicevoidsetMessageMethodArgumentResolvers(ShellMethodArgumentResolverComposite argumentResolvers) SetHandlerMethodArgumentResolversto use to use for resolving method argument values.voidsetParameterNameDiscoverer(org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer) Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g.voidsetValidator(jakarta.validation.Validator validator) toString()
- 
Field Details- 
logpublic static final org.slf4j.Logger logPublic for wrapping with fallback logger.
 
- 
- 
Constructor Details- 
InvocableShellMethodCreate an instance from a bean instance and a method.
- 
InvocableShellMethodpublic InvocableShellMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException Create an instance from a bean instance, method name, and parameter types.- Throws:
- NoSuchMethodException- when the method cannot be found
 
- 
InvocableShellMethodpublic InvocableShellMethod(String beanName, org.springframework.beans.factory.BeanFactory beanFactory, Method method) Create an instance from a bean name, a method, and aBeanFactory. The methodcreateWithResolvedBean()may be used later to re-create theHandlerMethodwith an initialized bean.
- 
InvocableShellMethodCopy constructor for use in subclasses.
 
- 
- 
Method Details- 
setConversionServicepublic void setConversionService(org.springframework.core.convert.ConversionService conversionService) Sets a conversion service- Parameters:
- conversionService- the conversion service
 
- 
setValidatorpublic void setValidator(jakarta.validation.Validator validator) 
- 
setMessageMethodArgumentResolverspublic void setMessageMethodArgumentResolvers(ShellMethodArgumentResolverComposite argumentResolvers) SetHandlerMethodArgumentResolversto use to use for resolving method argument values.
- 
setParameterNameDiscovererpublic void setParameterNameDiscoverer(org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer) Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).Default is a DefaultParameterNameDiscoverer.
- 
invoke@Nullable public Object invoke(org.springframework.messaging.Message<?> message, Object... providedArgs) throws Exception Invoke the method after resolving its argument values in the context of the given message.Argument values are commonly resolved through HandlerMethodArgumentResolvers. TheprovidedArgsparameter however may supply argument values to be used directly, i.e. without argument resolution.Delegates to getMethodArgumentValues(org.springframework.messaging.Message<?>, java.lang.Object...)and callsdoInvoke(java.lang.Object...)with the resolved arguments.- Parameters:
- message- the current message being processed
- providedArgs- "given" arguments matched by type, not resolved
- Returns:
- the raw value returned by the invoked method
- Throws:
- Exception- raised if no suitable argument resolver can be found, or if the method raised an exception
- See Also:
 
- 
getMethodArgumentValuesprotected Object[] getMethodArgumentValues(org.springframework.messaging.Message<?> message, Object... providedArgs) throws Exception Get the method argument values for the current message, checking the provided argument values and falling back to the configured argument resolvers.The resulting array will be passed into doInvoke(java.lang.Object...).- Throws:
- Exception
 
- 
doInvokeInvoke the handler method with the given argument values.- Throws:
- Exception
 
- 
getBeanReturn the bean for this handler method.
- 
getMethodReturn the method for this handler method.
- 
getBeanTypeThis method 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. 
- 
getBridgedMethodIf the bean method is a bridge method, this method returns the bridged (user-defined) method. Otherwise it returns the same method asgetMethod().
- 
getMethodParameterspublic org.springframework.core.MethodParameter[] getMethodParameters()Return the method parameters for this handler method.
- 
getReturnTypepublic org.springframework.core.MethodParameter getReturnType()Return the HandlerMethod return type.
- 
getReturnValueTypeReturn the actual return value type.
- 
isVoidpublic boolean isVoid()Returntrueif the method return type is void,falseotherwise.
- 
getMethodAnnotationReturn a single annotation on the underlying method traversing its super methods if no annotation can be found on the given method itself.Also supports merged composed annotations with attribute overrides. - Parameters:
- annotationType- the type of annotation to introspect the method for
- Returns:
- the annotation, or nullif none found
- See Also:
- 
- AnnotatedElementUtils.findMergedAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<A>)
 
 
- 
hasMethodAnnotationReturn whether the parameter is declared with the given annotation type.- Parameters:
- annotationType- the annotation type to look for
- See Also:
- 
- AnnotatedElementUtils.hasAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
 
 
- 
getResolvedFromHandlerMethodReturn the HandlerMethod from which this HandlerMethod instance was resolved viacreateWithResolvedBean().
- 
createWithResolvedBeanIf the provided instance contains a bean name rather than an object instance, the bean name is resolved before aInvocableShellMethodis created and returned.
- 
getShortLogMessageReturn a short representation of this handler method for log message purposes.
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
- 
findProvidedArgument
- 
formatArgumentError
- 
assertTargetBeanAssert that the target bean class is an instance of the class where the given method is declared. In some cases the actual endpoint instance at request- processing time may be a JDK dynamic proxy (lazy initialization, prototype beans, and others). Endpoint classes that require proxying should prefer class-based proxy mechanisms.
- 
formatInvokeError
 
-