PortableRemoteObject.narrow() purpose?

V

Vjeran Marcinko

Hi folks.

What is the purpose of PortableRemoteObject.narrow() ? It throws ClassCastException same as any unsuccessuful casting would do using only brackets, for eg. :
CastedClass castedObject = (CastedClass) object;
thus it could be ommitted then, right ?

Ragards,
Vjeran
 
D

Dobromir Gaydarov

The trick is that you have to do both narrow and cast to the type you want
if you are dealing with remote objects.

Regards,
Dobromir


Hi folks.

What is the purpose of PortableRemoteObject.narrow() ? It throws
ClassCastException same as any unsuccessuful casting would do using only
brackets, for eg. :
CastedClass castedObject = (CastedClass) object;
thus it could be ommitted then, right ?

Ragards,
Vjeran
 
A

Adam Maass

What is the purpose of PortableRemoteObject.narrow() ? It throws
ClassCastException same as any >unsuccessuful casting would do using only
brackets, for eg. :
CastedClass castedObject = (CastedClass) object;
thus it could be ommitted then, right ?


If you are doing remote operations, then PortableRemoteObject.narrow()
resolves issues with certain frameworks -- namely CORBA -- that have no
notion of java-style inheritence. The method takes an object (a remote stub)
and an interface (respresented by its Class object) and returns an object
that implements that interface and that also corresponds to the passed
remote stub. Usually, this is the same object that was passed in. But
sometimes it isn't.

-- Adam Maass
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top