Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Annotations and EJB's

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic