File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Annotations Processing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Annotations Processing?" Watch "Annotations Processing?" New topic
Author

Annotations Processing?

Amit Suresh Pawar
Ranch Hand

Joined: Dec 09, 2008
Posts: 30
How the Annotations are processed by the COntainer?

Are They mapped into DD?


Amit S. Pawar
SCJP,SCWCD,OCA
Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
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


28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

I guess he was interested to know how and what the container does when it sees the Annotations.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
sanjeev mehra
Ranch Hand

Joined: Feb 12, 2001
Posts: 93
Mark Garland your answer is helpful to me.

Thanks.
Amit Suresh Pawar
Ranch Hand

Joined: Dec 09, 2008
Posts: 30
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

Joined: Nov 11, 2006
Posts: 226
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Annotations Processing?
 
Similar Threads
What is the need for marker interface ?
Annotating a Session Bean
Annotations
Annotations and the certification test
Annotations