public final class EventListenerUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Comparator<EventListener> |
LISTENER_INSTANCE_COMPARATOR
A special "comparator" whose only purpose is to ensure there are no same references in a listener's set
- to be used in conjunction with a
TreeSet as its comparator |
Modifier and Type | Method and Description |
---|---|
static <T extends SshdEventListener> |
proxyWrapper(Class<T> listenerType,
ClassLoader loader,
Iterable<? extends T> listeners)
Provides proxy wrapper around an
Iterable container of listener interface implementation. |
static <T extends SshdEventListener> |
proxyWrapper(Class<T> listenerType,
Iterable<? extends T> listeners)
Provides proxy wrapper around an
Iterable container of listener interface implementation. |
static <L extends SshdEventListener> |
synchronizedListenersSet() |
static <L extends SshdEventListener> |
synchronizedListenersSet(Collection<? extends L> listeners) |
public static final Comparator<EventListener> LISTENER_INSTANCE_COMPARATOR
TreeSet
as its comparatorpublic static <L extends SshdEventListener> Set<L> synchronizedListenersSet(Collection<? extends L> listeners)
L
- Type of SshdEventListener
contained in the setlisteners
- The listeners to pre-add to the create set - ignored if (@code null}/emptySet
for containing the listeners ensuring that if same listener
instance is added repeatedly only one instance is actually containedpublic static <L extends SshdEventListener> Set<L> synchronizedListenersSet()
L
- Type of SshdEventListener
contained in the setSet
for containing the listeners ensuring that if same listener instance is
added repeatedly only one instance is actually containedLISTENER_INSTANCE_COMPARATOR
public static <T extends SshdEventListener> T proxyWrapper(Class<T> listenerType, Iterable<? extends T> listeners)
Iterable
container of listener interface implementation. Note: a
listener interface is one whose invoked methods return only void
.T
- Generic listener typelistenerType
- The expected listener interfacelisteners
- An Iterable
container of listeners to be invoked.
Note(s):
The invocation order is same as the Iterable
container
If any of the invoked listener methods throws an exception, the rest of the listener are not invoked and the exception is propagated to the caller
It is up to the caller to ensure that the container does not change while the proxy is invoked
proxyWrapper(Class, ClassLoader, Iterable)
public static <T extends SshdEventListener> T proxyWrapper(Class<T> listenerType, ClassLoader loader, Iterable<? extends T> listeners)
Iterable
container of listener interface implementation. Note: a
listener interface is one whose invoked methods return only void
.T
- Generic SshdEventListener
typelistenerType
- The expected listener interfaceloader
- The ClassLoader
to use for the proxylisteners
- An Iterable
container of listeners to be invoked.
Note(s):
The invocation order is same as the Iterable
container
If any of the invoked listener methods throws an exception, the rest of the listener are not invoked and the exception is propagated to the caller
It is up to the caller to ensure that the container does not change while the proxy is invoked
IllegalArgumentException
- if listenerType is not an interface or a null
container has
been providedproxyWrapper(Class, ClassLoader, Iterable)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.