Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Problem: return from one method when another method is called (http://www.velocityreviews.com/forums/t132725-problem-return-from-one-method-when-another-method-is-called.html)

Magne Bergfjord 04-20-2004 03:41 PM

Problem: return from one method when another method is called
 
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


John 04-20-2004 04:25 PM

Re: Problem: return from one method when another method is called
 
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


All times are GMT. The time now is 12:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.