DescriptorImpl which is not public static inside the parent class

25 views
Skip to first unread message

tzach....@gmail.com

unread,
Nov 7, 2023, 10:31:43 AM11/7/23
to Jenkins Developers
Hi,

I could not find the answer so sorry for asking something that might have been answered already but, can I create a class which will function as DescriptorImpl but not reside inside the parent class as public static class?

Thanks,
Tzach

Basil Crow

unread,
Nov 7, 2023, 1:36:42 PM11/7/23
to jenkin...@googlegroups.com
On Tue, Nov 7, 2023 at 7:31 AM tzach....@gmail.com
<tzach....@gmail.com> wrote:
>
> can I create a class which will function as DescriptorImpl but not reside inside the parent class as public static class?

What problem are you trying to solve that leads you to this question?

tzach solomon

unread,
Nov 8, 2023, 2:42:48 PM11/8/23
to jenkin...@googlegroups.com
From my experience (and I understand it's only me), it is hard to maintain multiple static classes over the years and I would like to make it as easy as possible.
For example, in "io.jenkins.plugins.designlibrary.Select.java", there are multiple static classes and the class kind of loses the single responsibility principle.

So my question is it a must that the DescriptorImpl reside in the same class and as static?

Thanks in advance,
Tzach


--
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/CAFwNDjqzroXLwof3PHfqiZeiKu1%3D5fyMK4bG49tSYqQkLZJ1vQ%40mail.gmail.com.

Winter, Markus

unread,
Nov 8, 2023, 3:10:18 PM11/8/23
to jenkin...@googlegroups.com

Yes, this is possible. See

https://github.com/jenkinsci/plot-plugin/blob/7e7504adc1f710a384af9961ea3940ab2ed11657/src/main/java/hudson/plugins/plot/PlotDescriptor.java

What can be seen frequently is that there is an abstract Descriptor implementation for extension points in a separate class, but the actual extensions have the descriptor as static inner class.

I think the reason why the descriptor implementation is usually a static inner class is because there is a tight relation between them. And quite often the descriptor contains few methods.

 

From: jenkin...@googlegroups.com <jenkin...@googlegroups.com> On Behalf Of tzach solomon
Sent: Mittwoch, 8. November 2023 20:43
To: jenkin...@googlegroups.com
Subject: Re: DescriptorImpl which is not public static inside the parent class

 

You don't often get email from tzach....@gmail.com. Learn why this is important

tzach solomon

unread,
Nov 8, 2023, 4:25:07 PM11/8/23
to jenkin...@googlegroups.com
Big thanks Markus, this really helps me understand the relation between the Descriptor and the class it is describing! 
And also the config.jelly placement :)

Reply all
Reply to author
Forward
0 new messages