Yeah !!! +1000. Thx for this improvement. — Sent from Mailbox for iPhone
On Fri, Oct 4, 2013 at 1:46 AM, Kohsuke Kawaguchi <[email protected]> wrote: > Today, many complex plugins suffer from a massive constructor annotated > with @DataBoundConstructor. > This is because the form data-binding requires that all the parameters > passed in through the constructor. See xcode plugin [1] for an example of > this. The situation was worse with plugins that are used by other plugins, > which needed to preserve ever-increasing list of constructors to remain > backward compatible. > Starting Jenkins 1.535, this problem is no more. Stapler can not only look > for @DataBoundConstructor, but it'll also perform setter injection on > methods annotated with @DataBoundSetter. > So whereas you had to write: > class Foo { > int a,b,c,d; > @DataBoundConstructor > public Foo(int a, int b, int c, int d) { > this.a = a; > this.b = b; > this.c = c; > this.d = d; > } > } > You can now write: > class Foo { > int a,b,c,d; > @DataBoundConstructor > public Foo(int a, int b) { > this.a = a; > this.b = b; > } > @DataBoundSetter > public void setC(int c) { this.c = c; } > @DataBoundSetter > public void setD(int d) { this.d = d; } > } > Or even: > class Foo { > int a,b,c,d; > @DataBoundConstructor > public Foo() {} > @DataBoundSetter > public void setA(int a) { this.a = a; } > @DataBoundSetter > public void setC(int b) { this.b = b; } > @DataBoundSetter > public void setC(int c) { this.c = c; } > @DataBoundSetter > public void setD(int d) { this.d = d; } > } > This will make it easier to evolve plugins that have a large number of > configuration options. > [1] > https://github.com/jenkinsci/xcode-plugin/blob/master/src/main/java/au/com/rayh/XCodeBuilder.java#L165 > -- > Kohsuke Kawaguchi > -- > 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 [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
