Extension: Difference between Singleton and Describable/Descriptor pattern

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Extension: Difference between Singleton and Describable/Descriptor pattern

Rishabh Budhouliya
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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4ad4dc34-36d6-4f87-b28b-9d0858e9c68fn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Extension: Difference between Singleton and Describable/Descriptor pattern

Jesse Glick-4
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2G1QZtrhWT6LMg%2B_ipnP7UXvnumLLSY5psAS%2B%3DjyTfTw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Extension: Difference between Singleton and Describable/Descriptor pattern

Rishabh Budhouliya
Thanks for the explanation.
The documentation I was referring to is: https://wiki.jenkins.io/display/JENKINS/Defining+a+new+extension+point

On Friday, July 24, 2020 at 5:50:15 PM UTC+5:30 Jesse Glick wrote:
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/15bd7fac-f00e-4610-8f43-4282f151e97en%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Extension: Difference between Singleton and Describable/Descriptor pattern

mike cirioli
In reply to this post by Jesse Glick-4
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

> On Jul 24, 2020, at 8:19 AM, Jesse Glick <[hidden email]> wrote:
>
> 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.
>
> --
> 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 [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2G1QZtrhWT6LMg%2B_ipnP7UXvnumLLSY5psAS%2B%3DjyTfTw%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CFB9E2FA-C8B2-44BE-8E90-DFBED8008F44%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Extension: Difference between Singleton and Describable/Descriptor pattern

Jesse Glick-4
On Fri, Jul 24, 2020 at 10:52 AM mike cirioli <[hidden email]> wrote:
> Thanks for the description Jesse

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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2uqO5b4AtriB5GmaduOL4a2RPqBOcyXE87gqRWoKHY9g%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Extension: Difference between Singleton and Describable/Descriptor pattern

Matt Sicker
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.

On Mon, Jul 27, 2020 at 11:06 AM Jesse Glick <[hidden email]> wrote:

>
> On Fri, Jul 24, 2020 at 10:52 AM mike cirioli <[hidden email]> wrote:
> > Thanks for the description Jesse
>
> Sure; want to write up a jenkins.io patch?
>
> --
> 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 [hidden email].
> 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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAEot4oy-qLRUF%2BhL-UGbyf7_EvF%2BbP%2BgjxTLJOpHq5vLV0H%3DAQ%40mail.gmail.com.