Open Source Consultant, Software Developer and System Administrator

If you are interrested in hiring a consultant for the effective use of open source software on an enterprise grade, take a look around in the About section to see, what I have to offer.

Blog and snippets

Various snippets or code parts I found useful, so I keep them here for reference.

Using Groovy for Vaadin Hilla endpoints

Since version 2 Vaadin Hilla no longer needs endpoints to be .java files to be parsed. Now the endpoints are determined by analyzing the generated classes. So in theory any JVM language can be used now for endpoints - as long as the result comes close enough to what the Java compiler would produce.

For Groovy this means to annotate the @dev.hilla.Enpoint classes with @groovy.transform.stc.POJO and @groovy.transform.CompileStatic.

@CompileStatic is no stranger, but @POJO is new since Groovy 4.0; both combined will result in byte-code, that is very close to what the Java compiler would produce from a similar .java file. Yet you are still able to use Groovy code and annotations.

Complete example:

package com.example.application.helloworld

import com.vaadin.flow.server.auth.AnonymousAllowed
import dev.hilla.Endpoint
import jakarta.annotation.Nonnull
import jakarta.validation.constraints.NotEmpty

@Endpoint
@AnonymousAllowed
@groovy.transform.stc.POJO      // XXX
@groovy.transform.CompileStatic // XXX
class HelloWorldEndpoint {

    private final HelloWorldService helloWorldService

    HelloWorldEndpoint(HelloWorldService helloWorldService) {
        this.helloWorldService = helloWorldService
    }

    @Nonnull
    String sayHello(@NotEmpty String name) {
        return helloWorldService.sayHello(name)
    }
}