This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Interfaces " Watch "Interfaces " New topic
Author

Interfaces

Dura Hurtado
Ranch Hand

Joined: Feb 16, 2011
Posts: 120
Hi, ¿could someone explain what way the next code works?


InterfaceName bean =(InterfaceName)context.lookup("JNDI-Name");


In bean, ¿is loaded an interface name or the code which is write in the EJB which correspond the interface name, or another way?

Thanks.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

The resource at "JNDI-NAME" is fetched from the JNDI and returned as an Object.
It is not an interface it is an Object.

The next step is to cast the resulted Object to the type you're expecting (in this case "InterfaceName").

Does this answer your question?


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Dura Hurtado
Ranch Hand

Joined: Feb 16, 2011
Posts: 120
The resource at "JNDI-NAME" is fetched from the JNDI and returned as an Object.
It is not an interface it is an Object.

The next step is to cast the resulted Object to the type you're expecting (in this case "InterfaceName").

Does this answer your question?


Yes , thanks for your answer.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

That's great :-)

Good luck!
 
wood burning stoves
 
subject: Interfaces
 
Similar Threads
casting
Anonymous class doubt.......
javadoc bug or missing an option for class extending AbstractTableModel
Inheritance
pass by reference problem?