• 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

The place where we define Annotations inside the EJB Bean class

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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")

 
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Sib . It was nice explanation from you
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic