Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 506 invoked from network); 3 Oct 2009 20:32:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Oct 2009 20:32:47 -0000 Received: (qmail 72790 invoked by uid 500); 3 Oct 2009 20:32:47 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 72646 invoked by uid 500); 3 Oct 2009 20:32:46 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 72636 invoked by uid 99); 3 Oct 2009 20:32:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Oct 2009 20:32:46 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of simone.tripodi@gmail.com designates 209.85.219.213 as permitted sender) Received: from [209.85.219.213] (HELO mail-ew0-f213.google.com) (209.85.219.213) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Oct 2009 20:32:37 +0000 Received: by ewy9 with SMTP id 9so1699130ewy.25 for ; Sat, 03 Oct 2009 13:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=rXSXPaEbVHOD2xo32WzMDlcylTd4g9kMscHkUJJKAVo=; b=UYLM6nBJlzY9A9V+Lrrq5Or6HcClNS1HN67uXp0S4MDhPwnmC2NBNHk4jBTDKHtPc2 40eHqbUmnMmbr9MrDxjQSBxqGu/aOTWuYT1uiJTLZqb5+HYWByxonX+gX8BXZljKRRRi pJyHdqlWWLGl0VRGe4RUX2tZlgoCO1Xrn9lpo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=SF2WxYZSigvIA1xnZ8Us3dwLVgEiip5F/yiotHYpHZ9ni+VeoGh3ksKUVRss0ZcGpr bhdF46NZe2romGmMCkmBNmaoxGTqDWEEpbeh3sMxwmgyN1Bw8XCuN0qF1zZBOI/ydOJu YfsYot53w/PREtoO37BLFuFPRX9xJMgyaCBE4= MIME-Version: 1.0 Received: by 10.211.126.15 with SMTP id d15mr1291116ebn.19.1254601937105; Sat, 03 Oct 2009 13:32:17 -0700 (PDT) Date: Sat, 3 Oct 2009 22:32:17 +0200 Message-ID: <4173dc210910031332l434808cbke4635f486ab060b4@mail.gmail.com> Subject: [digester] extension annottaion proposal From: Simone Tripodi To: Commons Developers List Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hi all commons folks!!! I've been happily using the digester package since the 1.6 release, I found it very easy to use and absolutely one of the best way to parse quickly XML documents and mapping them to Java objects :) Even if using the XML rule declaration, or coding Digester rules, is absolutely very very easy, times ago I started implementing as a PoC [1], in my spare time, a facility tool able to create Digester instances automatically... taking inspiration by Google-Guice and JPA's annotations, I wonder: "why can't we generate the Digester's Rules through Java5 annotations?" What I realized in my mind was the phrase "Basically, the Digester package lets you configure an XML -> Java object mapping module, which triggers certain actions called rules whenever a particular pattern of nested XML elements is recognized." So, my idea is: simply given an Annotated Class, we wanted to inspect it, and extract all the needed to generate the rules - in this way, we could save time writing the rules manually and reduce the errors while binding properties and methods'name, arguments etc, etc. I mean, for example, given the following XML snippet [...] action org.apache.struts.action.ActionServlet application org.apache.struts.example.ApplicationResources config /WEB-INF/struts-config.xml [...] has to be mapped to the following object @ObjectCreate("web-app/servlet") public final class ServletBean { @BeanPropertySetter("web-app/servlet/servlet-name") private String servletName; @BeanPropertySetter("web-app/servlet/servlet-class") private String servletClass; private final Map initParams = new HashMap(); public String getServletName() { return this.servletName; } public void setServletName(String servletName) { this.servletName = servletName; } public String getServletClass() { return this.servletClass; } public void setServletClass(String servletClass) { this.servletClass = servletClass; } @CallMethod("web-app/servlet/init-param") public void addInitParam(@CallParam("web-app/servlet/init-param/param-name") String name, @CallParam("web-app/servlet/init-param/param-value") String value) { this.initParams.put(name, value); } [...] } and a special DigesterLoader is able to create Digester rules simply by analizing the ServletBean class: Digester digester = DigesterLoader.createDigester(ServletBean.class); And that's all! While publishing this work on the Web (already licensed under the Apache 2.0 License) I wonder whether or not the Apache Community might be interested on this... would this be of interested to the community? is there anybody else out there in the community worked on something similar? I would more than happy to collaborate and find a way to merge the work into a bigger project eventually. I aim to achieve a mature version of the project quicker and better; and ultimately after submitting the proposal to the Commons Commettee as Digester extension we would like to find ways grow the work in an official module of the distribution or a sub-project. Last, I would personally be really happy to contribute to the ASF in any way and maintain the above work if necessary. Thanks in advance, best regards!!! Simone Tripodi [1] http://code.google.com/p/digester-annotations/ -- http://www.google.com/profiles/simone.tripodi --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org