Package io.roastedroot.proxywasm
Interface PluginFactory
-
public interface PluginFactory
A functional interface representing a factory for creatingPlugin
instances.This is typically used in scenarios where plugin instantiation needs to be deferred or customized, potentially based on configuration or context available at runtime. Implementations might handle loading WASM modules, configuring builders, and returning the ready-to-use plugin.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
PluginFactory.Builder
Builder for creating a PluginFactory instance that can create Plugin instances with pre-configured settings.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static PluginFactory.Builder
builder(WasmModule module)
Creates a newPluginFactory.Builder
to configure and construct aPluginFactory
instance from the given WASM module.Plugin
create()
Creates and returns a newPlugin
instance.String
name()
Returns the configured name of the plugin.boolean
shared()
Indicates whether this plugin instance is shared across multiple contexts or requests.
-
-
-
Method Detail
-
create
Plugin create() throws Exception
Creates and returns a newPlugin
instance. Implementations are responsible for all necessary setup, including potentially loading the WASM module and configuring it usingbuilder(com.dylibso.chicory.wasm.WasmModule)
.
-
name
String name()
Returns the configured name of the plugin.- Returns:
- the plugin name.
-
shared
boolean shared()
Indicates whether this plugin instance is shared across multiple contexts or requests.If
true
, the plugin will be instantiated once and reused, allowing it to maintain state between requests but potentially introducing contention. Iffalse
, a new instance will be created for each request or context, providing better isolation but consuming more memory.- Returns:
true
if the plugin instance is shared,false
otherwise.
-
builder
static PluginFactory.Builder builder(WasmModule module)
Creates a newPluginFactory.Builder
to configure and construct aPluginFactory
instance from the given WASM module.- Parameters:
module
- the compiledWasmModule
representing the plugin's code.- Returns:
- a new
PluginFactory.Builder
instance.
-
-