Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Annotations and EJB's

 
Jonah Kommu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just started reading about the changes 3.x brings. And there might be questions that already explain this on the forum.
What all do annotations do under the hood for me. I assume they generate the boiler plate code (remote, home objects etc)

TIA !
J
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are an alternate way to configure EJBs and other related services provided by the container. You can use them over XML configuration if you prefer.
 
Yash Don
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What all do annotations do under the hood for me. I assume they generate the boiler plate code (remote, home objects etc)


Actually annotation itself does not generate any boiler plate code for you. Annotations represnts the metadata associated with your class , attributes and methods. These are like preprocessors in C language. This metadata is used by the IDE, compiler and JVM (depending upon scope\retaintion policy of annotation) to extract additional information about class and attributes.

Check below tutorial for EJB 3

EJB 3 Tutorial
 
Jonah Kommu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This metadata is used by the IDE, compiler and JVM (depending upon scope\retaintion policy of annotation) to extract additional information about class and attributes.


Thanks for the response.
But would you be able to summarize how they are utilized and as to what the output is? Taking an example of a session bean.
 
Yash Don
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok I will explain you the concept of annotation in EJB 3 with the help of below EJB example. This is a simple EJB for validating credit card number.
Here we are using two annotations. Stateless and Remote. These annotations will be first processed by a program called annotation processor that can read a Java program and take actions based on its annotations. So these annotions are nothing but the instructions to the EJB container. EJB container gives special treatment to this class becoz of the annotions.

 
Jonah Kommu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hese annotations will be first processed by a program called annotation processor that can read a Java program and take actions based on its annotations.


Thanks again.
So what ALL actions would have been taken in your example below..?

-- any objects boilerplate objects get created
-- any JNDI mapping that was done
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic