From c557b84c37792288b53f305f24e4f74c42ad94bd Mon Sep 17 00:00:00 2001 From: Tomi Virtanen Date: Wed, 27 Mar 2024 15:02:43 +0200 Subject: [PATCH] chore: implement ClientRoutesProvider ClientRoutesProvider interface from flow-server is used by Flow to read a list of available client routes. Hilla can implement it in ClientRouteRegistry, which is already a Spring bean, and this way Flow finds it automatically. Related-to: vaadin/flow/isues/18857 --- .../com/vaadin/hilla/route/ClientRouteRegistry.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/java/endpoint/src/main/java/com/vaadin/hilla/route/ClientRouteRegistry.java b/packages/java/endpoint/src/main/java/com/vaadin/hilla/route/ClientRouteRegistry.java index a571c3bbd2..8df3d8abc4 100644 --- a/packages/java/endpoint/src/main/java/com/vaadin/hilla/route/ClientRouteRegistry.java +++ b/packages/java/endpoint/src/main/java/com/vaadin/hilla/route/ClientRouteRegistry.java @@ -24,13 +24,14 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.util.AntPathMatcher; +import com.vaadin.flow.router.internal.ClientRoutesProvider; import java.io.IOException; -import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Paths; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.Objects; @@ -40,7 +41,7 @@ * Keeps track of registered client side routes. */ @Component -public class ClientRouteRegistry implements Serializable { +public class ClientRouteRegistry implements ClientRoutesProvider { /** * A map of registered routes and their corresponding client view @@ -184,4 +185,10 @@ private void registerAndRecurseChildren(String basePath, }); } } + + @Override + public List getClientRoutes() { + return getAllRoutes().keySet().stream().toList(); + } + }