diff --git a/core/src/main/java/hudson/slaves/ComputerListener.java b/core/src/main/java/hudson/slaves/ComputerListener.java index be4dfd7ae2948f985a06cf7e5ef4550dfe3af5d1..4d31399e93cfe545edee1d8cc68d185f60a51638 100644 --- a/core/src/main/java/hudson/slaves/ComputerListener.java +++ b/core/src/main/java/hudson/slaves/ComputerListener.java @@ -27,6 +27,7 @@ import hudson.model.Computer; import hudson.model.Hudson; import hudson.ExtensionPoint; import hudson.Extension; +import hudson.ExtensionList; /** * Receives notifications about status changes of {@link Computer}s. @@ -52,7 +53,7 @@ public abstract class ComputerListener implements ExtensionPoint { * put {@link Extension} on your class to have it auto-registered. */ public final void register() { - Hudson.getInstance().getExtensionList(ComputerListener.class).add(this); + all().add(this); } /** @@ -62,6 +63,13 @@ public abstract class ComputerListener implements ExtensionPoint { * Unless {@link ComputerListener} is unregistered, it will never be a subject of GC. */ public final boolean unregister() { - return Hudson.getInstance().getExtensionList(ComputerListener.class).remove(this); + return all().remove(this); + } + + /** + * All the registered {@link ComputerListener}s. + */ + public static ExtensionList all() { + return Hudson.getInstance().getExtensionList(ComputerListener.class); } }