This discussion is archived
5 Replies Latest reply: Jun 11, 2010 10:02 AM by 843798 RSS

Retrieve used interface from implementation class

843798 Newbie
Currently Being Moderated
Hi to everyboby

I have a remoteObject that implement 2 interface (I1, I2). These interfaces are child of common father interface (I0).
This remote object is received unmarshalled and casted to one of the to directly implemented interface I1 or I2,

After that I want to execute a method declared into the interface I0 on the server side, that prints out the name of the interface used during casting after the unmarshall operation on the client side.

How can I retrieve the name of the current interface used to refer the object into the client side, from the server side?

Anyone as suggestions?

thank you very much

Edited by: dj3mb3 on Jun 10, 2010 5:49 AM
  • 1. Re: Retrieve used interface from implementation class
    DrClap Expert
    Currently Being Moderated
    This doesn't make any sense (or else I don't understand the question). An object has no way of knowing about any references to it, least of all the types of those references. What's the purpose of this requirement?
  • 2. Re: Retrieve used interface from implementation class
    EJP Guru
    Currently Being Moderated
    An object has no way of knowing about any references to it, least of all the types of those references.
    ... and least of all what happens in a different JVM.

    There is something seriously wrong with this 'requirement'.
  • 3. Re: Retrieve used interface from implementation class
    843798 Newbie
    Currently Being Moderated
    I'll try to explain in a better way ...

    I have a server with 2 different client and each client communicate to the server with a different interface.

    My needs are to recognize from the server, the type of the client that are operating, and to do this I was thinking to recognize the interface used from the client to interact with the server


    An other option is that, from the client, after retrieving the server and it's cast, a can call a method to pass to the server object, the type of the interface actually used.
    But I think this makes a bit of nonsense because When I receive the marshalled object in my opinion doesn't make sense that i have to say the object it's type (the interface used).
    the object is already alive and I think it has to know the interface used to refer it even if is on another VM
    The cast operation doesn't store nothing into the current object instance?

    local code example (I don't know if with JRMI the situation is different because the different JVM)
    Map foo = new HashTable();

    I need a method like
    foo.curretUsedInterface() ... that return "Map"

    instead of
    foo.getClass().getName() that return "HashMap"

    It's possible to obtain this information or I have to try another idea to make the server distinguish the client type?

    thank you very much for your comprehension
  • 4. Re: Retrieve used interface from implementation class
    DrClap Expert
    Currently Being Moderated
    dj3mb3 wrote:
    My needs are to recognize from the server, the type of the client that are operating, and to do this I was thinking to recognize the interface used from the client to interact with the server
    But clearly you can't do that.
    An other option is that, from the client, after retrieving the server and it's cast, a can call a method to pass to the server object, the type of the interface actually used.
    Yes, that would be a good option.
    But I think this makes a bit of nonsense...
    Yes, that's a good point. Perhaps the requirement that the server should recognize what type of client is sending the request is a bogus requirement. Why does it have to recognize that? Why should it behave differently for different clients who send the same request?
  • 5. Re: Retrieve used interface from implementation class
    843798 Newbie
    Currently Being Moderated
    Thank you very much, you have clarify my ideas a lot

    this is not a requirement, but a patch for a security bug introduced by my first implementation. :P

    anyway thank you another time

    bye bye