This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Which is better when working with J2EE Beans?

 
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


































 
Enthuware Software Support
Posts: 4452
41
  • 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.
 
Whizlabs Java Support
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.
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic