Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb injection with short bindings and long bindings confusion ?

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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;
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2448
96
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Fritz.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic