How to get a handle for an EJB ?

M

Manish Pandit

Question is, How to get a handle for an EJB ?
How does a client would find out a handle for an EJB ?

You can do a getHandle() on the EJB instance.

-cheers,
Manish
 
G

gk

Manish said:
You can do a getHandle() on the EJB instance.

-cheers,
Manish


what do you mean by EJB instance here ?

remote interface ?
home interface ?


client can not get hold of EJB directly , so i am not clear what do you
mean by EJB instance here ? please explain more

thank you
 
M

Manish Pandit

In order to use an EJB, I believe these are the steps you are following
(assuming server side code is all deployed and happy)

1. JNDI lookup to get the home interface (which can be local or remote)
2. narrow the reference to home interface if it is remote
3. call create() on the home interface reference to get the
remote/local interface
4. Whatever you receive after 3, the one on which you actually invoke
business methods is what you can call getHandle() on. It implements
EJBObject interface and it is not the actual bean that is there on the
server, but kind of a proxy to it.

Hope this is clear now :)

-cheers,
Manish
 
G

gk

Manish said:
In order to use an EJB, I believe these are the steps you are following
(assuming server side code is all deployed and happy)

1. JNDI lookup to get the home interface (which can be local or remote)
2. narrow the reference to home interface if it is remote
3. call create() on the home interface reference to get the
remote/local interface
4. Whatever you receive after 3, the one on which you actually invoke
business methods is what you can call getHandle() on. It implements
EJBObject interface and it is not the actual bean that is there on the
server, but kind of a proxy to it.

Hope this is clear now :)

-cheers,
Manish


yes ...its clear now.

thanks

i have question on your comments though.

you mentioned ,
"narrow the reference to home interface if it is remote"

I think , in EJB 2.0 we dont need to narrow it ...we dont need to use
portableremoteobject.narrow() method .we will do the direct casting to
home interface....am i right ? we do it for EJB 1.1
 
M

Manish Pandit

Hi,

You have to narrow the reference as long as it is *remote*. The
narrowing concept is carried forward from the CORBA days, and anything
dealing with IIOP has to be narrowed. You do not need the narrow() step
if you are dealing with local interfaces (inter-JVM).

-cheers,
Manish
 

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
474,269
Messages
2,571,097
Members
48,773
Latest member
Kaybee

Latest Threads

Top