Class EventListenerUtils
- java.lang.Object
-
- org.apache.sshd.common.util.EventListenerUtils
-
public final class EventListenerUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<java.util.EventListener>LISTENER_INSTANCE_COMPARATORA special "comparator" whose only purpose is to ensure there are no same references in a listener's set - to be used in conjunction with aTreeSetas its comparator
-
Constructor Summary
Constructors Modifier Constructor Description privateEventListenerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends SshdEventListener>
TproxyWrapper(java.lang.Class<T> listenerType, java.lang.ClassLoader loader, java.lang.Iterable<? extends T> listeners)Provides proxy wrapper around anIterablecontainer of listener interface implementation.static <T extends SshdEventListener>
TproxyWrapper(java.lang.Class<T> listenerType, java.lang.Iterable<? extends T> listeners)Provides proxy wrapper around anIterablecontainer of listener interface implementation.static <L extends SshdEventListener>
java.util.Set<L>synchronizedListenersSet()static <L extends SshdEventListener>
java.util.Set<L>synchronizedListenersSet(java.util.Collection<? extends L> listeners)
-
-
-
Field Detail
-
LISTENER_INSTANCE_COMPARATOR
public static final java.util.Comparator<java.util.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 aTreeSetas its comparator
-
-
Method Detail
-
synchronizedListenersSet
public static <L extends SshdEventListener> java.util.Set<L> synchronizedListenersSet(java.util.Collection<? extends L> listeners)
- Type Parameters:
L- Type ofSshdEventListenercontained in the set- Parameters:
listeners- The listeners to pre-add to the create set - ignored if (@code null}/empty- Returns:
- A (synchronized)
Setfor containing the listeners ensuring that if same listener instance is added repeatedly only one instance is actually contained
-
synchronizedListenersSet
public static <L extends SshdEventListener> java.util.Set<L> synchronizedListenersSet()
- Type Parameters:
L- Type ofSshdEventListenercontained in the set- Returns:
- A (synchronized)
Setfor containing the listeners ensuring that if same listener instance is added repeatedly only one instance is actually contained - See Also:
LISTENER_INSTANCE_COMPARATOR
-
proxyWrapper
public static <T extends SshdEventListener> T proxyWrapper(java.lang.Class<T> listenerType, java.lang.Iterable<? extends T> listeners)
Provides proxy wrapper around anIterablecontainer 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- AnIterablecontainer of listeners to be invoked.Note(s):
The invocation order is same as the
IterablecontainerIf 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(Class, ClassLoader, Iterable)
-
proxyWrapper
public static <T extends SshdEventListener> T proxyWrapper(java.lang.Class<T> listenerType, java.lang.ClassLoader loader, java.lang.Iterable<? extends T> listeners)
Provides proxy wrapper around anIterablecontainer of listener interface implementation. Note: a listener interface is one whose invoked methods return onlyvoid.- Type Parameters:
T- GenericSshdEventListenertype- Parameters:
listenerType- The expected listener interfaceloader- TheClassLoaderto use for the proxylisteners- AnIterablecontainer of listeners to be invoked.Note(s):
The invocation order is same as the
IterablecontainerIf 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:
java.lang.IllegalArgumentException- if listenerType is not an interface or anullcontainer has been provided- See Also:
proxyWrapper(Class, ClassLoader, Iterable)
-
-