API
- Parameterized Plugin API type, ie. the type the Application will use.
public interface Plugin<API>
A Plugin is activated/passivated alongside the Application, can contribute Routes to it, is given a change to hook around interactions and can depend on other plugins.
Plugins should not create static state and their instanciation should be as close to NOOP as possible.
Modifier and Type | Interface and Description |
---|---|
static class |
Plugin.Void
Void Plugin exposing no type to the Application.
|
Modifier and Type | Method and Description |
---|---|
default void |
afterInteraction(Context context)
Invoked after each HTTP Interaction.
|
API |
api()
Plugin API.
|
Class<API> |
apiType()
Plugin API type.
|
default void |
beforeInteraction(Context context)
Invoked before each HTTP Interaction.
|
default List<Class<?>> |
dependencies(Config config)
Plugin dependencies.
|
default List<Route> |
firstRoutes(Mode mode, RouteBuilder routeBuilder)
Routes to prepend to the Application routes.
|
default List<Route> |
lastRoutes(Mode mode, RouteBuilder routeBuilder)
Routes to append to the Application routes.
|
default void |
onActivate(Application application)
Invoked on Application activation.
|
default void |
onPassivate(Application application)
Invoked on Application passivation.
|
API api()
Application
to use
default List<Class<?>> dependencies(Config config)
The runtime will use this information to order the plugins activation order according to the dependency graph.
Defaults to an empty list.
Application configuration is provided to the plugin so it can decide on what to depend according to its own configuration.
config
- Application configuration
default void onActivate(Application application) throws ActivationException
Defaults to no operation.
application
- Application
ActivationException
- if something goes wrong.
default List<Route> firstRoutes(Mode mode, RouteBuilder routeBuilder)
Defaults to no Route.
Called by Application once activated.
mode
- Application Mode
routeBuilder
- Builder for Routes
default List<Route> lastRoutes(Mode mode, RouteBuilder routeBuilder)
Defaults to no Route.
Called by Application once activated.
mode
- Application Mode
routeBuilder
- Builder for Routes
default void onPassivate(Application application)
Defaults to no operation.
application
- Application
default void beforeInteraction(Context context)
Defaults to no operation.
context
- Interaction Context
default void afterInteraction(Context context)
Defaults to no operation.
context
- Interaction Context