• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The place where we define Annotations inside the EJB Bean class

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have seen that the @Stateless is defined at the top of the class .

and the @Resource is defined at the method level .

Please let me know what is the name given to that annotation if it is defined at the class Level.

For example :

@Stateless(name="HelloEjb",mappedName="HelloEjb")

public class HelloEjbBean implements HelloEjb
{}

And at @Resource is defined at :

public class BidderAccountCreatorBean implements BidderAccountCreator
{

@Resource(name = "jdbc/ActionBazaarDS", mappedName="jdbc/ActionBazaarDS")

 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4501
267
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For @Resource that is the JNDI name which can be used in 'lookup's within that class. For @Stateless you can specify a name for the ejb, as same as you do with <ejb-name> XML element.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Devaka .

Actually my question is :

Do we call @Resource Annotations as Method Level Annotations . and @Stateless as Class Level Annotations .

Am i correct here ??

Thanks in advance.
 
Sib Pete
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do we call @Resource Annotations as Method Level Annotations . and @Stateless as Class Level Annotations .


The @Stateless annotation marks that the class is a 'Stateless' session bean implementing some local/remote interface and that should it be handled accordingly by the container.

The @Resource annotation on the other hand can be either a method level annotation if its used on a setter method or also a field level annotation if used on a declaring field statement. What this annotation does is that it lets the ejb container know that the particular resource needs to be injected and set via dependency injection on invocation.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Sib . It was nice explanation from you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic