A behavior interceptor allows for intercepting message and signal reception and perform arbitrary logic -
transform, filter, send to a side channel etc. It is the core API for decoration of behaviors. Many built-in
intercepting behaviors are provided through factories in the respective Behaviors.

Constructor Detail

BehaviorInterceptor

Method Detail

interceptMessageType

Allows for applying the interceptor only to certain message types. Useful if the official protocol and the actual
protocol of an actor causes problems, for example class cast exceptions for a message not of type O that
the actor still knows how to deal with. Note that this is only possible to use when O and I are the same type.

Returns:

A subtype of O that should be intercepted or null to intercept all Os.
Subtypes of O matching this are passed directly to the inner behavior without interception.

aroundReceive

Intercept a message sent to the running actor. Pass the message on to the next behavior
in the stack by passing it to target.apply, return Behaviors.same without invoking target
to filter out the message.

isSame

true if this behavior logically the same as another behavior interceptor and can therefore be eliminated
(to avoid building infinitely growing stacks of behaviors)? Default implementation is based on instance
equality. Override to provide use case specific logic.