4 Replies Latest reply: Feb 5, 2012 2:22 AM by EJP RSS

    How can I get Remote Address from Object?

    915335
      Hi,

      I have a problem with using Java RMI such that,

      My Client class is like this;



      String remote_address=...;

      Server_Int remobj= (Server_Int) Naming.lookup(remote_address);

      String str=....;
                     
      String str=remobj.send(str);



      Now I have a remote object as "*remobj*",

      And I want to reach its connection address *"remote_address"*

      HOw can I find this address?

      Thanks a lot....
        • 1. Re: How can I get Remote Address from Object?
          EJP
          You can't.

          Or rather you can, by using the proprietary part of the API, but in my book that's the same as "can't".

          Why do you think you need this?
          • 2. Re: How can I get Remote Address from Object?
            DarrylBurke
            Cross posted
            http://www.java-forums.org/networking/55108-how-can-i-get-remote-address-object-java-rmi.html
            http://www.javaprogrammingforums.com/java-networking/13802-how-can-i-get-remote-address-object-java-rmi.html#post56981

            db
            • 3. Re: How can I get Remote Address from Object?
              915335
              Hi,

              I want to develop and Aspect (by using AspectJ) Oriented Software

              In an aspect I can catch the *"remobj.send(str)"* command with parameters of *"remobj"* and *"str"*

              -----
              _ String remote_address=...;

              _ Server_Int remobj= (Server_Int) Naming.lookup(remote_address);

              _ String str=....;

              _ String str=remobj.send(str);

              -----

              And I want to send a different (*type*) message (for example an Object or Integer) to the same server machine.

              I cannot use "send" method, because parameter type is changed now.

              Therefore, I create a different server object (SO) which implements and interface with *"send(Object)"* method.

              If I can reach the IPaddress of the "*remobj*", I can also reach the newly created *"server object (SO)"* and call its *"send(Object)"* method.

              My main goal is sending a different (type) message to server node. I want to make some modifications on original message, so type of message should also be changed.

              How can I achieve this?

              Can I use a different approach for this?

              Thanks...
              • 4. Re: How can I get Remote Address from Object?
                EJP
                I cannot use "send" method, because parameter type is changed now.
                So you need to define a different send() method.
                Therefore, I create a different server object (SO) which implements and interface with *"send(Object)"* method.
                Which you must export, to be accessible via RMI, and which will therefore have its own stub, which you have to acquire somehow.
                If I can reach the IPaddress of the "*remobj*", I can also reach the newly created *"server object (SO)"* and call its *"send(Object)"* method.
                Correct, but knowing the IP address won't help you in that process. What you need is the stub of the second object.