Package dev.hilla
Class EndpointInvoker
- java.lang.Object
-
- dev.hilla.EndpointInvoker
-
@Component public class EndpointInvoker extends Object
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
Constructors Constructor Description EndpointInvoker(org.springframework.context.ApplicationContext applicationContext, com.fasterxml.jackson.databind.ObjectMapper vaadinEndpointMapper, ExplicitNullableTypeChecker explicitNullableTypeChecker, javax.servlet.ServletContext servletContext, EndpointRegistry endpointRegistry)Creates an instance of this bean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>getReturnType(String endpointName, String methodName)Gets the return type of the given method.Objectinvoke(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 Detail
-
EndpointInvoker
public EndpointInvoker(org.springframework.context.ApplicationContext applicationContext, com.fasterxml.jackson.databind.ObjectMapper vaadinEndpointMapper, ExplicitNullableTypeChecker explicitNullableTypeChecker, javax.servlet.ServletContext servletContext, EndpointRegistry endpointRegistry)Creates an instance of this bean.- Parameters:
applicationContext- Spring context to extract beans annotated withEndpointfromvaadinEndpointMapper- optional bean to override the defaultObjectMapperthat is used for serializing and deserializing request and response bodies UseEndpointController.VAADIN_ENDPOINT_MAPPER_BEAN_QUALIFIERqualifier to override the mapper.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 Detail
-
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.EndpointInternalException
Invoke 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 role- Returns:
- 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
-
-