@API(status=EXPERIMENTAL,
since="1.10")
public interface LauncherInterceptor
Launcher in the
context of a LauncherSession.
Interceptors are instantiated once per LauncherSession and closed
after the session is closed. They can
intercept the following invocations:
LauncherSessionListener instances registered via the
ServiceLoader mechanism
Launcher instances
Launcher.discover(LauncherDiscoveryRequest),
Launcher.execute(TestPlan, TestExecutionListener...), and
Launcher.execute(LauncherDiscoveryRequest, TestExecutionListener...)
Implementations of this interface can be registered via the
ServiceLoader mechanism by additionally
setting the
configuration parameter to true.
A typical use case is to create a custom ClassLoader in the
constructor of the implementing class, replace the
contextClassLoader of the
current thread while intercepting invocations,
and close the custom ClassLoader in close()
Launcher,
LauncherSession,
LauncherConstants.ENABLE_LAUNCHER_INTERCEPTORS| Modifier and Type | Interface and Description |
|---|---|
static interface |
LauncherInterceptor.Invocation<T>
An invocation that can be intercepted.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this interceptor.
|
<T> T |
intercept(LauncherInterceptor.Invocation<T> invocation)
Intercept the supplied invocation.
|
<T> T intercept(LauncherInterceptor.Invocation<T> invocation)
Implementations must call LauncherInterceptor.Invocation.proceed() exactly once.
invocation - the intercepted invocation; never nullvoid close()
Any resources held by this interceptor should be released by this method.