T
- Defines the type of event that will be used by the subclassL
- Defines the type of ListenerInvocations that the subclasses usepublic abstract class AbstractListenerImpl<T,L extends ListenerInvocation<T>> extends Object
CacheManagerNotifierImpl
and
CacheNotifierImpl
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractListenerImpl.AbstractInvocationBuilder |
protected class |
AbstractListenerImpl.ListenerInvocationImpl<A>
Class that encapsulates a valid invocation for a given registered listener - containing a reference to the method
to be invoked as well as the target object.
|
Modifier and Type | Field and Description |
---|---|
protected Executor |
asyncProcessor |
protected Map<Class<? extends Annotation>,List<L>> |
listenersMap |
Constructor and Description |
---|
AbstractListenerImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
canApply(Set<Class<? extends Annotation>> filterAnnotations,
Class<? extends Annotation> annotationClass) |
protected static AggregateCompletionStage<Void> |
composeStageIfNeeded(AggregateCompletionStage<Void> aggregateCompletionStage,
CompletionStage<Void> stage)
If the given stage is null or normally completed returns the provided aggregateCompletionStage as is.
|
protected Set<Class<? extends Annotation>> |
findListenerCallbacks(Object listener) |
protected abstract Map<Class<? extends Annotation>,Class<?>> |
getAllowedMethodAnnotations(Listener l) |
protected List<L> |
getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) |
Set<Object> |
getListeners() |
protected abstract Log |
getLog() |
boolean |
hasListener(Class<? extends Annotation> annotationClass) |
abstract CompletionStage<Void> |
removeListenerAsync(Object listener) |
protected void |
removeListenerFromMaps(Object listener) |
protected Set<L> |
removeListenerInvocation(Class<? extends Annotation> annotation,
Object listener) |
protected abstract void |
resumeIfNeeded(Transaction transaction) |
protected CompletionStage<Void> |
resumeOnCPU(CompletionStage<Void> stage,
Object traceId) |
void |
stop()
Removes all listeners from the notifier
|
protected abstract Transaction |
suspendIfNeeded() |
protected static Listener |
testListenerClassValidity(Class<?> listenerClass)
Tests if a class is properly annotated as a CacheListener and returns the Listener annotation.
|
protected static void |
testListenerMethodValidity(Method m,
Class<?> allowedParameter,
String annotationName)
Tests that a method is a valid listener method, that is that it has a single argument that is assignable to
allowedParameter.
|
protected boolean |
validateAndAddFilterListenerInvocations(Object listener,
AbstractListenerImpl.AbstractInvocationBuilder builder,
Set<Class<? extends Annotation>> filterAnnotations) |
protected boolean |
validateAndAddListenerInvocations(Object listener,
AbstractListenerImpl.AbstractInvocationBuilder builder)
Loops through all valid methods on the object passed in, and caches the relevant methods as
ListenerInvocation for invocation by reflection. |
protected Executor asyncProcessor
protected final Map<Class<? extends Annotation>,List<L extends ListenerInvocation<T>>> listenersMap
public void stop()
protected CompletionStage<Void> resumeOnCPU(CompletionStage<Void> stage, Object traceId)
protected abstract Log getLog()
protected abstract Map<Class<? extends Annotation>,Class<?>> getAllowedMethodAnnotations(Listener l)
public boolean hasListener(Class<? extends Annotation> annotationClass)
protected List<L> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation)
public abstract CompletionStage<Void> removeListenerAsync(Object listener)
protected static AggregateCompletionStage<Void> composeStageIfNeeded(AggregateCompletionStage<Void> aggregateCompletionStage, CompletionStage<Void> stage)
aggregateCompletionStage
- the existing composed stage or nullstage
- the stage to rely uponprotected void removeListenerFromMaps(Object listener)
protected Set<L> removeListenerInvocation(Class<? extends Annotation> annotation, Object listener)
protected boolean validateAndAddListenerInvocations(Object listener, AbstractListenerImpl.AbstractInvocationBuilder builder)
ListenerInvocation
for invocation by reflection.
The builder provided will be used to create the listener invocations. This method will set the target, subject
sync, and methods as needed. If other values are needed to be set they should be invoked before passing to this method.listener
- object to be considered as a listener.builder
- The builder to use to build the invocationtrue
if annotated listener methods were found or false
otherwiseprotected boolean validateAndAddFilterListenerInvocations(Object listener, AbstractListenerImpl.AbstractInvocationBuilder builder, Set<Class<? extends Annotation>> filterAnnotations)
public boolean canApply(Set<Class<? extends Annotation>> filterAnnotations, Class<? extends Annotation> annotationClass)
protected Set<Class<? extends Annotation>> findListenerCallbacks(Object listener)
protected static Listener testListenerClassValidity(Class<?> listenerClass)
listenerClass
- class to inspectprotected static void testListenerMethodValidity(Method m, Class<?> allowedParameter, String annotationName)
m
- method to testallowedParameter
- what parameter is allowed for the method argumentannotationName
- name of the annotationIncorrectListenerException
- if the listener is not a valid targetprotected abstract Transaction suspendIfNeeded()
protected abstract void resumeIfNeeded(Transaction transaction)
Copyright © 2021 JBoss by Red Hat. All rights reserved.