Class WasmPluginFeature

  • All Implemented Interfaces:
    jakarta.ws.rs.container.DynamicFeature

    public class WasmPluginFeature
    extends io.roastedroot.proxywasm.jaxrs.internal.AbstractWasmPluginFeature
    A JAX-RS Feature that enables Proxy-Wasm plugin filtering for JAX-RS applications. This feature registers the necessary WasmPluginFilter to intercept requests and responses for resources annotated with WasmPlugin.

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

    If you are using a CDI container like quarkus, you will be using the WasmPluginFeature instead.

     public class MyApplication extends jakarta.ws.rs.core.Application {
         @Override
         public Set<Class<?>> getClasses() {
             Set<Class<?>> resources = new HashSet<>();
             resources.add(MyResource.class);
             return resources;
         }
    
         @Override
         public Set<Object> getSingletons() {
             Set<Object> singletons = new HashSet<>();
             try {
                 // Assuming a ServerAdaptor and PluginFactory are available
                 ServerAdaptor serverAdaptor = ...;
                 PluginFactory myPluginFactory = ...;
                 singletons.add(new WasmPluginFeature(serverAdaptor, myPluginFactory));
             } catch (StartException e) {
                 throw new RuntimeException("Failed to initialize WasmPluginFeature", e);
             }
             return singletons;
         }
     }
     
    See Also:
    WasmPlugin, WasmPluginFilter, PluginFactory, ServerAdaptor
    • Constructor Detail

      • WasmPluginFeature

        public WasmPluginFeature​(io.roastedroot.proxywasm.internal.ServerAdaptor httpServer,
                                 PluginFactory... factories)
                          throws StartException
        Constructs a new WasmPluginFeature.
        Parameters:
        httpServer - The ServerAdaptor used to adapt JAX-RS specific request/response objects for the Proxy-Wasm host.
        factories - One or more PluginFactory instances used to create and manage the Proxy-Wasm plugins.
        Throws:
        StartException - If an error occurs during the initialization or startup of the underlying Proxy-Wasm plugins.
      • WasmPluginFeature

        public WasmPluginFeature​(io.roastedroot.proxywasm.internal.ServerAdaptor httpServer,
                                 List<PluginFactory> factories)
                          throws StartException
        Constructs a new WasmPluginFeature with a list of factories.
        Parameters:
        httpServer - The ServerAdaptor used to adapt JAX-RS specific request/response objects for the Proxy-Wasm host.
        factories - A list of PluginFactory instances used to create and manage the Proxy-Wasm plugins.
        Throws:
        StartException - If an error occurs during the initialization or startup of the underlying Proxy-Wasm plugins.