my dog learned polymorphism*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejb injection with short bindings and long bindings confusion ? 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 » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ejb injection with short bindings and long bindings confusion ?" Watch "ejb injection with short bindings and long bindings confusion ?" New topic
Author

ejb injection with short bindings and long bindings confusion ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Please refer to the link http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.nd.multiplatform.doc%2Finfo%2Fae%2Fae%2Fcejb_bindingsejbfp.html

following are the lines of interest from the above link :

The server always creates a default long-form binding for each EJB interface, including the no-interface view, and places them into the java:global, java:app, and java:module namespaces. A short-form binding is also created and placed into the java:global, java:app, and java:module namespaces, if the bean exposes only one interface, including the no-interface view. The default bindings are only created for session beans. They are not created for entity beans or message driven beans

The long-form binding pattern is java:global/<applicationName>/<moduleName>/<bean component name>!<fully qualified interface name>.

The short-form binding pattern is java:global/<applicationName>/<moduleName>/<bean component name>.


the link says short-form binding is only created when bean exposes ONLY ONE interface. my question is that if the bean exposes more than one interface than why cant we use short-form because even if there are multiple interfaces exposed BEAN COMPONENT NAME will be unique and there wont be any ambiguity of any kind . ? for e.g.

Application name : MyApp
Module name : MyEjb-jar.jar
Ejb Name : MyEjb
Interface names : MyEjbLocal, MyEjbLocal1

now CANT WE use short form like this

@EJB(lookup=java:global/MyApp/MyEjb-jar/MyEjb)
MyEjbLocal local;
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1731
    
  25

Hi Gurpeet,

my question is that if the bean exposes more than one interface than why cant we use short-form because even if there are multiple interfaces exposed BEAN COMPONENT NAME will be unique and there wont be any ambiguity of any kind . ? for e.g.

The simple answer is because the specs specify that the short-form-binding should only be created if there is one interface:
4.4 Global JNDI Access
. . .
In addition to the previous requirements, if the bean exposes only one of the applicable client interfaces(or alternatively has only a no-interface view), the container registers an entry for that view with the following syntax :

java:global[/<app-name>]/<module-name>/<bean-name>

The container is also required to make session bean JNDI names available through the java:app and java:module namespaces.

Apart from that if you inject the EJB on the class, like this:
Then you will need the extra information of the interface that is requested, because you can't deduct it from the property.

Regards,
Frits
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Thanks a lot Fritz.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejb injection with short bindings and long bindings confusion ?