aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes The place where we define Annotations inside the EJB Bean class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "The place where we define Annotations inside the EJB Bean class" Watch "The place where we define Annotations inside the EJB Bean class" New topic
Author

The place where we define Annotations inside the EJB Bean class

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

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")


Save India From Corruption - Anna Hazare.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3266
    
  52

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.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

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

Joined: Apr 27, 2009
Posts: 26
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

Joined: Apr 18, 2009
Posts: 2234

Thank you very much Sib . It was nice explanation from you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The place where we define Annotations inside the EJB Bean class