From 8bfc7eceab58697f867937434accbbbd3ca042af Mon Sep 17 00:00:00 2001 From: Josiah Noel <32279667+SentryMan@users.noreply.github.com> Date: Sat, 23 Nov 2024 16:50:22 -0500 Subject: [PATCH] fix service collision --- .../avaje/jex/render/freemarker/FreeMarkerRenderTest.java | 6 +++--- avaje-jex/src/main/java/io/avaje/jex/DJex.java | 6 +++--- avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java | 8 ++++---- avaje-jex/src/main/java/io/avaje/jex/Jex.java | 4 ++-- avaje-jex/src/main/java/io/avaje/jex/Routing.java | 8 ++++---- avaje-jex/src/main/java/io/avaje/jex/http/ErrorCode.java | 2 +- avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/avaje-jex-freemarker/src/test/java/io/avaje/jex/render/freemarker/FreeMarkerRenderTest.java b/avaje-jex-freemarker/src/test/java/io/avaje/jex/render/freemarker/FreeMarkerRenderTest.java index 73017de3..2b8cdff8 100644 --- a/avaje-jex-freemarker/src/test/java/io/avaje/jex/render/freemarker/FreeMarkerRenderTest.java +++ b/avaje-jex-freemarker/src/test/java/io/avaje/jex/render/freemarker/FreeMarkerRenderTest.java @@ -17,21 +17,21 @@ class FreeMarkerRenderTest { static TestPair pair = init(); static TestPair init() { - final List services = List.of(new NoModel(), new WithModel()); + final List services = List.of(new NoModel(), new WithModel()); var app = Jex.create() .routing(services) .register(new FreeMarkerRender(), "ftl"); return TestPair.create(app); } - static class NoModel implements Routing.Service { + static class NoModel implements Routing.HttpService { @Override public void add(Routing routing) { routing.get("/noModel", ctx -> ctx.render("one.ftl")); } } - static class WithModel implements Routing.Service { + static class WithModel implements Routing.HttpService { @Override public void add(Routing routing) { routing.get("/withModel", ctx -> ctx.render("two.ftl", Map.of("message", "hello"))); diff --git a/avaje-jex/src/main/java/io/avaje/jex/DJex.java b/avaje-jex/src/main/java/io/avaje/jex/DJex.java index ed24cce8..f5fd7320 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/DJex.java +++ b/avaje-jex/src/main/java/io/avaje/jex/DJex.java @@ -36,13 +36,13 @@ public T attribute(Class cls) { } @Override - public Jex routing(Routing.Service routes) { + public Jex routing(Routing.HttpService routes) { routing.add(routes); return this; } @Override - public Jex routing(Collection routes) { + public Jex routing(Collection routes) { routing.addAll(routes); return this; } @@ -70,7 +70,7 @@ public Jex configureWith(BeanScope beanScope) { for (JexPlugin plugin : beanScope.list(JexPlugin.class)) { plugin.apply(this); } - routing.addAll(beanScope.list(Routing.Service.class)); + routing.addAll(beanScope.list(Routing.HttpService.class)); beanScope.getOptional(JsonService.class).ifPresent(this::jsonService); return this; } diff --git a/avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java b/avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java index 999aaddd..c0ef2a59 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java +++ b/avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java @@ -12,7 +12,7 @@ import io.avaje.jex.Routing.Entry; import io.avaje.jex.Routing.Group; -import io.avaje.jex.Routing.Service; +import io.avaje.jex.Routing.HttpService; import io.avaje.jex.Routing.Type; import io.avaje.jex.security.Role; @@ -55,14 +55,14 @@ private void addEndpoints(String path, Group group) { } @Override - public Routing add(Routing.Service routes) { + public Routing add(Routing.HttpService routes) { routes.add(this); return this; } @Override - public Routing addAll(Collection routes) { - for (Service route : routes) { + public Routing addAll(Collection routes) { + for (HttpService route : routes) { route.add(this); } return this; diff --git a/avaje-jex/src/main/java/io/avaje/jex/Jex.java b/avaje-jex/src/main/java/io/avaje/jex/Jex.java index b0e42346..459ccf91 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/Jex.java +++ b/avaje-jex/src/main/java/io/avaje/jex/Jex.java @@ -58,12 +58,12 @@ static Jex create() { /** * Add routes and handlers to the routing. */ - Jex routing(Routing.Service routes); + Jex routing(Routing.HttpService routes); /** * Add many routes and handlers to the routing. */ - Jex routing(Collection routes); + Jex routing(Collection routes); /** * Return the Routing to configure. diff --git a/avaje-jex/src/main/java/io/avaje/jex/Routing.java b/avaje-jex/src/main/java/io/avaje/jex/Routing.java index 8779eae5..f0deaf3f 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/Routing.java +++ b/avaje-jex/src/main/java/io/avaje/jex/Routing.java @@ -11,14 +11,14 @@ public sealed interface Routing permits DefaultRouting { /** - * Add the routes provided by the Routing Service. + * Add the routes provided by the Routing HttpService. */ - Routing add(Routing.Service routes); + Routing add(Routing.HttpService routes); /** * Add all the routes provided by the Routing Services. */ - Routing addAll(Collection routes); + Routing addAll(Collection routes); /** * Specify permittedRoles for the last added handler. @@ -186,7 +186,7 @@ interface Group { * Adds to the Routing. */ @FunctionalInterface - interface Service { + interface HttpService { /** * Add to the routing. diff --git a/avaje-jex/src/main/java/io/avaje/jex/http/ErrorCode.java b/avaje-jex/src/main/java/io/avaje/jex/http/ErrorCode.java index f1123dd4..f6b4bad8 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/http/ErrorCode.java +++ b/avaje-jex/src/main/java/io/avaje/jex/http/ErrorCode.java @@ -16,7 +16,7 @@ public enum ErrorCode { // 5xx Server Error INTERNAL_SERVER_ERROR(500, "Internal Server Error"), BAD_GATEWAY(502, "Bad Gateway"), - SERVICE_UNAVAILABLE(503, "Service Unavailable"), + SERVICE_UNAVAILABLE(503, "HttpService Unavailable"), GATEWAY_TIMEOUT(504, "Gateway Timeout"), HTTP_VERSION_NOT_SUPPORTED(505, "HTTP Version Not Supported"), VARIANT_ALSO_NEGOTIATES(506, "Variant Also Negotiates"), diff --git a/avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java b/avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java index 821c407c..91834abb 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java +++ b/avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java @@ -3,7 +3,7 @@ import java.util.Iterator; /** - * Service used to convert request/response bodies to beans. + * HttpService used to convert request/response bodies to beans. */ public non-sealed interface JsonService extends JexExtension {