Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which is better when working with J2EE Beans?

 
charlsy chuks
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,

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.

Cheers

Charles


































 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3712
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

HTH,
Paul.
 
James X Peterson
Whizlabs Java Support
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul and Charles...

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
 
charlsy chuks
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'm grateful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic