Multi-Module Vaadin project where routed views are located in independent modules

Viewed 200

I'm playing around the idea of a very huge vaadin application, which consists of a skeleton (providing the ui framework) and hundreds of functional units (providing the specific vaadin views).

The main architectural point is to let the skeleton be agnostic about the functional units, so not a single java dependency to a functional unit should be injected into skeleton. Every single functional unit has to be in it's own distinct JAR.

The vaadin container is started by the skeleton-module. It is perfectly possible to build a navigation with all the necessary routes to the functional units (/routeToView001.../routeToView999) without having further details about them.

However, I don't see, how the started vaadin spring boot container would load the java classes from the independent JARs when navigation occurs in browser. Practical attempts failed. Any ideas?

1 Answers

The Spring Boot integration is by default looking for @Route classes within the Java package that contains the @SpringBootApplication class. This can be further configured by passing package names to the @EnableVaadin annotation.

I haven't tested this in practice, but it might be possible to have a multiple @EnableVaadin annotations so that there would be one in each module and through that also provide multiple locations to look for @Route classes from. In that case, the @EnableVaadin class in each module would also have to register itself in the same way as any other @Configuration by using the regular Spring Boot autoconfiguration mechanism.

Another alternative is that you register route classes manually to the application's route registry (accessed using ApplicationRouteRegistry.getInstance(new VaadinServletContext(servletContext))). In that case, you might still need to have at least a dummy @Route in the base module since Vaadin might not automatically enable itself in a Spring Boot environment unless at least one @Route class is discovered in the regular way.

Related