jenkinsci/jenkins-plugin-runtime.rb — pull request #2 by kohsuke (2012-01-01 01:00:24+00:00)
Title: More stream-lined approach to wrap extension points

Jenkins defines two kinds of extension points. One is for thing like Builder and Publisher, where we get a lot of instances created and retained in a single JVM. This is `Descriptor` and `Describable` and we've already got a proven mechanism to define more wrappers.

The other kind, which is actually more fundamental, is a mechanism for Jenkins to discover singleton instances that are the extension points, such as `EnvironmentContributor`, `RunListener`, and `PageDecorator` (`Descriptor` is actually just one of these, and `Describable` is just a further layer above.)

This pull request adds a mechanism for us to rapidly define such singleton extension points.

The main change is the `ExtensionPoint` module, which is a mix-in that detects subtype implementations, and it'll invoke a callback specified via the `when_implemented` class method. I've added a couple of actual wrappers based on this mechanism (and used them successfuly in the RVM plugin.)

One thing that I couldn't quite figure out was how to modify `Jenkins::Model::Describable` to use `ExtensionPoint` to avoid dupliation of the subtype detection logic. I'll think more about it later.