Package jenkins.util
Class Listeners
- java.lang.Object
-
- jenkins.util.Listeners
-
public class Listeners extends Object
Utilities for working with listener interfaces.- Since:
- 2.324
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <L> void
notify(Class<L> listenerType, boolean asSystem, Consumer<L> notification)
Safely send a notification to all listeners of a given type.
-
-
-
Method Detail
-
notify
public static <L> void notify(Class<L> listenerType, boolean asSystem, Consumer<L> notification)
Safely send a notification to all listeners of a given type.Only suitable for listener methods which do not throw checked or otherwise documented exceptions.
- Type Parameters:
L
- the type of listener- Parameters:
listenerType
- the type of listenerasSystem
- whether to impersonateACL.SYSTEM2
. For most listener methods, this should betrue
, so that listener implementations can freely perform various operations without access checks. In some cases, existing listener interfaces were implicitly assumed to pass along user authentication, because they were sometimes triggered by user actions such as configuration changes; this is an antipattern (better to pass an explicitAuthentication
argument if relevant).notification
- a listener method, perhaps with arguments- Since:
- 2.325
-
-