Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

ejb injection with short bindings and long bindings confusion ?

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
 
Creator of Enthuware JWS+ V6
Posts: 3372
306
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Fritz.
 
Evil is afoot. But this tiny ad is just an ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic