aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3.0 - Injecting EJB References - confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3.0 - Injecting EJB References - confusion" Watch "EJB 3.0 - Injecting EJB References - confusion" New topic
Author

EJB 3.0 - Injecting EJB References - confusion

Saeed Amer
Ranch Hand

Joined: Jan 20, 2004
Posts: 140
Hi there,

Section "16.5 EJB References" (ejb core spec - Page# 414):
Sub-section: "16.5.1.1 Injection of EJB References" says:

The Bean Provider uses the EJB annotation to annotate a field or setter property method of the bean class as a target for the injection of an EJB reference. The reference may be to a session bean�s business interface or to the local home interface or remote home interface of a session bean or entity bean. The following example illustrates how an enterprise bean uses the EJB annotation to reference another enterprise bean. The enterprise bean reference will have the name java:comp/env/com.acme.example.ExampleBean/myCart in the referencing bean�s
naming context, where ExampleBean is the name of the class of the referencing bean and com.acme.example its package. The target of the reference must be resolved by the Deployer.



I am confused - is this ALL one has to do to inject an EJB reference? Don't we have to specify the following:

  • name
  • beanInterface
  • beanname



  • TIA for help!
    Saeed
    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17260
        
        6

    Nope, the container can figure out based you your interface, what to inject.

    Now, if there is ever a conflict where there could be two or more possibilities, then you can include the JNDI name to help the container out. There are attributes that you can include with @EJB, as in all EJB Annotations, it is just that EJB3 has these smart defaults.

    Mark


    Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
    How to Ask Questions the Smart Way FAQ
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: EJB 3.0 - Injecting EJB References - confusion