How to make Spring accept fluent (non-void) setters?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-05-24T23:54:33Z Indexed on 2010/05/25 2:51 UTC
Read the original article Hit count: 344

Filed under:
|
|

Hi,

I have an API which I am turning into an internal DSL. As such, most methods in my PoJos return a reference to this so that I can chain methods together declaratively as such (syntactic sugar).

myComponent
    .setID("MyId")
    .setProperty("One")
    .setProperty2("Two")
    .setAssociation(anotherComponent)
    .execute();

My API does not depend on Spring but I wish to make it 'Spring-Friendly' by being PoJo friendly with zero argument constructors, getters and setters. The problem is that Spring seems to not detect my setter methods when I have a non-void return type.

The return type of this is very convenient when chaining together my commands so I don't want to destroy my programmatic API just be to compatible with Spring injection.

Is there a setting in Spring to allow me to use non-void setters?

Chris

© Stack Overflow or respective owner

Related posts about java

Related posts about spring