@RestController @Import(value={FusionControllerConfiguration.class,FusionEndpointProperties.class}) @ConditionalOnBean(annotation=Endpoint.class) @NpmPackage(value="@vaadin/fusion-frontend",version="0.0.17") @NpmPackage(value="@vaadin/form",version="0.0.17") public class FusionController extends Object
Endpoint
gets its public methods
exposed so that those can be triggered by a correct POST request, including
the methods inherited from the other classes, excluding Object
class
ones. Other methods (non-public) are not considered by the controller.
For example, if a class with name TestClass
that has the only public
method testMethod
was annotated with the annotation, it can be called
via http://${base_url}/testclass/testmethod POST call, where
${base_url} is the application base url, configured by the user.
Class name and method name case in the request URL does not matter, but if
the method has parameters, the request body should contain a valid JSON with
all parameters in the same order as they are declared in the method. The
parameter types should also correspond for the request to be successful.
Modifier and Type | Field and Description |
---|---|
static String |
VAADIN_ENDPOINT_MAPPER_BEAN_QUALIFIER
A qualifier to override the request and response default json mapper.
|
Constructor and Description |
---|
FusionController(com.fasterxml.jackson.databind.ObjectMapper vaadinEndpointMapper,
ExplicitNullableTypeChecker explicitNullableTypeChecker,
org.springframework.context.ApplicationContext context,
EndpointRegistry endpointRegistry,
CsrfChecker csrfChecker)
A constructor used to initialize the controller.
|
Modifier and Type | Method and Description |
---|---|
org.springframework.http.ResponseEntity<String> |
serveEndpoint(String endpointName,
String methodName,
com.fasterxml.jackson.databind.node.ObjectNode body,
javax.servlet.http.HttpServletRequest request)
Captures and processes the Vaadin endpoint requests.
|
public static final String VAADIN_ENDPOINT_MAPPER_BEAN_QUALIFIER
public FusionController(@Autowired(required=false) @Qualifier(value="vaadinEndpointMapper") com.fasterxml.jackson.databind.ObjectMapper vaadinEndpointMapper, ExplicitNullableTypeChecker explicitNullableTypeChecker, org.springframework.context.ApplicationContext context, EndpointRegistry endpointRegistry, CsrfChecker csrfChecker)
vaadinEndpointMapper
- optional bean to override the default ObjectMapper
that is used for serializing and deserializing request and
response bodies Use
VAADIN_ENDPOINT_MAPPER_BEAN_QUALIFIER
qualifier to override the mapper.explicitNullableTypeChecker
- the method parameter and return value type checker to verify
that null values are explicitcontext
- Spring context to extract beans annotated with
Endpoint
fromendpointRegistry
- the registry used to store endpoint informationcsrfChecker
- the csrf checker to use@PostMapping(path="/{endpoint}/{method}", produces="application/json;charset=UTF-8") public org.springframework.http.ResponseEntity<String> serveEndpoint(@PathVariable(value="endpoint") String endpointName, @PathVariable(value="method") String methodName, @RequestBody(required=false) com.fasterxml.jackson.databind.node.ObjectNode body, javax.servlet.http.HttpServletRequest request)
Matches the endpoint name and a method name with the corresponding Java class and a public method in the class. Extracts parameters from a request body if the Java method requires any and applies in the same order. After the method call, serializes the Java method execution result and sends it back.
If an issue occurs during the request processing, an error response is returned instead of the serialized Java method return value.
endpointName
- the name of an endpoint to address the calls to, not case
sensitivemethodName
- the method name to execute on an endpoint, not case sensitivebody
- optional request body, that should be specified if the method
called has parametersrequest
- the current request which triggers the endpoint callCopyright © 2024. All rights reserved.