Problem: return from one method when another method is called

Discussion in 'Java' started by Magne Bergfjord, Apr 20, 2004.

  1. Hi!

    I have an http module which I intend to use in my application:

    To connect to a server and send a request, there is a method like this in
    the module:

    public void sendRequest(String query){
    ....
    }

    When the server responds, it calls another method in the same class:

    public void respons(String results){
    ....
    }

    I want to combine these two methods so that my application can use one
    method looking something like this:

    public String sendRequest(String xml){
    ....
    }

    which returns the results when the server calls the respons method. Is
    this possible?

    To summarize, the problem is to make one method return something when
    another method is called. I guess there are some smart ways around this
    problem, but I haven't found any yet. I hope there is some way to solve
    this without changing the underlaying logic of the http module too much.

    Magne Bergfjord
    Magne Bergfjord, Apr 20, 2004
    #1
    1. Advertising

  2. Magne Bergfjord

    John Guest

    Magne Bergfjord wrote:
    > Hi!
    >
    > I have an http module which I intend to use in my application:
    >
    > To connect to a server and send a request, there is a method like this in
    > the module:
    >
    > public void sendRequest(String query){
    > ...
    > }
    >
    > When the server responds, it calls another method in the same class:
    >
    > public void respons(String results){
    > ...
    > }
    >
    > I want to combine these two methods so that my application can use one
    > method looking something like this:
    >
    > public String sendRequest(String xml){
    > ...
    > }
    >
    > which returns the results when the server calls the respons method. Is
    > this possible?
    >
    > To summarize, the problem is to make one method return something when
    > another method is called. I guess there are some smart ways around this
    > problem, but I haven't found any yet. I hope there is some way to solve
    > this without changing the underlaying logic of the http module too much.
    >
    > Magne Bergfjord
    >


    public String getData(String input) {

    //contact the server

    //initialise a variable x that will be set by the server.

    while(notset(x)) {

    //sleep
    }

    //return x

    }

    John
    John, Apr 20, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. loveNUNO
    Replies:
    2
    Views:
    908
    loveNUNO
    Nov 20, 2003
  2. Apricot
    Replies:
    4
    Views:
    524
    velthuijsen
    Apr 16, 2004
  3. Mars
    Replies:
    2
    Views:
    409
    Bengt Richter
    Jul 19, 2003
  4. Robert Cohen
    Replies:
    3
    Views:
    269
    Andrew Durstewitz
    Jul 15, 2003
  5. Trans
    Replies:
    5
    Views:
    103
    Trans
    Aug 9, 2005
Loading...

Share This Page