From ec5e25f406b83c8b94f510f748904cefc176a596 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Tue, 6 May 2025 10:24:32 -0400 Subject: [PATCH] refactor: Rename the jaxrs.WasmPlugin* classes to jars.ProxyWasm* as WasmPlugin was a bit too generic. Signed-off-by: Hiram Chirino --- .github/dependabot.yml | 15 +++++++++++ .../jaxrs/{WasmPlugin.java => ProxyWasm.java} | 8 +++--- ...uginFeature.java => ProxyWasmFeature.java} | 26 +++++++++---------- ...PluginFilter.java => ProxyWasmFilter.java} | 14 +++++----- ...uginFeature.java => ProxyWasmFeature.java} | 17 ++++++------ ...ure.java => AbstractProxyWasmFeature.java} | 12 ++++----- .../proxywasm/jaxrs/example/Resources.java | 14 +++++----- .../jaxrs/example/tests/BaseTest.java | 6 ++--- 8 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 .github/dependabot.yml rename proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/{WasmPlugin.java => ProxyWasm.java} (84%) rename proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/{WasmPluginFeature.java => ProxyWasmFeature.java} (79%) rename proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/{WasmPluginFilter.java => ProxyWasmFilter.java} (97%) rename proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/{WasmPluginFeature.java => ProxyWasmFeature.java} (81%) rename proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/{AbstractWasmPluginFeature.java => AbstractProxyWasmFeature.java} (91%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..05fc58a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "maven" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily \ No newline at end of file diff --git a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPlugin.java b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasm.java similarity index 84% rename from proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPlugin.java rename to proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasm.java index 7b4bb2a..b6d9217 100644 --- a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPlugin.java +++ b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasm.java @@ -12,15 +12,15 @@ * *

Apply this annotation to JAX-RS resource classes or methods to enable filtering * by the Proxy-Wasm plugins identified by the names specified in the {@link #value()} attribute. - * The {@link WasmPluginFeature} must be registered for this annotation to have effect. + * The {@link ProxyWasmFeature} must be registered for this annotation to have effect. * - * @see WasmPluginFeature - * @see WasmPluginFilter + * @see ProxyWasmFeature + * @see ProxyWasmFilter */ @NameBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) -public @interface WasmPlugin { +public @interface ProxyWasm { /** * Specifies the names of the Proxy-Wasm plugins that should filter the annotated * resource class or method. diff --git a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPluginFeature.java b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasmFeature.java similarity index 79% rename from proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPluginFeature.java rename to proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasmFeature.java index 014ccfa..8c0db1f 100644 --- a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPluginFeature.java +++ b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasmFeature.java @@ -3,20 +3,20 @@ import io.roastedroot.proxywasm.PluginFactory; import io.roastedroot.proxywasm.StartException; import io.roastedroot.proxywasm.internal.ServerAdaptor; -import io.roastedroot.proxywasm.jaxrs.internal.AbstractWasmPluginFeature; +import io.roastedroot.proxywasm.jaxrs.internal.AbstractProxyWasmFeature; import java.util.Arrays; import java.util.List; /** * A JAX-RS {@link jakarta.ws.rs.core.Feature} that enables Proxy-Wasm plugin filtering - * for JAX-RS applications. This feature registers the necessary {@link WasmPluginFilter} - * to intercept requests and responses for resources annotated with {@link WasmPlugin}. + * for JAX-RS applications. This feature registers the necessary {@link ProxyWasmFilter} + * to intercept requests and responses for resources annotated with {@link ProxyWasm}. * *

To use this feature, register an instance of it with your JAX-RS application, providing * the required {@link ServerAdaptor} and a list of {@link PluginFactory} instances. * *

If you are using a CDI container like quarkus, you will be using the - * {@link io.roastedroot.proxywasm.jaxrs.cdi.WasmPluginFeature} instead. + * {@link io.roastedroot.proxywasm.jaxrs.cdi.ProxyWasmFeature} instead. * *

  * public class MyApplication extends jakarta.ws.rs.core.Application {
@@ -34,24 +34,24 @@
  *             // Assuming a ServerAdaptor and PluginFactory are available
  *             ServerAdaptor serverAdaptor = ...;
  *             PluginFactory myPluginFactory = ...;
- *             singletons.add(new WasmPluginFeature(serverAdaptor, myPluginFactory));
+ *             singletons.add(new ProxyWasmFeature(serverAdaptor, myPluginFactory));
  *         } catch (StartException e) {
- *             throw new RuntimeException("Failed to initialize WasmPluginFeature", e);
+ *             throw new RuntimeException("Failed to initialize ProxyWasmFeature", e);
  *         }
  *         return singletons;
  *     }
  * }
  * 
