|
From: Chris N. <C.N...@AB...> - 2007-01-30 16:35:40
|
I've been working on an Annotation-based Spring Configuration solution which I'd be happy to donate to the Spring project, so I wanted to determine whether there is any interest?=20 Such initiatives seem to have received a cool reception in the past, e.g.=20 http://opensource.atlassian.com/projects/spring/browse/SPR-1987?page=3Dal= l .=20 I'm an Architect working with a mainly junior development team, and when we first started using Spring we quickly came across the problem of keeping the XML configuration files in step with the code. As we were already using XDoclet for J2EE configuration, we moved to using that for Spring configuration as well. It has served us as a very good solution for a couple of years now.=20 We're now looking to move to Spring 2.x and Java 5, and it makes great sense for us to use type-safe Annotations instead of XDoclet (which seems to be a dying project). I've put together a prototype that allows for custom (e.g. user-defined) annotations to be used (so no dependency on Spring code is introduced to the POJOs). The default annotations work as follows:=20 @Bean(id=3D"createNewPerson")=20 @BaseProperties({=20 =20 @Property(name=3D"formView", value=3D"createPerson"),=20 =20 @Property(name=3D"successView", value=3D"createSucceeded") })=20 public class CreateNewPersonController extends SimpleFormController {=20 =20 @Property(ref=3D"personService")=20 =20 public void setPersonService(PersonService service) {=20 =20 ...=20 =20 }=20 }=20 Properties can be configured by annotating the setter method, base-class properties can be added to the class declaration, and so on. I'm working on fleshing out support for all Spring features. I'd be happy for the shape of these default annotations to be further discussed.=20 All this is enabled via adding one class (a BeanFactoryPostProcessor) to the XML configuration. XML and Annotation-based configuration can be mixed without restriction - typically just the abtract and "plumbing" bean configuration is required in XML.=20 Please let me know if this is of interest. I would imagine it would be a useful feature for all existing XDoclet users? =20 (PS. All code has been written on my own time and has no relation with my employer) =20 Chris Nappin. =20 CONFIDENTIALITY NOTICE This e-mail is confidential to the addressee. It may also be privileged. = Neither the confidentiality nor any privilege attaching to this e-mail is= =20waived lost or destroyed by reason that it has been mistakenly transmi= tted to a person or entity other than the addressee. If you are not the a= ddressee please notify us immediately by telephone or fax at the numbers = provided above or e-mail by Reply To Author and return the printed e-mail= =20to us by post at our expense. We believe, but do not warrant, that thi= s e-mail and any attachments are virus-free, but you should check. We may= =20monitor traffic data of both business and personal e-mails. We are not= =20liable for any opinions expressed by the sender where this is a non-bu= siness e-mail. If you do not receive all the message, or if you have diff= iculty with the transmission, please telephone us immediately. ABM United Kingdom Ltd Registered in England & Wales, number 03319098 Registered Office: Peterbridge House, 3 The Lakes, Northampton, UK. NN4 &= HB ABM America Inc Registered in Delaware, number 03174068 Registered Office: 1220 N Market Street, Wilmington, Delaware, USA. 19801= |