This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Annotations Processing?

 
Amit Suresh Pawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How the Annotations are processed by the COntainer?

Are They mapped into DD?
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

The DD is a deployment descriptor (an xml file) where you describe your deployment - just like web.xml in a web app.
Annotations are put directly in the code and can be loaded by a Java class (or Container) using the Reflection API.
They are just two ways of describing the same thing. If both are used, the DD takes precedence.

Does this answer your question?

MG
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess he was interested to know how and what the container does when it sees the Annotations.
 
sanjeev mehra
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Garland your answer is helpful to me.

Thanks.
 
Amit Suresh Pawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi MG........

I got what you want to say.thanks.
But,
I know that Container reads the DD at start up. And DD also has the default values for their tags. So, if the annotations are in generated into java codes then at startup it needs to be replaced by values in the DD( or by default values ,if they are not initialized).

Finally, every time DD will replace values defined by annotations. Is it so?
I think no, then what is the correct flow?

Thank You....
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

As far as I know you are correct - the DD replaces (overrides) values from annotations.

This is useful as otherwise you'd need to recompile the source (which you may or may not have) to change the value in an annotation.

For example, let's say you defined a database connection string in an annotation and compiled the class and sent it to me.
Now, I may want to change that database connection string to something more applicable to my environment - but I couldn't do that without the source.
However, I *can* use a deployment descriptor to override your value, and for that I don't need the source.

Hope that helps,

MG
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic