XDoclet vs. JSR 175
Rob Kischuk has a post where he describes what a Struts Action might look like using JSR 175 annotations.
@StrutsAction( @ActionMappings({ @ActionMapping( path="index" @ActionForwards({ @ActionForward( name="success" path="index.jsp" ) @ActionForward( name="failure" path="error.jsp" ) }) ) }) ) public class IndexAction extends Action {
As I read it, I though - "holy crap is that ugly!" Isn't the XDoclet version a bit cleaner?
* @struts.action path="index" * @struts.action-forward name="success" path="index.jsp" * @struts.action-forward name="failure" path="error.jsp"
I'll admit, I don't know much about JSR 175, except that it is designed to replace XDoclet. However, I don't believe that it will generate code like XDoclet does - but rather it will allow your Java code to describe metadata using doclet tags. So what good does that do? Does this mean all my metadata and configuration stuff is hard-coded into my source? With XDoclet, I realize that a lot of this stuff is hard-coded into my source, but at least I can change things by changing an ant property and rebuilding - or changing the generated XML files. Why is JSR 175 better than XDoclet? I guess I just don't see the beauty of it. More typing and uglier javadocs aren't that appealing to me.
At least one advantage is that Annotations have a lower barrier to entry than XDoclet. I think many developers find it intimidating that they have to download XDoclet, get it configured in their build script, make sure the generated code is being merged correctly, etc. (Granted, you only have to do this once.) With annotations, frameworks can be built with support for metadata right out of the box.
Posted by Rob Kischuk on May 19, 2004 at 06:15 PM MDT #
Posted by Damien Bonvillain on May 19, 2004 at 09:56 PM MDT #
Posted by Unknown on May 20, 2004 at 12:48 AM MDT #
Posted by gerryg on May 20, 2004 at 09:45 PM MDT #
The JSR 175 syntax is different than the XDoclet version, some would say a bit uglier, but not that it also allows you to express more complex constructs than XDoclet.
So with XDoclet, you use a non-standard syntax to add metadata to your object, generate the mapping from the metadata, package the metadata with your application, and add the class to your Hibernate configuration.
In a theoretical JSR 175 version of Hibernate, you annotate the class you want to persist. No generation or packaging needed. Your metadata follows a standard. The format of your mapping is validated at compile time rather than runtime. You don't need to register your class with Hibernate - the framework can discover persistable classes by reflection.
It is a potential application of JSR 175. I don't know whether it is a good application of it, but it came to mind, so I wanted to explore it more deeply. In many cases, people are using XDoclet because the metadata is best maintained and understood when it is tied closely to the source code. In this case, why not standardize the format of the metadata? In other cases, code generation is the desired end result - it certainly has its place.
Posted by Rob Kischuk on May 21, 2004 at 05:56 PM MDT #
Posted by Seth Ladd on May 21, 2004 at 07:02 PM MDT #
Posted by 161.185.1.100 on September 30, 2005 at 08:28 PM MDT #