com.vaadin.hilla.
Class EndpointInvoker
Handles invocation of endpoint methods after checking the user has proper access.
This class is a generic invoker that does not have knowledge of HTTP requests or the context that the method is being invoked in.
For internal use only. May be renamed or removed in a future release.
-
Constructor Summary
ConstructorsConstructorDescriptionEndpointInvoker
(org.springframework.context.ApplicationContext applicationContext, com.fasterxml.jackson.databind.ObjectMapper endpointObjectMapper, ExplicitNullableTypeChecker explicitNullableTypeChecker, jakarta.servlet.ServletContext servletContext, EndpointRegistry endpointRegistry) Creates an instance of this bean.
-
Method Summary
Modifier and TypeMethodDescriptioncheckAccess
(EndpointRegistry.VaadinEndpointData endpointData, Method methodToInvoke, Principal principal, Function<String, Boolean> rolesChecker) Class<?>
getReturnType
(String endpointName, String methodName) Gets the return type of the given method.
getVaadinEndpointData
(String endpointName) invoke
(String endpointName, String methodName, com.fasterxml.jackson.databind.node.ObjectNode body, Principal principal, Function<String, Boolean> rolesChecker) Invoke the given endpoint method with the given parameters if the user has access to do so.
-
Constructor Details
-
EndpointInvoker
public EndpointInvoker(org.springframework.context.ApplicationContext applicationContext, @Qualifier("hillaEndpointObjectMapper") com.fasterxml.jackson.databind.ObjectMapper endpointObjectMapper, ExplicitNullableTypeChecker explicitNullableTypeChecker, jakarta.servlet.ServletContext servletContext, EndpointRegistry endpointRegistry) Creates an instance of this bean.
Parameters:
applicationContext
- The Spring application contextendpointObjectMapper
- The object mapper to be used for serialization and deserialization of request and response bodies. To override the mapper, use theEndpointController.ENDPOINT_MAPPER_FACTORY_BEAN_QUALIFIER
qualifier on a JacksonObjectMapperFactory bean definition.explicitNullableTypeChecker
- the method parameter and return value type checker to verify that null values are explicitservletContext
- the servlet contextendpointRegistry
- the registry used to store endpoint information
-
-
Method Details
-
getReturnType
Gets the return type of the given method.
Parameters:
endpointName
- the name of the endpointmethodName
- the name of the method -
invoke
public Object invoke(String endpointName, String methodName, com.fasterxml.jackson.databind.node.ObjectNode body, Principal principal, Function<String, Boolean> rolesChecker) throws EndpointInvocationException.EndpointNotFoundException, EndpointInvocationException.EndpointAccessDeniedException, EndpointInvocationException.EndpointBadRequestException, EndpointInvocationException.EndpointInternalExceptionInvoke the given endpoint method with the given parameters if the user has access to do so.
Parameters:
endpointName
- the name of the endpointmethodName
- the name of the method in the endpointbody
- optional request body, that should be specified if the method called has parametersprincipal
- the user principal objectrolesChecker
- a function for checking if a user is in a given roleReturns:
the return value of the invoked endpoint method, wrapped in a response entity
Throws:
EndpointInvocationException.EndpointNotFoundException
- if the endpoint was not foundEndpointInvocationException.EndpointAccessDeniedException
- if access to the endpoint was deniedEndpointInvocationException.EndpointBadRequestException
- if there was a problem with the request dataEndpointInvocationException.EndpointInternalException
- if there was an internal error executing the endpoint method -
getVaadinEndpointData
public EndpointRegistry.VaadinEndpointData getVaadinEndpointData(String endpointName) throws EndpointInvocationException.EndpointNotFoundException -
checkAccess
-