I have a class which connects to a web service and then returns the response. The class is working in a different thread. It is called SoapConnector. There is an interface which notify the caller that the response is ready. It is:
public interface ISoapConnectorObserver {
public void onSoapRequestFinished(String response);
}
When the response is ready, the onSoapRequestFinished() is called.
I use the SoapConnector for fetching different data. For example CustomerReader for reading the customers from server and ProductReader for reading the products list. How can i change the ISoapConnectorObserver to differentiate the return value from CustomerReader or ProductReader?
public class CustomerReader {
private observer ISoapConnectorObserver observer;
public CustomerReader(ISoapConnectorObserver observer) {
this.observer = observer;
}
.
.
}
public class ProductReader {
private observer ISoapConnectorObserver observer;
public ProductReader(ISoapConnectorObserver observer) {
this.observer = observer;
}
.
.
}
I want to find an elegant way to not to use another helper class, but extending this interface or changing the onSoapRequestFinished(). Thanks