• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How the Annotations are Processed?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Christophe explained. Java has a reflection API that allows to inspect class information at runtime.
 
mahudees waran
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic