Class EventListenerUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<EventListener>
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 aTreeSet
as its comparator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends SshdEventListener>
TproxyWrapper
(Class<T> listenerType, ClassLoader loader, Iterable<? extends T> listeners) Provides proxy wrapper around anIterable
container of listener interface implementation.static <T extends SshdEventListener>
TproxyWrapper
(Class<T> listenerType, Iterable<? extends T> listeners) Provides proxy wrapper around anIterable
container of listener interface implementation.static <L extends SshdEventListener>
Set<L>static <L extends SshdEventListener>
Set<L>synchronizedListenersSet
(Collection<? extends L> listeners)
-
Field Details
-
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 aTreeSet
as its comparator
-
-
Constructor Details
-
EventListenerUtils
private EventListenerUtils()
-
-
Method Details
-
synchronizedListenersSet
public static <L extends SshdEventListener> Set<L> synchronizedListenersSet(Collection<? extends L> listeners) - Type Parameters:
L
- Type ofSshdEventListener
contained in the set- Parameters:
listeners
- The listeners to pre-add to the create set - ignored if (@code null}/empty- Returns:
- A (synchronized)
Set
for containing the listeners ensuring that if same listener instance is added repeatedly only one instance is actually contained
-
synchronizedListenersSet
- Type Parameters:
L
- Type ofSshdEventListener
contained in the set- Returns:
- A (synchronized)
Set
for containing the listeners ensuring that if same listener instance is added repeatedly only one instance is actually contained - See Also:
-
proxyWrapper
public static <T extends SshdEventListener> T proxyWrapper(Class<T> listenerType, Iterable<? extends T> listeners) Provides proxy wrapper around anIterable
container of listener interface implementation. Note: a listener interface is one whose invoked methods return onlyvoid
.- Type Parameters:
T
- Generic listener type- Parameters:
listenerType
- The expected listener interfacelisteners
- AnIterable
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
-
- Returns:
- A proxy wrapper implementing the same interface, but delegating the calls to the container
- See Also:
-
proxyWrapper
public static <T extends SshdEventListener> T proxyWrapper(Class<T> listenerType, ClassLoader loader, Iterable<? extends T> listeners) Provides proxy wrapper around anIterable
container of listener interface implementation. Note: a listener interface is one whose invoked methods return onlyvoid
.- Type Parameters:
T
- GenericSshdEventListener
type- Parameters:
listenerType
- The expected listener interfaceloader
- TheClassLoader
to use for the proxylisteners
- AnIterable
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
-
- Returns:
- A proxy wrapper implementing the same interface, but delegating the calls to the container
- Throws:
IllegalArgumentException
- if listenerType is not an interface or anull
container has been provided- See Also:
-