Extension: Difference between Singleton and Describable/Descriptor pattern

265 views
Skip to first unread message

rishabhb...@gmail.com

unread,
Jul 24, 2020, 5:56:41 AM7/24/20
to Jenkins Developers
Hi all, 

In the documentation, it says that for an extension point where "users should be able to configure zero or more instances of some things you define", Describable/Descriptor pattern is preferred over Singleton pattern. 

From a design point of view, which pattern is better when implementing an extension point where one or more instance might try to send the same thing? 

Also, I've seen that mostly the Descriptor pattern has been used with extensions linked to the UI. Is it a necessary condition?

Thanks, 
Rishabh Budhouliya

Jesse Glick

unread,
Jul 24, 2020, 8:20:15 AM7/24/20
to Jenkins Dev
An `ExtensionPoint` is implemented by classes marked `@Extension`,
which are singletons contributed by plugins, sometimes known as a
service registry pattern. This is the fundamental mechanism by which
Jenkins plugins add functionality. An admin does not configure the
_set_ of extensions, though a particular extension may have
configurable properties (typically as a `GlobalConfguration`).
Extensions need not have any presence in the UI whatsoever. They are
found via `ExtensionList`.

A `Descriptor` is a special kind of extension which registers an
implementation class of associated `Describable`, sometimes also
serving as a factory. `Describable` instances are defined by an admin
or other user via the GUI or configuration-as-code, use
`@DataBoundConstructor` & `@DataBoundSetter`, are intended to be
persisted using XStream, and are typically values of a property or
elements of a list defined in turn by something else—a job property, a
build step, a piece of global configuration, some other `Describable`,
etc.

I am not sure exactly which documentation you are referring to but
perhaps it needs to be patched.

rishabhb...@gmail.com

unread,
Jul 24, 2020, 9:15:35 AM7/24/20
to Jenkins Developers
Thanks for the explanation.
The documentation I was referring to is: https://wiki.jenkins.io/display/JENKINS/Defining+a+new+extension+point

mike cirioli

unread,
Jul 24, 2020, 10:52:48 AM7/24/20
to jenkin...@googlegroups.com
Thanks for the description Jesse, thats probably the clearest I have seen it explained so far :)
-mike


——

“What makes us unhappy is to want. Yet if we would learn to cut our wants to nothing, the smallest thing we’d get would be a true gift.”
― Carlos Castaneda, Separate Reality: Conversations With Don Juan
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2G1QZtrhWT6LMg%2B_ipnP7UXvnumLLSY5psAS%2B%3DjyTfTw%40mail.gmail.com.

Jesse Glick

unread,
Jul 27, 2020, 12:06:15 PM7/27/20
to Jenkins Dev
On Fri, Jul 24, 2020 at 10:52 AM mike cirioli <mikec...@gmail.com> wrote:
> Thanks for the description Jesse

Sure; want to write up a jenkins.io patch?

Matt Sicker

unread,
Jul 28, 2020, 12:24:21 PM7/28/20
to jenkin...@googlegroups.com
I'd love to see more info about this. I had similar difficulty
understanding the difference back when I was working on the secret
textarea UI widget, and I had wanted to do some research to write a
blog post about it, but that was well over a year ago by now.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2uqO5b4AtriB5GmaduOL4a2RPqBOcyXE87gqRWoKHY9g%40mail.gmail.com.



--
Matt Sicker
Senior Software Engineer, CloudBees
Reply all
Reply to author
Forward
0 new messages