[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openorb-users
Subject:    Re: [openorb-users] Problem with ListInputStream.readObject(Class)
From:       Jesper Pedersen <jep () itplus ! dk>
Date:       2002-12-22 17:03:38
[Download RAW message or body]

Quoting Peter Wensing <Peter.Wensing@integrated-workflow.de>:
> No, I don't think so. The condition is correct.
> 
> In my case, n contains an ObjectStub (an instance of class 
> org.openorb.CORBA.ObjectStub). It would be wrong to return this.
> 
> Instead it has to be narrowed to the specialized Stub (in my case, an
> instance 
> of com.iw.examples.orderingprocess._CustomerStub).
> But as the clz parameter, the method gets the class object of 
> com.iw.examples.orderingprocess.Customer.
> 
> So we have to find the right Stub class object (of type 
> com.iw.examples.orderingprocess._CustomerStub) for the given interface class
> 
> object (of type com.iw.examples.orderingprocess.Customer), create an instance
> 
> of it, assign it the delegate of the ObjectStub in n and return the newly 
> created instance. (Be aware, that there is no inheritance between stubs !)
> 
> Alternatively, the clz parameter may be the class object of the specialized 
> stub. Then everything is working fine, cause we can now directly create an 
> instance from the given stub class as it is done in the code.
> 
> So, the problem can be reduced to finding the stub class object for a given 
> interface class object. And I don't know how to do that in the OpenORB code.
>

Generally:
Short answer: You can't
Longer answer:
A class (or an interface) has a relation with the interfaces it implements and 
its super class.

An interface has no relation with its implementing classes.

You can ofcourse go through all classes loaded by the classloader and check for 
if the current class implements the needed interface. But ofcourse more classes 
can implement the same interface, so you don't know if you have the right one.

OpenORB:
Since the stub objects are created by the IDL to Java mapping we can make some 
assumptions when resolving the class name which we want to check. So it can be 
done in the OpenORB code.

You'll need to use the loadClass() method on the correct classloader (found by 
Thread.currentThread().getContextClassloader()).

> Peter
> 

Hope this helps.

 Jesper




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
openorb-users mailing list
openorb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openorb-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic