I have written code that use annotations like the @Stateless etc. I sometimes wonder which to choose when coding-settings in the web cofig xml or would it be better to use annotations sometimes?
I'm tempted to think config xml files are nbetter since they can be changed after the web application has been deployed.
It is true that config files can be changed after a web app has been coded but many config items such as the one you mentioned (@Stateless) are closely tied to the code. If a bean is coded to be used as @Stateless, is there any point in changing its type to @Stateful in the deployment descriptor? It will most probably fail to work as expected. So some configuration items are better specified using annotations while others such as environment properties can be overridden using a DD.
Generically speaking, with the launch of the Servlet specification 3.0, annotations were introduced. Deployment descriptors are still present and they are being used - but the use of annotations is encouraged to enable easier assembly and deployment. Writing huge chunks of DD elements can be cumbersome after a while.
Some elements can be defined by means of deployment descriptor web fragments and the others can be defined by means of annotations
Joined: May 18, 2012
Thanks for the answers Paul and James.
I can really do with this information in the work I do. Most of Java SE is smooth. but issues arise when it comes to J2EE.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Which is better when working with J2EE Beans?