Hi Simone,
I like your idea too.
From me a +1 for creating the lab.
I do agree with Christian comment that commons sandbox can be a good
place for this work as well, but I think that a lab can work well too,
moving to commons if/when the code is complete as you proposed.
Simone
Simone Tripodi wrote:
Hi all guys - and happy new year!
As a new ASF committer and Cocoon3 PMC member, I propose the creation
of a new Apache Lab, called "@Digester"
@Digester
The Apache commons-digester[1] is a great, light and fast XML parser;
it works with the SAX APIs and provides a serie of facilities to map
XML to POJOs.
It's configurable in the following ways:
* instancing and registering digester's rules into the digester;
* using the shorthand registration methods
* XML digester rules.
Even if these methods are excellent, they are limited - if Java
objects are due to be changed quickly, all previous methods need to be
extended/modified.
Inspired by the basic idea behind the JPA, JAXB's specifications, the
digester-annotations package would add some facilities to configure
the
commons-digester using the Java5 language metadata annotations
support, it means creating the digester ruleset introspecting the
target POJOs, using a provided set of annotations. Using the annotated
Java object it's possible to create, in runtime the digester parser,
avoiding manual updates.
I mean, for example, given the following XML snippet
<web-app>
[...]
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>org.apache.struts.example.ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
</servlet>
[...]
</web-app>
@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<String, String> initParams = new HashMap<String,
String>();
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);
Of course, this approach has limitations too - i.e. it doesn't work
with 3rd part developed objects - but the combined use of the
different approaches should reduce the manually produced code.
Current status of code:
I've already done almoust the 80% of code on google-code[2] licensed
under ASF2 license and also submitted a deprecable patch[3] on
commons-digester Jira: I would like to set up the lab, removing the
project on google-code, deprecate the patch and complete the work in
the lab, then re-propose to commons-digester community the new
feature.
What do you think about it? I really hope you'll find this new way of
parsing XML interesting like I do :P
Thanks in advance, best regards!!!
Simone Tripodi
[1] http://commons.apache.org/digester/
[2] http://code.google.com/p/digester-annotations/source/browse/
[3] https://issues.apache.org/jira/browse/DIGESTER-135
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: labs-unsubscr...@labs.apache.org
For additional commands, e-mail: labs-h...@labs.apache.org
--
Simone Gianni CEO Semeru s.r.l. Apache Committer
http://www.simonegianni.it/
---------------------------------------------------------------------
To unsubscribe, e-mail: labs-unsubscr...@labs.apache.org
For additional commands, e-mail: labs-h...@labs.apache.org