aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes How the Annotations are Processed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "How the Annotations are Processed?" Watch "How the Annotations are Processed?" New topic
Author

How the Annotations are Processed?

mahudees waran
Greenhorn

Joined: Dec 17, 2006
Posts: 28
Can any one please help me out to understand how the annotations are processed by the container? and how does container use it when compared to DD?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The Container will scan the classes when they are deployed. It will probably use methods like Class#getAnnotation and Class#getAnnotations on the class, on its fields and on its methods. It does it once, then parses the DD and overrides any existing settings.


[My Blog]
All roads lead to JavaRanch
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
As Christophe explained. Java has a reflection API that allows to inspect class information at runtime.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
mahudees waran
Greenhorn

Joined: Dec 17, 2006
Posts: 28
Thanks for your reply guys.

Christophe,
Do you mean that the container first reads the DD and then overrides the DD configurations according to the annotations in classes while loading them.Also loading the classes which does mean that, Every class in the application will be loaded while the server startup? where as in case of servlets the servlet class is loaded on the first request untill we specifically mention it to load while server startup using
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
DD overrides annotations.

I don't know detail, but I guess container just read class metadata, not create instance of every class.
When use reflection API to inspect class metadata, we don't need to create an instance of class. Anyway, a class itself is some kind of instance, but you don't need to worry about that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How the Annotations are Processed?