Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

XDoclet Extensibility...

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've worked with many home made "code generators" at various companies, and a common problem that I see time and time again, is that once the code has been generated, it is often tweaked for further changes meaning that it can no longer be regenerated.
This in conjunction with the fact that the generators create about 90% of what you want, generally mean it's a one off helper for the initial create.
So my question is, does XDoclet provide a mechanism to allow custom code to be added and preserved upon further generation?
Thanks in advance for any info.
Dave.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dave Hewy:
So my question is, does XDoclet provide a mechanism to allow custom code to be added and preserved upon further generation?


XDoclet provides what are called "merge points" in the various templates. These are places in the template that include another custom template. The included template is named based on the type of object being generated or the class, depending on the particular merge point. As well, the templates are simply text files packaged into the various XDoclet JARs, and there is a mechanism to use your own templates instead.
Finally, all generated files get token-replacement treatment, so you can include regular Ant properties in your source code and have the values replaced at build time.
So far this has worked quite well for me. I've used XDoclet to build a medium-sized EJB project (30 or so entity, session and message-driven beans), and another developer here that converted to using XDoclet has been quite pleased too.
 
Author
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XDoclet is an "active" code generation system and is meant to be run at every build as part of a normal ant based build. The generated files should NOT be checked into your revision control system and shouldn't be kept around for editing.
As David pointed out, the normal ways of tweaking XDoclet (besides the javadoc metadata) is through merge points (inserting/tweaking sections of the generated code) or (as a last resort) editting the template. Both of these are essentially data input to code generator, which is always run for each build.
 
reply
    Bookmark Topic Watch Topic
  • New Topic