* - * @see WasmPlugin - * @see WasmPluginFilter + * @see ProxyWasm + * @see ProxyWasmFilter * @see PluginFactory * @see ServerAdaptor */ -public class WasmPluginFeature extends AbstractWasmPluginFeature { +public class ProxyWasmFeature extends AbstractProxyWasmFeature { /** - * Constructs a new WasmPluginFeature. + * Constructs a new ProxyWasmFeature. * * @param httpServer The {@link ServerAdaptor} used to adapt JAX-RS specific request/response * objects for the Proxy-Wasm host. @@ -60,13 +60,13 @@ public class WasmPluginFeature extends AbstractWasmPluginFeature { * @throws StartException If an error occurs during the initialization or startup of the * underlying Proxy-Wasm plugins. */ - public WasmPluginFeature(ServerAdaptor httpServer, PluginFactory... factories) + public ProxyWasmFeature(ServerAdaptor httpServer, PluginFactory... factories) throws StartException { this(httpServer, Arrays.asList(factories)); } /** - * Constructs a new WasmPluginFeature with a list of factories. + * Constructs a new ProxyWasmFeature with a list of factories. * * @param httpServer The {@link ServerAdaptor} used to adapt JAX-RS specific request/response * objects for the Proxy-Wasm host. @@ -75,7 +75,7 @@ public WasmPluginFeature(ServerAdaptor httpServer, PluginFactory... factories) * @throws StartException If an error occurs during the initialization or startup of the * underlying Proxy-Wasm plugins. */ - public WasmPluginFeature(ServerAdaptor httpServer, List factories) + public ProxyWasmFeature(ServerAdaptor httpServer, List factories) throws StartException { init(factories, httpServer); } diff --git a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPluginFilter.java b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasmFilter.java similarity index 97% rename from proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPluginFilter.java rename to proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasmFilter.java index aba496d..98853e7 100644 --- a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/WasmPluginFilter.java +++ b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/ProxyWasmFilter.java @@ -29,31 +29,31 @@ * and {@link WriterInterceptor} interfaces to intercept HTTP requests and responses, * allowing Proxy-Wasm plugins to process them. * - *

This filter is registered by the {@link WasmPluginFeature}. It interacts with + *

This filter is registered by the {@link ProxyWasmFeature}. It interacts with * {@link Plugin} instances obtained from configured {@link Pool}s to execute the * appropriate Proxy-Wasm ABI functions (e.g., {@code on_http_request_headers}, * {@code on_http_response_body}) at different stages of the JAX-RS request/response lifecycle. * - * @see WasmPluginFeature - * @see WasmPlugin + * @see ProxyWasmFeature + * @see ProxyWasm * @see Plugin */ -public class WasmPluginFilter +public class ProxyWasmFilter implements ContainerRequestFilter, WriterInterceptor, ContainerResponseFilter { private static final String FILTER_CONTEXT = PluginHttpContext.class.getName() + ".context"; - private static final Logger LOGGER = Logger.getLogger(WasmPluginFilter.class.getName()); + private static final Logger LOGGER = Logger.getLogger(ProxyWasmFilter.class.getName()); private final List pluginPools; /** - * Constructs a WasmPluginFilter. + * Constructs a ProxyWasmFilter. * * @param pluginPools A list of {@link Pool} instances, each managing a pool of {@link Plugin} * instances for a specific Wasm module. */ - public WasmPluginFilter(List pluginPools) { + public ProxyWasmFilter(List pluginPools) { this.pluginPools = List.copyOf(pluginPools); } diff --git a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/WasmPluginFeature.java b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/ProxyWasmFeature.java similarity index 81% rename from proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/WasmPluginFeature.java rename to proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/ProxyWasmFeature.java index 2e6988d..27322a4 100644 --- a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/WasmPluginFeature.java +++ b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/cdi/ProxyWasmFeature.java @@ -3,7 +3,8 @@ import io.roastedroot.proxywasm.PluginFactory; import io.roastedroot.proxywasm.StartException; import io.roastedroot.proxywasm.internal.ServerAdaptor; -import io.roastedroot.proxywasm.jaxrs.internal.AbstractWasmPluginFeature; +import io.roastedroot.proxywasm.jaxrs.ProxyWasmFilter; +import io.roastedroot.proxywasm.jaxrs.internal.AbstractProxyWasmFeature; import jakarta.annotation.PostConstruct; import jakarta.annotation.PreDestroy; import jakarta.enterprise.context.ApplicationScoped; @@ -26,11 +27,11 @@ * will then automatically register the necessary filters. * *

Note: This class is intended for use in CDI environments. If you are not using CDI, you can - * use the {@link io.roastedroot.proxywasm.jaxrs.WasmPluginFeature} class directly to register the + * use the {@link io.roastedroot.proxywasm.jaxrs.ProxyWasmFeature} class directly to register the * feature with your JAX-RS application. * - * @see io.roastedroot.proxywasm.jaxrs.WasmPluginFeature - * @see io.roastedroot.proxywasm.jaxrs.WasmPluginFilter + * @see io.roastedroot.proxywasm.jaxrs.ProxyWasmFeature + * @see ProxyWasmFilter * @see PluginFactory * @see ServerAdaptor * @see Provider @@ -40,19 +41,19 @@ */ @Provider @ApplicationScoped -public class WasmPluginFeature extends AbstractWasmPluginFeature { +public class ProxyWasmFeature extends AbstractProxyWasmFeature { @Inject Instance factories; @Inject @Any ServerAdaptor serverAdaptor; /** - * Creates a new instance of the WasmPluginFeature. + * Creates a new instance of the ProxyWasmFeature. */ - public WasmPluginFeature() {} + public ProxyWasmFeature() {} /** - * Initializes the WasmPluginFeature using injected CDI dependencies. + * Initializes the ProxyWasmFeature using injected CDI dependencies. * This method is automatically called by the CDI container after dependency injection * is complete. * diff --git a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/AbstractWasmPluginFeature.java b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/AbstractProxyWasmFeature.java similarity index 91% rename from proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/AbstractWasmPluginFeature.java rename to proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/AbstractProxyWasmFeature.java index 771e1c8..8fbbbac 100644 --- a/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/AbstractWasmPluginFeature.java +++ b/proxy-wasm-jaxrs/src/main/java/io/roastedroot/proxywasm/jaxrs/internal/AbstractProxyWasmFeature.java @@ -5,8 +5,8 @@ import io.roastedroot.proxywasm.internal.Plugin; import io.roastedroot.proxywasm.internal.Pool; import io.roastedroot.proxywasm.internal.ServerAdaptor; -import io.roastedroot.proxywasm.jaxrs.WasmPlugin; -import io.roastedroot.proxywasm.jaxrs.WasmPluginFilter; +import io.roastedroot.proxywasm.jaxrs.ProxyWasm; +import io.roastedroot.proxywasm.jaxrs.ProxyWasmFilter; import jakarta.ws.rs.container.DynamicFeature; import jakarta.ws.rs.container.ResourceInfo; import jakarta.ws.rs.core.FeatureContext; @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.stream.Collectors; -public abstract class AbstractWasmPluginFeature implements DynamicFeature { +public abstract class AbstractProxyWasmFeature implements DynamicFeature { private final HashMap pluginPools = new HashMap<>(); @@ -68,11 +68,11 @@ public void configure(ResourceInfo resourceInfo, FeatureContext context) { var resourceMethod = resourceInfo.getResourceMethod(); if (resourceMethod != null) { - WasmPlugin pluignNameAnnotation = resourceMethod.getAnnotation(WasmPlugin.class); + ProxyWasm pluignNameAnnotation = resourceMethod.getAnnotation(ProxyWasm.class); if (pluignNameAnnotation == null) { // If no annotation on method, check the class level pluignNameAnnotation = - resourceInfo.getResourceClass().getAnnotation(WasmPlugin.class); + resourceInfo.getResourceClass().getAnnotation(ProxyWasm.class); } if (pluignNameAnnotation != null) { var pools = @@ -95,7 +95,7 @@ public void configure(ResourceInfo resourceInfo, FeatureContext context) { } }) .collect(Collectors.toList()); - context.register(new WasmPluginFilter(pools)); + context.register(new ProxyWasmFilter(pools)); } } } diff --git a/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java b/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java index dce79e7..5520e81 100644 --- a/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java +++ b/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java @@ -1,6 +1,6 @@ package io.roastedroot.proxywasm.jaxrs.example; -import io.roastedroot.proxywasm.jaxrs.WasmPlugin; +import io.roastedroot.proxywasm.jaxrs.ProxyWasm; import jakarta.ws.rs.GET; import jakarta.ws.rs.HeaderParam; import jakarta.ws.rs.POST; @@ -37,42 +37,42 @@ public Response ok() { @Path("/headerTests") @GET - @WasmPlugin("headerTests") + @ProxyWasm("headerTests") public String httpHeaders(@HeaderParam("x-request-counter") String counter) { return String.format("counter: %s", counter); } @Path("/headerTestsNotShared") @GET - @WasmPlugin("headerTestsNotShared") + @ProxyWasm("headerTestsNotShared") public String notSharedHttpHeaders(@HeaderParam("x-request-counter") String counter) { return String.format("counter: %s", counter); } @Path("/tickTests/{sub: .+ }") @GET - @WasmPlugin("tickTests") + @ProxyWasm("tickTests") public String tickTests(@PathParam("sub") String sub) { return "hello world"; } @Path("/ffiTests/reverse") @POST - @WasmPlugin("ffiTests") + @ProxyWasm("ffiTests") public String ffiTests(String body) { return body; } @Path("/httpCallTests") @GET - @WasmPlugin("httpCallTests") + @ProxyWasm("httpCallTests") public String httpCallTests() { return "hello world"; } @Path("/httpCallTestsAndFFI") @GET - @WasmPlugin({"ffiTests", "httpCallTests"}) + @ProxyWasm({"ffiTests", "httpCallTests"}) public String httpCallTestsAndFFI() { return "hello world"; } diff --git a/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/tests/BaseTest.java b/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/tests/BaseTest.java index 2c6f3a7..1ecc618 100644 --- a/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/tests/BaseTest.java +++ b/proxy-wasm-jaxrs/src/test/java/io/roastedroot/proxywasm/jaxrs/example/tests/BaseTest.java @@ -1,7 +1,7 @@ package io.roastedroot.proxywasm.jaxrs.example.tests; import io.restassured.specification.RequestSpecification; -import io.roastedroot.proxywasm.jaxrs.WasmPluginFeature; +import io.roastedroot.proxywasm.jaxrs.ProxyWasmFeature; import io.roastedroot.proxywasm.jaxrs.example.App; import io.roastedroot.proxywasm.jaxrs.example.Resources; import io.roastedroot.proxywasm.jaxrs.internal.BlockingServerAdaptor; @@ -30,9 +30,9 @@ public void setUp() throws Exception { ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.register(Resources.class); - // Create mock Instance for WasmPluginFeature + // Create mock Instance for ProxyWasmFeature resourceConfig.register( - new WasmPluginFeature( + new ProxyWasmFeature( new BlockingServerAdaptor(), App.headerTests(), App.headerTestsNotShared(),