class interfaces to server
This may not be the right forum for this question, but if anyone has any thoughts, I would appreciate it.
I am a bit unclear on what the best approach is given the following scenario:
I have a program I am writing which needs to interface to my server and database. To do so, I have am writing a ServerRequest class (actually its an interface with an implementation and a factory class to instantiate... although for the purposes of this question, I don't think that makes a difference)
Other classes instantiate the ServerRequest class and make various requests to the server through it. The ServerRequest class creates a new thread, and handles the http request.
Unfortunately, I need my listener for the server's response to be from the original class which had the ServerRequest instance, and not the ServerRequest class itself. Barring that, I would still need to get the information back to the original class from the ServerRequest.
In other languages, I would simply pass a function from the original class to the ServerRequest class to be the listener. However, I don't think that is quite right in java.
Can anyone point me in the right direction for the best way to attack this?
Thanks in advance!