aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes XML based config vs annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "XML based config vs annotations" Watch "XML based config vs annotations" New topic
Author

XML based config vs annotations

Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Howdy Ranchers!

I guess this might be also treated as a more general discussion, but: recently there was a increased number of things you can configure using annotations (i.e. JEE 6), like Servlets, url mappings, etc. The point is, the annotations are compilation-time feature, and XML is run-time.

So, all those unique, decalrative features i.e. runtime servlet mapping url change is vanished...

So, my question is: do you prefer annotations over XML, or the other way around.
Or maybe you have found a golden ratio, like: use XML for things that frequently changes (or are more likely to change) and annotations for more firm configuration.

Thanks in advance for your replies :-)

Cheers!


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Piotr Rzexniczak
Greenhorn

Joined: Jan 26, 2011
Posts: 4

Many of frameworks, libraries and other type project allows you to use both: annotations and xml configuration with the higher priority of xml configuration (I mean xml overrides annotations).
So you can safely use annotations during the development phase and if there is a need to change the configuration, you can do this in additional xml file later without recompiling your code.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

And that sounds like a golden ratio for me.

Thanks Piotr!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: XML based config vs annotations
 
Similar Threads
Persistence unit xml or annotations in EJB3?
advantage of ejb3 :: annotation as against DD
Spring Annotation
Why should I use annotations and what are those?
why the annotaion way