J
Julien Klein
Hi !
I know this subject has already been discusses several times, but no
one situation seems to correspond to mine, so I decided to start a new
thread about it. I will try to be as clear as possible, yet if need
more information, just tell me..
To begin, just something about CORBA :
- I have a reference on an object (thanks to an IOR) which type is
org.omg.CORBA.Object
- I need to "narrow" this object to get a "real object"
- in the simple case (which is not mine), I just need to do the
following :
(1) pfmalarmService service =
(pfmalarmService)pfmalarmServiceHelper.narrow(obj)
where pfmalarmService is an interface and pfmalarmServiceHelper a
class (which implements no interface)
- my problem is that the name of the interface I need to cast my
object with is given as a string (here pfmalarmService)
- how can I do (is it possible ?), whatever the name X I receive as a
string, to execute the following (X is an interface) :
(2) X service = (X)XHelper.narrow(obj)
- I had a look on reflection in Java, I read a lot of threads about
dynamic casting and I am a bit lost in all these information. Yet, it
seems that there is no way for me to do what I want...
- During compile time, pfmalarm... classes are unknown, they are
generated later from an IDL file, so I can't modify these generated
files.
- all the interfaces I need to use (X interfaces as used above)
extends another interface which is called inService, so I can write :
(3) inService service = (inService)inServiceHelper.narrow(obj)
but after, it is not possible for me to call methods specific to one
particular X interface.
Let's take an example : imagine my interface pfmalarmeService extends
inService interface. In pfmalarmService, I have a method called
count(...) which is not defined in inService interface. So if I
execute (3), it is not possible for me to call count(...) method,
isn't it ?
Does someone have a idea or can someone tell me it is not possible for
me to do what I want ?
Thanks !!
Julien
I know this subject has already been discusses several times, but no
one situation seems to correspond to mine, so I decided to start a new
thread about it. I will try to be as clear as possible, yet if need
more information, just tell me..
To begin, just something about CORBA :
- I have a reference on an object (thanks to an IOR) which type is
org.omg.CORBA.Object
- I need to "narrow" this object to get a "real object"
- in the simple case (which is not mine), I just need to do the
following :
(1) pfmalarmService service =
(pfmalarmService)pfmalarmServiceHelper.narrow(obj)
where pfmalarmService is an interface and pfmalarmServiceHelper a
class (which implements no interface)
- my problem is that the name of the interface I need to cast my
object with is given as a string (here pfmalarmService)
- how can I do (is it possible ?), whatever the name X I receive as a
string, to execute the following (X is an interface) :
(2) X service = (X)XHelper.narrow(obj)
- I had a look on reflection in Java, I read a lot of threads about
dynamic casting and I am a bit lost in all these information. Yet, it
seems that there is no way for me to do what I want...
- During compile time, pfmalarm... classes are unknown, they are
generated later from an IDL file, so I can't modify these generated
files.
- all the interfaces I need to use (X interfaces as used above)
extends another interface which is called inService, so I can write :
(3) inService service = (inService)inServiceHelper.narrow(obj)
but after, it is not possible for me to call methods specific to one
particular X interface.
Let's take an example : imagine my interface pfmalarmeService extends
inService interface. In pfmalarmService, I have a method called
count(...) which is not defined in inService interface. So if I
execute (3), it is not possible for me to call count(...) method,
isn't it ?
Does someone have a idea or can someone tell me it is not possible for
me to do what I want ?
Thanks !!
Julien