why use JNDI in EJB?

J

jrefactors

I want to ask why we need to use JNDI in EJB. It is optional, right? In
what situations we need to use JNDI? is it better performance?
advantages? disadvantages?

please advise. thanks!!
 
F

Frank Seidinger

I want to ask why we need to use JNDI in EJB. It is optional, right? In
what situations we need to use JNDI? is it better performance?
advantages? disadvantages?

For EJB the use of JNDI is not optional. For better understanding why you
need JNDI, I would advise you to read a beginners book of EJB principles.

But for short here are some hints. EJB are components running in an
application server. Clients that want to use an EJB must get an instance,
more precisely an interface, first. Because EJB are living insinde the
application server you cannot create an EJB using the new operator.
Therefore you need someone that creates an EJB in behalf of you.

Here comes JNDI into use. Each EJB registers the factory for creating
instances of the EJB in the JNDI. JNDI takes the place of a yello page. You
tell JNDI what kind of service you need (the name of the EJB) and get back
the factory for it (home interface). With the factory you can create an
instance of an EJB and use it.

That's all. So without JNDI there is no factory. No factory, no EJB.

Frank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top