public final class RunOnceInvocationInstrumenter extends Object implements InvocationInstrumenter
InvocationInstrumenter
to protect against multiple chained invocations.NOOP
Modifier and Type | Method and Description |
---|---|
void |
afterInvocation(boolean cleanup)
After call.
|
void |
beforeInvocation()
Before call.
|
static InvocationInstrumenter |
create(io.micronaut.reactive.rxjava2.RxInstrumenterFactory factory)
Creates a new
InvocationInstrumenter with the given factory and wraps it immediately. |
Instrumentation |
newInstrumentation() |
static InvocationInstrumenter |
wrap(InvocationInstrumenter instrumenter)
Wraps the given instrumenter if necessary to guarantee that it will only instrument once if it gets called
multiple times in a chain.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterInvocation, combine, instrument, instrument, instrument, instrument, instrument
@NonNull public Instrumentation newInstrumentation()
newInstrumentation
in interface InvocationInstrumenter
Instrumentation
instance which to be used in a try-with-resources to do the
instrumentation. When using this approach InvocationInstrumenter.beforeInvocation()
will already be invoked by the time
this method invocation returns. Instrumentation.close()
will by default invoke InvocationInstrumenter.afterInvocation()
without cleanup. To force cleanup invoke Instrumentation.forceCleanup()
on the retuned instance.public void beforeInvocation()
InvocationInstrumenter
beforeInvocation
in interface InvocationInstrumenter
public void afterInvocation(boolean cleanup)
InvocationInstrumenter
afterInvocation
in interface InvocationInstrumenter
cleanup
- Whether to enforce cleanup@NonNull public static InvocationInstrumenter create(@NonNull io.micronaut.reactive.rxjava2.RxInstrumenterFactory factory)
InvocationInstrumenter
with the given factory
and wraps it immediately.
Equivalent to: wrap(factory.create())
factory
- The instrumenter factory to create instrumenter with.@NonNull public static InvocationInstrumenter wrap(@Nullable InvocationInstrumenter instrumenter)
InvocationInstrumenter delegate = ...; InvocationInstrumenter onlyOnce = RunOnceInvocationInstrumenter.wrap(delegate); try (Instrumentation outer = onlyOnce.newInstrumentation()) { try (Instrumentation inner = onlyOnce.newInstrumentation()) { ... } }will only invoke
delegate.beforeInvocation()
and delegate.afterInvocation()
once.instrumenter
- The instrumenter to protect against multiple chained invocations.