Class NamedEventInterceptorBuilder
- All Implemented Interfaces:
BuilderCustomization<EventInterceptor>
,ParameterizedBuilder<NamedEventInterceptor>
NamedEventInterceptor
, which wraps an EventInterceptor
. The
wrapped EventInterceptor will be constructed based on its instance /
class-scheme XML declaration, honoring any init-params
defined.
The construction of a NamedEventInterceptor allows metadata associated
with the EventInterceptor to be held. This metadata is used to determine
eligibility against EventDispatcher
s and
for registration purposes.
In addition to XML being used as input in defining an EventInterceptor and
its metadata the presence of an annotation (Interceptor
) can also
contribute. This annotation can define the identifier for this interceptor,
the event types to subscribe to and whether to be placed first in the chain
of EventInterceptors (Interceptor.Order.HIGH
.
NamedEventInterceptor objects also use class level generic type definitions as input for configuration. The generic type definition allows EventInterceptor implementations to restrict on event types by narrowing the type definition within the reference to the EventInterceptor interface. For example, the following interceptor restricts to only accept transfer events:
class MyInterceptor
implements EventInterceptor<TransferEvent>
{
public void onEvent(TransferEvent event);
}
The precedence, in highest order first reading left to right, for
configuration is as follows:
XML -> Annotation -> Generic Type Bounds
- Since:
- Coherence 12.1.2
- Author:
- hr 2011.10.05
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tangosol.coherence.config.builder.ParameterizedBuilder
ParameterizedBuilder.ReflectionSupport
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionObtains the customParameterizedBuilder
.getName()
Get the logical name / identifier for thisEventInterceptor
.getOrder()
Return theInterceptor.Order
of this interceptor.Returns the behavior upon duplicate registration.boolean
isFirst()
Whether thisEventInterceptor
should be head of the stack.realize
(ParameterResolver resolver, ClassLoader loader, ParameterList listParameters) Realizes (creates if necessary) an instance of a object of type T, using the providedParameterResolver
to resolve values any referencedParameter
s.void
Sets theParameterizedBuilder
to be used as the alternate builder.Set the logical name / identifier for thisEventInterceptor
.setOrder
(Interceptor.Order order) Set theEventInterceptor
's order (HIGH || LOW), hence whether it should be at the start of the chain of interceptors.setRegistrationBehavior
(RegistrationBehavior behavior) Specifies the behavior upon duplicate registration.toString()
-
Constructor Details
-
NamedEventInterceptorBuilder
public NamedEventInterceptorBuilder()
-
-
Method Details
-
realize
public NamedEventInterceptor realize(ParameterResolver resolver, ClassLoader loader, ParameterList listParameters) Realizes (creates if necessary) an instance of a object of type T, using the providedParameterResolver
to resolve values any referencedParameter
s.- Specified by:
realize
in interfaceParameterizedBuilder<NamedEventInterceptor>
- Parameters:
resolver
- theParameterResolver
for resolving namedParameter
sloader
- theClassLoader
for loading any necessary classes and ifnull
theClassLoader
used to load the builder will be used insteadlistParameters
- an optionalParameterList
(may benull
) to be used for realizing the instance, eg: used as constructor parameters- Returns:
- an instance of T
-
getCustomBuilder
Obtains the customParameterizedBuilder
.- Specified by:
getCustomBuilder
in interfaceBuilderCustomization<EventInterceptor>
- Returns:
- the
ParameterizedBuilder
-
setCustomBuilder
Sets theParameterizedBuilder
to be used as the alternate builder.- Specified by:
setCustomBuilder
in interfaceBuilderCustomization<EventInterceptor>
- Parameters:
bldr
- the ParameterizedBuilder
-
getName
Get the logical name / identifier for thisEventInterceptor
.- Returns:
- the logical name / identifier for this
EventInterceptor
-
setName
Set the logical name / identifier for thisEventInterceptor
.- Parameters:
sName
- logical name / identifier for thisEventInterceptor
.- Returns:
- a reference to
this
builder
-
isFirst
public boolean isFirst()Whether thisEventInterceptor
should be head of the stack.- Returns:
- whether this
EventInterceptor
should be head of the stack
-
getOrder
Return theInterceptor.Order
of this interceptor.- Returns:
- the
Interceptor.Order
of this interceptor
-
setOrder
Set theEventInterceptor
's order (HIGH || LOW), hence whether it should be at the start of the chain of interceptors.- Parameters:
order
- whether thisEventInterceptor
should be head of the stack based on the valuesInterceptor.Order.HIGH
orInterceptor.Order.LOW
- Returns:
- a reference to
this
builder
-
getRegistrationBehavior
Returns the behavior upon duplicate registration.- Returns:
- the behavior upon duplicate registration.
-
setRegistrationBehavior
@Injectable public NamedEventInterceptorBuilder setRegistrationBehavior(RegistrationBehavior behavior) Specifies the behavior upon duplicate registration.- Parameters:
behavior
- the behavior upon duplicate registration- Returns:
- a reference to
this
builder
-
toString
-